I'm pretty new to nmap & python so I was wondering if I could get some help with this.
I'm working on mac with Ventura OS
PATH is :
/Library/Frameworks/Python.framework/Versions/3.12/bin:/Users/AaronBrinkley/.nvm/versions/node/v18.13.0/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Users/AaronBrinkley/.nvm/versions/node/v18.13.0/bin:/opt/local/bin:/opt/local/sbin
Code pasted below
====
import nmap
#These variables will be used as ranges for the nmap tool to scan throug
port_min = 0
port_max = 65535
#Uses context manager to open file containing IP addresses
with open('devices_file') as f:
devices_list = f.read().splitlines()
#User types in range of ports to be scanned
port_range = input("Please enter port range in 'x-x' format ")
nm = nmap.PortScanner()
for device in devices_list:
print("Now Checking " + device)
for port in range(port_min, port_max + 1):
try:
result = nm.scan(device, str(port))
port_status = (result['scan'][device]['tcp'][port]['state'])
print(f"Port {port} is {port_status}")
except:
print("Port {port} is not scannable")