2010-09-03 18:26:59 +00:00
#!/usr/bin/env php
2009-09-07 11:07:59 +00:00
< ? php
2010-02-27 14:44:38 +00:00
include ( " includes/defaults.inc.php " );
2007-04-03 14:10:23 +00:00
include ( " config.php " );
include ( " includes/functions.php " );
2011-03-08 18:17:49 +00:00
$handle = fopen ( " ips.txt " , " w " );
2007-04-03 14:10:23 +00:00
2010-06-12 20:14:41 +00:00
$query = mysql_query ( " SELECT * FROM `ipv4_networks` " );
2011-04-06 13:54:50 +00:00
while ( $data = mysql_fetch_assoc ( $query ))
2011-03-08 18:17:49 +00:00
{
2011-03-23 09:54:56 +00:00
$cidr = $data [ 'ipv4_network' ];
list ( $network , $bits ) = explode ( " / " , $cidr );
if ( $bits != '32' && $bits != '32' && $bits > '22' )
{
$addr = Net_IPv4 :: parseAddress ( $cidr );
$broadcast = $addr -> broadcast ;
$ip = ip2long ( $network ) + '1' ;
$end = ip2long ( $broadcast );
while ( $ip < $end )
2011-03-08 18:17:49 +00:00
{
2011-03-23 09:54:56 +00:00
$ipdotted = long2ip ( $ip );
if ( mysql_result ( mysql_query ( " SELECT count(ipv4_address_id) FROM ipv4_addresses WHERE ipv4_address = ' $ipdotted ' " ), 0 ) == '0' && match_network ( $config [ 'nets' ], $ipdotted ))
{
fputs ( $handle , $ipdotted . " \n " );
}
$ip ++ ;
2007-04-03 14:10:23 +00:00
}
2011-03-23 09:54:56 +00:00
}
2007-04-03 14:10:23 +00:00
}
2011-03-08 18:17:49 +00:00
fclose ( $handle );
shell_exec ( " fping -t 100 -f ips.txt > ips-scanned.txt " );
2007-04-03 14:10:23 +00:00
?>