Library code snippets
PHP Port Scanner
By gringod, published on 05 Sep 2003
Page 1 of 3
- Using The Scanner Class
- Displaying the results
- Conclusion
Using The Scanner Class
In order to use the scanner class you will firstly need to instantiate a scanner object:
$my_scanner = new PortScanner($ip_address1, $ip_address2);When creating the scanner object, you are required to pass 2 ip-addresses to it in the Internet Protocol dotted for (www.xxx.yyy.zzz). This set the range of ip-address which will be scanned. If you only require one ip-address to be scanned then you should pass the same ip-address twice.
Secondly, you need to set the ports which tou wish to scan. This can be done by (1) sending a single number to the function:
$my_scanner->set_ports("21");
or (2) it can be done by passing a range of ports:
$my_scanner->set_ports("1-25");
or lastly (3) it can be done with a comma-seperated combination of the above two:
$my_scanner->set_ports("1-10,21,80,1024-1030");
Thirdy you need to set the timeout to wait for a port response, slower network will require a greater timeout delay:
$my_scanner->set_wait(2);
Fourthly, and last of the parameters to be set, is the scan delay. This causes the scanner to pause between each port it scans. The function takes two arguments, both of which are optional, the first being a delay in seconds, the second being a delay in micro-seconds. If no arugments are sent, the default delay is 0 micro-seconds:
$my_scanner->set_delay(0, 5000);
Now that all the parameters are set, the last thing to do is run the scan. This is done with the statement:
$results = $my_scanner->do_scan();
This returns a structured array the format of which is:
[ip_address] -> [port_number] -> [port_name] |-> [port_status]
for each ip-address is the given range.
Related articles
Related discussion
-
Ventrilo Server Status Php. Snmp Server Enable Traps
by MarkHewitt (0 replies)
-
Aion Server Status Php, Server Racks Cabinets
by MarkHewitt (0 replies)
-
Moparscape Server Status Php - Global Catalog Server Could Not Be Located
by MarkHewitt (0 replies)
-
accutane online without prescription, isotretinoin online, accutane cost, accutane acne treatment
by torgo (0 replies)
-
We are seeking a highly skilled iPhone Develope
by Kim abunado (0 replies)
Related podcasts
-
EarthClassMail.com - Moving from LAMP to .NET 3.5
Scott chats with Matt Davis, architect at EarthClassMail.com, about their move from a LAMP stack (Linux/Apache/mysql/PHP) to .NET 3.5. What's working, what's not, and what kinds of issues are they running into as their architect their solution.
Events coming up
-
Apr
17
WebTech Conference 2010 - Bulgaria
Veliko Turnovo, Bulgaria
6th edition of WebTech conference will be held. A 2 day conference about : - Web Technologies - Blogs and blogging - Web 3.0 - Open Web - Mobile technologies - Internet Business
HI
I unzipped the script and run it, but I got errors.
and it's not so fast as indicated ???!!!
Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allowcalltimepassreference to true in your INI file. However, future versions may not support this any longer. in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allowcalltimepassreference to true in your INI file. However, future versions may not support this any longer. in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:15 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:16 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:17 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:18 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:19 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:20 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:22 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:23 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:24 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:110 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:3306 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:1337 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
Warning: fsockopen(): unable to connect to 216.26.163.133:666 in c:\easyphp\www\wwwvbwebcoukshow30883fportscanner\scanner.class.php on line 103
www.vbweb.co.uk
15 : netstat : closed
16 : N/A : closed
17 : qotd : closed
18 : N/A : closed
19 : chargen : closed
20 : ftp-data : closed
21 : ftp : open
22 : N/A : closed
23 : telnet : closed
24 : N/A : closed
25 : smtp : open
80 : N/A : open
110 : pop3 : closed
3306 : N/A : closed
1337 : N/A : closed
666 : N/A : closed
where to correct ( which .INI file ??)
I would prefer to let my setting as they are and correct in the script itself.
Is there anyway to pass an external parameter to such script ??? (call it from another PHP one)
Good idea, full interest
Happy new year
This thread is for discussions of PHP Port Scanner.