Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 30,310 times

Contents

Downloads

Related Categories

PHP Port Scanner - Using The Scanner Class

gringod

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.

I was born. I lived. I got bored.... I found computers. I live again!!!

Comments

  • Get errors running it on my local server

    Posted by adjamlotfi on 05 Jan 2004

    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...