./c0de/php/pscan.txt

0.
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.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
<?
 
##############################################
#       php proxy scanner- by Jackh4xor
#       j4ckh4xor [at ]gmail [.com]
##############################################
##############################################
## ##
## USAGE ##
## ##
## //TEST IP AND DEFINED PORT ##
## PSCAN.PHP?IP=<IP>&PORT=<PORT> ##
## ##
## ##
## //SCAN IP (ports 80 - 65200) ##
## PSCAN.PHP?IP=<IP>&SCAN=TRUE ##
## ##
## ##
##############################################
## ##
## TESED ON WINDOWS PHP5 & APACHE 2 ##
## UNTESTED ON NIX BUT SHOULD WORK ##
## ##
##############################################
## ##
 
 
set_time_limit(0);
 
$_port = $_GET['PORT'];
$_ip = $_GET['IP'];
$_scan = $_GET['SCAN'];
$Query = $_GET['q'];
 
 
function Port_Check($host, $port)
{
if (isset($host) && isset($port)) {
$i=(int)$port;
$fp = @fsockopen("tcp://".$host,$i,$errno,$errstr,10);
 
if($fp) { $res = TRUE; } else { $res = FALSE; }
 
} else {
$res = FALSE;
}
return $res;
}
 
function getmicrotime() ## USED IN PING
{
list ($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
 
 
function Sockcheck($host,$port,$type)
{
$Response = '..GOODCON..';
 
$ch = curl_init();
 
 
curl_setopt($ch, CURLOPT_URL, "http://".$_SERVER['SERVER_NAME']."".$_SERVER['PHP_SELF']."?q=true");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT,'[DB]');
 
curl_setopt($ch, CURLOPT_PROXY, $host.":".$port);
if($type == "4") curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
else if($type == "5") curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
 
$mk_time = getmicrotime();
 
$SOCKGOOD = FALSE;
$html = curl_exec($ch);
if(stristr( trim($html) , $Response )) {
$SOCKGOOD = TRUE;
} else {
$SOCKGOOD = FALSE;
}
 
 
if ($SOCKGOOD == TRUE) {
$Proxy_Ping = trim(Round(((getmicrotime()-$mk_time) * 1000),0));
$res = "(".$port.") <font color=green>Open</font> : SOCK ".$type." Proxy Found <font color=";
 
if ($Proxy_Ping < 500) { $res .= 'green'; }
elseif ($Proxy_Ping < 1000) { $res .= 'orange'; }
else { $res .= 'red'; }
 
$res .= sprintf("> %s </font>ms<br>", $Proxy_Ping);
} else { $res = "(".$port.") <font color=green>Open</font> : No SOCK ".$type." Proxy Found<br>"; }
 
curl_close ($ch);
unset($ch);
return $res;
}
 
 
function HTTPProxy_Test($IP, $Port)
{
$Response = '..GOODCON..';
 
$fp = fsockopen($IP, (int)$Port, $errno, $errstr, 10);
if (!$fp) {
$res = "$errstr ($errno)<br />\n";
} else {
$mk_time = getmicrotime();
 
$out = "GET http://".$_SERVER['SERVER_NAME']."".$_SERVER['PHP_SELF']."?q=true HTTP/1.0\r\n";
$out .= "User-Agent: [DB]\r\n";
$out .= "Connection: Close\r\n";
$out .= "Pragma: no-cache\r\n";
$out .= "Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7\r\n";
$out .= "Cache-Control: no\r\n";
$out .= "Accept-Language: en;q=0.7,en-us;q=0.3\r\n";
$out .= "\r\n";
 
fwrite($fp, $out);
 
$HTTPGOOD = FALSE;
while (!feof($fp)) {
$fptmp = fgets($fp, 128);
 
if( stristr( trim($fptmp) , $Response ) ) { $HTTPGOOD = TRUE; BREAK; }
 
}
 
if ($HTTPGOOD == TRUE) {
$Proxy_Ping = trim(Round(((getmicrotime()-$mk_time) * 1000),0));
$res = "(".$Port.") <font color=green>Open</font> : HTTP Proxy Found <font color=";
 
if ($Proxy_Ping < 500) { $res .= 'green'; }
elseif ($Proxy_Ping < 1000) { $res .= 'orange'; }
else { $res .= 'red'; }
 
$res .= sprintf("> %s </font>ms<br>", $Proxy_Ping);
} else { $res = "(".$Port.") <font color=green>Open</font> : No HTTP Proxy Found<br>"; }
 
 
fclose($fp);
}
return $res;
}
 
 
function scanPorts($host, $pfrom, $pto, $delay)
{
$res;
for ($i = $pfrom-1; $i <= $pto; $i++) {
 
$res[$i]['RES'] = 0;
 
if (Port_Check($host, $i)) {
$re[$i]['RES'] = 1;
$res[$i]['HTTP'] = HTTPProxy_Test($host, $i);
$res[$i]['SOCK4'] = Sockcheck($host, $i,4);
$res[$i]['SOCK5'] = Sockcheck($host, $i,5);
} else {
$res[$i]['RES'] = 0;
$res[$i]['C'] = '('.$i.') <font color=red>Closed</font> : Unable to test... <br>';
}
 
sleep($delay);
}
return $res;
}
 
 
if (isset($_ip)) {
if (isset($_scan)) {
$mk_time = getmicrotime();
$pt = scanPorts($_ip,80,65200,2);
 
echo "Scanning ".$_ip." .....<br>";
 
foreach($pt as $tport => $tres)
{
if ($tres['RES'] == 1) {
 
echo "-- ".$tres['HTTP'];
echo "-- ".$tres['SOCK4'];
echo "-- ".$tres['SOCK5'];
 
} //else { echo "- ".$tres['C']; } //uncomment to show closed ports as well
}
 
$Proxy_Ping = trim(Round(((getmicrotime()-$mk_time)),0));
echo "<br>Scanned in ".$Proxy_Ping."Secs<br>";
 
}
if (isset($_port)) {
if (Port_Check($_ip,$_port) == TRUE) {
echo "Scanning ".$_ip." .....<br>";
echo HTTPProxy_Test($_ip, $_port);
echo Sockcheck($_ip, $_port,4);
echo Sockcheck($_ip, $_port,5);
}
}
}
 
if (isset($Query)) {
$Response = '..GOODCON..';
echo $Response;
}
 
 
?>

Back