Last active
July 3, 2023 09:14
-
-
Save ivabus/13daec679d87411901d6e09f4f9407eb to your computer and use it in GitHub Desktop.
nmap launcher on python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# --- | |
# dependencies: | |
# python.org: '>=3.11.3' | |
# nmap.org: '*' | |
# --- | |
import os | |
import sys | |
myArgs = list(sys.argv)[0:] | |
if len(myArgs) == 2: | |
threads = int(myArgs[1]) | |
file = 0 | |
if os.listdir('.').count('nmap') == 0: | |
os.system('mkdir nmap') | |
if threads <= 256 and 256 % threads == 0: | |
for i in range(0, 256, 256//threads): | |
os.system('python3 ' + myArgs[0] + ' ' + str(i) + ' ' + str(i + 256//threads) + ' &' ) | |
else: | |
sys.exit('Error: wrong number of threads') | |
os.sync() | |
else: | |
start = int(myArgs[1]) | |
end = int(myArgs[2]) | |
file = str(str(start) + '-' + str(end - 1) + '.nmap') | |
if start == end - 1: | |
file = str(str(start) + '.nmap') | |
for i in range(start, end): | |
os.system(str('nmap 192.168.' + str(i) + '.0/24 >> nmap/' + file)) | |
os.sync() |
I would recommend to do it it the separate terminal, also 128 and 256 threads require lots of resources.
It can freeze your network
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It will generate a directory with files named %.nmap in the case of 256 streams (192.168.%) and %-#.nmap in other cases (192.168.% - 192.168.#)