Commit | Line | Data |
---|---|---|
8de51304 H |
1 | #!/usr/bin/php |
2 | <?php | |
3 | ||
4 | function ip_rand($all = false) { | |
5 | if(!$all) { | |
6 | return(rand(1,254).'.'.rand(1,254).'.'.rand(1,254).'.'.rand(1,254)); | |
7 | } else { | |
8 | return(rand(0,255).'.'.rand(0,255).'.'.rand(0,255).'.'.rand(0,255)); | |
9 | } | |
10 | } | |
11 | ||
12 | function ip_range($ip) { | |
13 | $ip = explode('.', trim($ip)); | |
14 | if($ip[0]==0 || $ip[0]==255) return 3; | |
15 | if($ip[0]==127 && $ip[1]==0 && $ip[2]==0) return 2; | |
16 | if($ip[0]==10) return 1; | |
17 | if($ip[0]==172 && $ip[1]>=16 && $ip[1]<=31) return 1; | |
18 | if($ip[0]==192 && $ip[1]==168) return 1; | |
19 | return 0; | |
20 | } | |
21 | ||
22 | function scan_check($ip, $port=80, $timeout = 0.4) { | |
23 | $fp = @fsockopen($ip, $port, $errno, $errstr, $timeout); | |
24 | if($fp) return 1; | |
25 | } | |
26 | ||
27 | //while(1) echo(ip_range(ip_rand())."\n"); | |
28 | ||
29 | ||
30 | while(1) { | |
31 | if(ip_range($ip = ip_rand())) continue; | |
32 | if(scan_check($ip, 23)) echo($ip."\n"); | |
33 | //echo($ip.' - '.gethostbyaddr($ip)."\n"); //Debug | |
34 | } | |
35 | /* | |
36 | 24-bit block 10.0.0.0 - 10.255.255.255 | |
37 | 20-bit block 172.16.0.0 - 172.31.255.255 | |
38 | 16-bit block 192.168.0.0 - 192.168.255.255 | |
39 | */ |