WIth php5-snmp installed, tried snmpwalk through php:
1 2 3 4 5 6 7 | <?php $a = snmpwalk("127.0.0.1", "public", ""); foreach ($a as $val) { echo "$val\n"; } ?> |
WIth php5-snmp installed, tried snmpwalk through php:
1 2 3 4 5 6 7 | <?php $a = snmpwalk("127.0.0.1", "public", ""); foreach ($a as $val) { echo "$val\n"; } ?> |
1 2 | $first_ip=$_SERVER['REMOTE_ADDR']; $hostname=gethostbyaddr($first_ip); |
For example
1 2 3 4 5 | <?php $first_ip="192.168.1.17"; $hostname=gethostbyaddr($first_ip); echo $hostname; ?> |
which in my current LAN will gives the output:
gungz-3c2d7c341.local
Port scanner class. An example of usage is as follow where my IP is 192.168.1.10. The upper range for scanning isn’t alive: 192.168.1.11. I hide warnings due to open socket failure which will happen because the IP isn’t alive.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php ini_set( "display_errors", 0); require_once("scanner.class.php"); $ip_address1 = "192.168.1.10"; $ip_address2 = "192.168.1.11"; $my_scanner = new PortScanner($ip_address1, $ip_address2); $my_scanner->set_ports("80"); $results = $my_scanner->do_scan(); foreach($results as $ip=>$ip_results) { echo gethostbyaddr($ip)."\n<blockquote>\n"; foreach($ip_results as $port=>$port_results) { echo "\t".$port." : ".$port_results['pname']." : "; if ($port_results['status']==1){echo "open";} else {echo "closed";}echo "<br />\n"; } echo "</blockquote>\n\n"; } ?> |
Results are as follow (it includes developerfusion.com port scan by default (?)):
developerfusion.com
15 : netstat : closed
16 : N/A : closed
17 : qotd : closed
18 : msp : closed
19 : chargen : closed
20 : ftp-data : closed
21 : ftp : closed
22 : ssh : closed
23 : telnet : closed
24 : N/A : closed
25 : smtp : open
80 : www : open
110 : pop3 : closed
3306 : mysql : closed
1337 : N/A : closed
666 : N/A : closed
xp-racy.local
80 : www : open
192.168.1.11
80 : www : closed