def getComputers(search=getDeviceNetwork()[2], args='-sS -p 22 -n -T5'):
"""Given string search and string args: Return list of hosts on network
'args' being nmap arguments to be passed to nmap for optimized searching on networks
'search' defaults to current network subnet
'args' defaults to '-sS -p 22 -n -T5'
To break down these NMAP arguments:
-sS : TCP SYN scan. A fast unobtrusive stealthy scan that shouldn't raise any flags while remaining quick
-p 22: Only scan port 22. This should speed things up while remaining fairly reliable
-n : No DNS resolution. Since we don't need the host names, we can go ahead and skip that
-T5 : Insane timing template. This is the most unreliable, but also the quickest. If you have issues with
assets being found, I'd suggest to start change with this option.
"""
nm = nmap.PortScanner()
scanInfo = nm.scan(hosts=search, arguments=args) # Remove -n to get DNS NetBIOS results
IPs = nm.all_hosts() # Gives me an host of hosts
return IPs, scanInfo
评论列表
文章目录