11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 16 • NETWORKINGwww.it-ebooks.info}echo fgets($http, 1024);?>// Close the connectionfclose($http);This returns the following output (formatted as you would see it in the browser):HTTP/1.1 200 OK Server: Apache/2.2.3 (CentOS) Last-Modified: Tue, 15 Nov 2005 13:24:10 GMTETag: "24ec5-1b6-4059a80bfd280" Accept-Ranges: bytes Content-Type: text/html; charset=UTF-8 Connection: close Date: Mon, 17 May 2010 20:54:02 GMT Age: 1976 Content-Length: 438You have reached this web page by typing "example.com", "example.<strong>net</strong>", or "example.org"into your web browser.These domain names are reserved for use in documentation and are not available forregistration. See RFC 2606, Section 3.The second example, shown in Listing 16-1, demonstrates how to use fsockopen() to build arudimentary port scanner.Listing 16-1. Creating a Port Scanner with fsockopen()// Give the script enough time to complete the taskini_set("max_execution_time", 120);// Define scan range$rangeStart = 0;$rangeStop = 1024;// Which server to scan?$target = "localhost";// Build an array of port values$range =range($rangeStart, $rangeStop);echo "Scan results for $target";// Execute the scanforeach ($range as $port) {$result = @fsockopen($target, $port,$errno,$errstr,1);if ($result) echo "Socket open at port $port";}Scanning my local machine using this script produces the following output :338

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!