비정상 접속 아이피 블럭

#!/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년 전 조회 885
10년 전 조회 973
10년 전 조회 1,129
10년 전 조회 1,351
10년 전 조회 837
10년 전 조회 2,206
10년 전 조회 1,049
10년 전 조회 1,025
10년 전 조회 1,258
10년 전 조회 1,652
10년 전 조회 1,589
10년 전 조회 1,527
10년 전 조회 882
10년 전 조회 1,164
10년 전 조회 977
10년 전 조회 1,330
10년 전 조회 1,731
10년 전 조회 1,442
10년 전 조회 1,117
10년 전 조회 1,262
10년 전 조회 1,265
10년 전 조회 1,245
10년 전 조회 1,288
10년 전 조회 1,239
10년 전 조회 1,311
10년 전 조회 1,298
10년 전 조회 1,847
10년 전 조회 1,496
10년 전 조회 1,338
10년 전 조회 1,588