Port Scanner

The introduction of fsockopen() earlier in this chapter was accompanied by a demonstration of how to create a port scanner. However, like many of the tasks introduced in this section, this can be accomplished much more easily using one of PHP's program execution functions. The following example uses PHP's system() function and the Nmap (network mapper) tool:

$target = "www.example.com"; echo "<pre>";

system("/usr/bin/nmap $target"); echo "</pre>";

// Kill the task system("killall -q nmap");

A snippet of the sample output follows:

Starting nmap V. 2.54BETA31 ( www.insecure.org/nmap/ ) Interesting ports on (209.51.142.155):

(The 1500 ports scanned but not shown below are in state: closed)

Port

22/tcp

80/tcp

110/tcp

111/tcp

State open open open filtered

Service ssh http pop-3 sunrpc

Was this article helpful?

+1 0

Post a comment