def main():
echoC(__name__, "Starting a scan")
# Determine subnets
ipRangeList = getIPRange()
if ipRangeList == -1:
return -1
# Select a random subnet
rand = random.randint(0, len(ipRangeList)-1)
ipRange = ipRangeList[rand]
# Define arguments
scanOptions = ["-sF", "-sA", "-sU", "-sS", "-n -sP -PE"]
myArguments = random.choice(scanOptions) + " -T " + str(random.randint(1, 3))
echoC(__name__, "Scanning " + str(ipRange) + " with arguments: " + myArguments)
# Execute Scan
nm = nmap.PortScanner()
nm.scan(hosts=ipRangeList[rand], arguments=myArguments)
# Store the found IPs
# At first, delete old IPs
open(ipList, 'w').close()
for i in nm.all_hosts():
with open(ipList, 'a') as myfile:
myfile.write(str(i) + '\n')
echoC(__name__, "Done")
returnval = "0,nmap args: " + myArguments
return returnval
评论列表
文章目录