moved libpurple-answerscripts to separate repository. wow!
[mirrors/Programs.git] / php / randscan.php
CommitLineData
8de51304
H
1#!/usr/bin/php
2<?php
3
4function 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
12function 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
22function 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
30while(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/*
3624-bit block 10.0.0.0 - 10.255.255.255
3720-bit block 172.16.0.0 - 172.31.255.255
3816-bit block 192.168.0.0 - 192.168.255.255
39*/
This page took 0.284395 seconds and 4 git commands to generate.