Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

PHP Port Scanner


ghost's Avatar
0 0

I wrote a port scanner in php. Its a very unstealthy and simple piece of code - it just does the old connect() scan, so it is easily logged.

However, the reason I wrote it is because it could come in quite handy. With a http proxy, you are only concealed behind port 80, the http port. But, host this on a free account and access it from behind a proxy, and the server will do the scanning. You will be concealed.

Well, that's the theory.

<?php
error_reporting(0);
$address = "127.0.0.1"; //Change this to data sent from a HTML form
$startport = 1; //Change this to data sent from a HTML form
$endport = 500; //Change this to data sent from a HTML form
if ($startport > $endport){exit("Starting port must be greater than or equal to finishing port!\n");}
if ($socket < 0){exit("Couldn't create socket");}
for ($port = $startport; $port <= $endport; $port++)
{
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$connect = socket_connect($socket, $address, $port);
if ($connect > 0){echo "Port ".$port." is open\n";}
socket_close($socket);
}
?>```

ghost's Avatar
0 0

nice,