$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
$event=array("InvalidAccountID","InvalidPassword");
if (preg_match("/\b$event[0]\b/i", $result,$match) || preg_match("/\b$event[1]\b/i", $result,$match)){
$result=explode("\n",$result);
//foreach($result as $key=>$value){
//echo "$key : $value\n";
$ip=$result[9];
$ip=explode("/",$ip);
echo "$ip[2]\n";
system("iptables -A INPUT -s $ip[2] -j DROP");
//}
}
}
}
fclose($socket);
?>
nohup php ami_guard.php >> ban.txt &
No hay comentarios:
Publicar un comentario