-
Notifications
You must be signed in to change notification settings - Fork 128
/
Proxychains-Nmap.py
executable file
·91 lines (82 loc) · 2.79 KB
/
Proxychains-Nmap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import multiprocessing
from argparse import RawTextHelpFormatter
import Queue
import threading
import os
import sys
import subprocess
import argparse
from random import randint
def cli_parser():
parser = argparse.ArgumentParser(add_help=False, description='''This script Simply routes your nmap scan in a "sort-of" fast way
through a ProcyChain that has been setup.
\n\t(1) You will find out that when routing nmap through a Proxychain connection that Timing performace is out the window.
\n\t(2) This is do to the nature of a SOCKS proxy and SYN->SYN/ACK connection is already established in NMAPS Eyes.
\n\t(3) It out puts random (#) of .gnmap file for each IP for parsing. (MAKE A FOLDER) :)
''', formatter_class=RawTextHelpFormatter)
parser.add_argument("-i", metavar="iplist.txt", help="Set Ip List of IPs Delimited by line")
parser.add_argument('-h', '-?', '--h', '-help', '--help', action="store_true", help=argparse.SUPPRESS)
args = parser.parse_args()
if args.h:
parser.print_help()
sys.exit()
if not args.i:
print "[!] I need a list IP's!"
sys.exit()
return args.i
def Execution(Task_queue):
while True:
Ip = Task_queue.get()
# If the queue is emepty exit this proc
# Setup a simple output in the folder, For gnmap Parser
IpName = str(Ip).replace('.',"-") + str(".gnmap")
if Ip is None:
break
try:
print "[*] On Ip: " + Ip
test = subprocess.check_output(["proxychains", "nmap", "-Pn", "-n", "-sT", "--max-scan-delay", "0", "-p111,445,139,21-23,80,443", "-oG", IpName, "--open", Ip])
test = ""
except:
pass
def TaskSelector(Task_queue, verbose=False):
total_proc = int(8)
for i in xrange(total_proc):
Task_queue.put(None)
procs = []
for thread in range(total_proc):
procs.append(multiprocessing.Process(target=Execution, args=(Task_queue,)))
for p in procs:
p.daemon = True
p.start()
for p in procs:
p.join()
Task_queue.close()
def Ip_List(Task_queue, cli_IpList):
items = []
cli_IpList = str(cli_IpList)
try:
with open(cli_IpList, "r") as myfile:
lines = myfile.readlines()
for line in lines:
line = line.rstrip('\n')
items.append(line)
for item in items:
Task_queue.put(item)
return Task_queue
except Exception as e:
print "[!] Please check your Ip List: " + str(e)
sys.exit(0)
def main():
cli_IpList = cli_parser()
Task_queue = multiprocessing.Queue()
Task_queue = Ip_List(Task_queue, cli_IpList)
TaskSelector(Task_queue)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print 'Interrupted'
try:
sys.exit(0)
except SystemExit:
os._exit(0)