비정상 접속 아이피 블럭

#!/bin/bash

for i in $( tail -n50 /usr/local/apache/logs/*log | grep '301 ' | awk '{print $1}' | sort | uniq -c | awk '$1 >30 {print $2}'); do
echo "$i blocked"
/root/block $i
done

sleep 30

for i in $( tail -n50 /usr/local/apache/logs/*log | grep '301 ' | awk '{print $1}' | sort | uniq -c | awk '$1 >30 {print $2}'); do
echo "$i blocked"
/root/block $i
done


for i in $(tail -n50 /usr/local/apache/logs/*log | grep 'htmGET' | awk '{print $2}' | grep -v 'Jan'); do

echo "$i blocked"

/root/block $i

done



cat block 

#!/usr/local/bin/php

<?

posix_setuid(0);

$ip = $argv[1];


//$id = sem_get(0x12341234, 1);

//sem_acquire($id);


$a = `iptables -L -n | grep $ip`;

if(!$a)`iptables -I INPUT -s $ip -j DROP`;


//sem_release($id);

?>


 

 

더 좋은 방법 있으면 공유 부탁 드립니다. 

|
댓글을 작성하시려면 로그인이 필요합니다.

호스팅정보

+
제목 글쓴이 날짜 조회
10년 전 조회 883
10년 전 조회 973
10년 전 조회 1,129
10년 전 조회 1,350
10년 전 조회 836
10년 전 조회 2,205
10년 전 조회 1,047
10년 전 조회 1,025
10년 전 조회 1,254
10년 전 조회 1,650
10년 전 조회 1,587
10년 전 조회 1,525
10년 전 조회 881
10년 전 조회 1,162
10년 전 조회 976
10년 전 조회 1,330
10년 전 조회 1,731
10년 전 조회 1,440
10년 전 조회 1,114
10년 전 조회 1,262
10년 전 조회 1,265
10년 전 조회 1,244
10년 전 조회 1,288
10년 전 조회 1,236
10년 전 조회 1,310
10년 전 조회 1,295
10년 전 조회 1,847
10년 전 조회 1,496
10년 전 조회 1,336
10년 전 조회 1,585