So I know this is an odd piece of code. I am simply trying to make nmap run faster. I need to find all active ips and what ports are open on the 10.0.0.0/8 network. My company has very poor documentation and never kept track of all this. I have a lot of cores to work with on my machine, but nmap doesn't make use of them. I also have a 10 gig NIC. I should be able to make this go blazing fast if I did it right, but I am not sure how to go about it. My code below is one of many attempts to multithread calls to nmap, but it seems os.system() puts a pause on everything else. Obviously that won't help make my scans run faster.
Eventually I need to use -Pn since some of the hosts have ICMP disabled, but might have open ports. Since my boss won't accept waiting 11 years for this I am kind of stuck. Any help, advice, or scolding for doing it completely wrong would be much appreciated. Thank you in advanced.
import os
import sys
from threading import Thread
def nmaping(x):
command = "nmap 10." + str(x) + ".0.0/16 --open -oG nmap10-" + str(x) + ".txt"
print(command)
try:
threads = []
for x in range(0, 255):
t = Thread(target = nmaping, args=(x,))
t.start()
except KeyboardInterrupt:
print("Quit")
sys.exit()