forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-iplist.php
executable file
·49 lines (42 loc) · 1.12 KB
/
generate-iplist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env php
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @author Adam Armstrong <[email protected]>
* @copyright (C) 2006 - 2012 Adam Armstrong
*
*/
include("includes/defaults.inc.php");
include("config.php");
include("includes/definitions.inc.php");
include("includes/functions.php");
$handle = fopen("ips.txt", "w");
foreach (dbFetchRows("SELECT * FROM `ipv4_networks`"))
{
$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)
{
$ipdotted = long2ip($ip);
if (dbFetchCell("SELECT COUNT(ipv4_address_id) FROM `ipv4_addresses` WHERE `ipv4_address` = ?", array($ipdotted)) == '0' && match_network($config['nets'], $ipdotted))
{
fputs($handle, $ipdotted . "\n");
}
$ip++;
}
}
}
fclose($handle);
shell_exec("fping -t 100 -f ips.txt > ips-scanned.txt");
?>