<?php
### Brainy Control Panel
### Decoded IonCube by pimnik98
### Декодировал Пиминов Никита
### vk.com/piminov_remont
### Скрипт скачан с портала X-Scripts.Ru
define("DEBUG", "0");
$var = $argc;
$ip_size = 10;
$port = "all";
$syn_type = "NULL";
$ch = "true";
if ($var < 6) {
if ($var == 2) {
$ip_size = $argv[1];
} else {
if ($var == 3) {
list(, $ip_size, $port) = $argv;
} else {
if ($var == 4) {
list(, $ip_size, $port, $syn_type) = $argv;
} else {
if ($var == 5) {
list(, $ip_size, $port, $syn_type, $ch) = $argv;
}
}
}
}
include "/etc/brainy/classes/server.php";
include "/etc/brainy/classes/network_tools.php";
$net_tools = new network_tools();
$t = time();
$date = date("d-m-Y", $t);
$time = date("H:i:s", $t);
$syn = "TIME_WAIT";
if ($port == "all" && $syn_type == "NULL") {
if (DEBUG == "1") {
echo "Info: port all, syn_type NULL\n";
}
$n = $net_tools->net_connections_n();
$list = $net_tools->net_connections();
} else {
if ($port != "all" && $syn_type == "NULL") {
if (DEBUG == "1") {
echo "Info: port=" . $port . ", syn_type=" . $syn_type . "\n";
}
$list = $net_tools->net_portconn_tmp($port);
$net_tools->net_portconn($port);
$n = $net_tools->net_portconn_correct_n($port);
} else {
if ($port != "all" && $syn_type == $syn) {
if (DEBUG == "1") {
echo "Info: port=" . $port . ", syn_type=" . $syn_type . "\n";
}
$list = $net_tools->net_portconn_tmp($port);
$n = $net_tools->net_portconn_correct_n($port);
} else {
if ($port == "all" && $syn_type == $syn) {
if (DEBUG == "1") {
echo "Info: port = all, syn_type=" . $syn_type . "\n";
}
$list = $net_tools->net_syncrec_connections(0);
$n = $net_tools->net_syncrec_n(0);
} else {
if (DEBUG == "1") {
echo "Info: port = all, syn_type=" . $syn_type . "\n";
}
$list = $net_tools->net_syncrec_connections(0);
$n = $net_tools->net_syncrec_n(0);
}
}
}
}
if (DEBUG == "1") {
print $date . " " . $time . " Size:" . $ip_size . " Port:" . $port . " SYN:" . $syn_type . " n_connect:" . $n . " check:" . $ch . "\n";
}
if (0 < $n && $ip_size < $n) {
for ($i = 0; $i < count($list); $i++) {
$addr = explode(" ", trim($list[$i]));
if (!($addr[1] == "127.0.0.1" || $addr[1] == "localhost")) {
$out = $net_tools->net_iptables_drop_ip($addr[1]);
}
if ($ch == "true") {
print "" . $date . " " . $time . " IP:" . $addr[1] . " Blocking. (connections:" . $n . ", port:" . $port . ")" . "\n";
}
}
}
} else {
echo "params error\n";
exit;
}
?>