hi, Im looking for a way to determine what kind of server a host is. Ive writen a script to scan ip ranges an find live hosts but i need a way to find out if the host is a web server, mail server, dns etc. how can i do this? im new at this and im realy stuck ... plz help even a way to determine just one type of host (e.g. web server) would be highly apreciated thank you
Katanius what the information you are requesting I think this is the best lik you will get help from here -> http://in2.php.net/reserved.variables. Any other help you need fell free to ask
One host can be both a web server, mail server, and dns server, etc. Different services use different port numbers. Are you talking about port scanner?
Thank you very much Subikar following the link i found the getservbyname() and getservbyport() functions, is it posible to use them to identify the server type? ill try it allthough i dont know exactly how this can be done. i guess it would be more something like a portsweeper, Basicly im using nslookup to see if an ip coresponds to a host. What im trying to do is make a script that outputs a txt file that contains something like this: <<IP:62.169.194.16 Host: www.something.gr is a WEB_SERVER>> <<IP:62.169.194.17 Host: dns1.something.gr is a DNS>> e.t.c. Ive reached to the <<IP:62.169.194.16 Host: www.something.gr>> part my self but now im not realy shure how to go on. I can post the script if you need more details. thank you very much for answering
use dig, that way you can look for a specific records type, for instance mx records for smtp/pop/imap servers and ns records for domain name servers and a records for website / webserver, dig is a unix command, however I have seen classes on phpclasses that "claim" to achieve the same results, I never tested them though, just noted it was interesting that it could be done.
Im running php on a windows platform so i cant use them, i also tryed the PEAR Net_DNS class but couldnt get it to work so i think i ll go with port scanning. Using the information i found i wrote the followin script which im going to later use in a loop: <?php $host='dns1.tellas.gr'; $port=80; echo "$host.<br>"; $service = getservbyport($port, "tcp"); $result = @fsockopen($host, $port); stream_set_timeout($result, 1); fclose($result); echo "getservbyport result:.<br>"; echo "Port: $port is commonly used for: $service"; if($result) { echo " OPEN"; } else { echo " CLOSED"; } ?> Code (markup): the server used is obviusly a dns, getservbyport returns http as a service allthough the port is closed. what does this mean? have i done something wrong? Or should i disregard the getservbyport function and just identify type of server by port being open or closed?
I eventualy used fsockopen to listen to ports 80, 20, 110, 53 but it takes aproximatly 30sec to scan each port that isnt open. This is like 2min per IP, if i would scan 500 ips it would take like half a day! Isnt port scanning supposed to be fast?