Prev | Current Page 488 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

048/0.078/0.158/0.041 ms
PHP??™s program execution functions are great because they allow you to take
advantage of any program installed on the server that has the appropriate permissions
assigned.
Creating a Port Scanner
The introduction of fsockopen() earlier in this chapter is 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:
420 CHAPTER 16 ?–  NE TWORKING
$target = "www.example.com";
echo "
";
system("/usr/bin/nmap $target");
echo "
";
// Kill the task
system("killall -q nmap");
?>
A snippet of the sample output follows:
Starting nmap V. 4.11 ( www.insecure.org/nmap/ )
Interesting ports on (209.51.142.155):
(The 1500 ports scanned but not shown below are in state: closed)
Port State Service
22/tcp open ssh
80/tcp open http
110/tcp open pop-3
111/tcp filtered sunrpc
Creating a Subnet Converter
You??™ve probably at one time scratched your head trying to figure out some obscure
network configuration issue. Most commonly, the culprit for such woes seems to
center on a faulty or an unplugged network cable. Perhaps the second most common
problem is a mistake made when calculating the necessary basic network ingredients:
IP addressing, subnet mask, broadcast address, network address, and the like.


Pages:
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500