2007-04-03 14:10:23 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?
|
|
|
|
include("config.php");
|
|
|
|
include("includes/functions.php");
|
|
|
|
|
2008-04-10 14:52:51 +00:00
|
|
|
shell_exec("rm ips.txt && touch ips.txt");
|
2007-04-03 14:10:23 +00:00
|
|
|
|
|
|
|
$handle = fopen("ips.txt", "w+");
|
|
|
|
|
|
|
|
$query = mysql_query("SELECT * FROM `networks`");
|
|
|
|
while ($data = mysql_fetch_array($query)) {
|
|
|
|
$cidr = $data['cidr'];
|
|
|
|
list ($network, $bits) = split("/", $cidr);
|
|
|
|
if($bits != '32' && $bits != '32' && $bits > '22') {
|
2008-04-10 14:52:51 +00:00
|
|
|
$broadcast = trim(shell_exec($config['ipcalc']." $cidr | grep Broadcast | cut -d\" \" -f 2"));
|
2007-04-03 14:10:23 +00:00
|
|
|
$ip = ip2long($network) + '1';
|
|
|
|
$end = ip2long($broadcast);
|
|
|
|
while($ip < $end) {
|
|
|
|
$ipdotted = long2ip($ip);
|
2008-03-15 17:58:15 +00:00
|
|
|
if(mysql_result(mysql_query("SELECT count(id) FROM ipaddr WHERE addr = '$ipdotted'"),0) == '0' && match_network($config['nets'], $ipdotted)) {
|
2007-04-03 14:10:23 +00:00
|
|
|
fputs($handle, $ipdotted . "\n");
|
|
|
|
}
|
|
|
|
$ip++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
`fping -t 100 -f ips.txt > ips-scanned.txt`;
|
|
|
|
|
|
|
|
?>
|