Question: #import the nmap libraries import nmap # initialize the port scanner nmScan = nmap.PortScanner() # scan localhost for ports in range 21-443 #nmScan.scan('127.0.0.1', '21-443') nmScan.scan('192.168.1.0/24',
#import the nmap libraries import nmap
# initialize the port scanner nmScan = nmap.PortScanner()
# scan localhost for ports in range 21-443 #nmScan.scan('127.0.0.1', '21-443') nmScan.scan('192.168.1.0/24', '21-80')
# run a loop to print all the found result about the ports for host in nmScan.all_hosts(): print('Host : %s (%s)' % (host, nmScan[host].hostname())) print('State : %s' % nmScan[host].state()) for proto in nmScan[host].all_protocols(): print('----------') print('Protocol : %s' % proto) lport = nmScan[host][proto].keys() #lport.sort() sorted(lport) for port in lport: print ('port : %s\tstate : %s' % (port, nmScan[host][proto][port]['state']))
How to modify this program to scan your entire subnet (i.e. 192.168.1.xxx) for the same ports
2. Python Progamming
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
