-
Notifications
You must be signed in to change notification settings - Fork 12
/
MultiMac.py
86 lines (71 loc) · 2.06 KB
/
MultiMac.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
import random, threading, os, subprocess, itertools, sys
MAC_LIST = []
THREAD_POOL = []
TOTAL_PORTS = []
SWITCHES = []
def randomMAC():
global MAC_LIST
if len(MAC_LIST) > 0:
curr = MAC_LIST.pop()
MAC_LIST = [curr] + MAC_LIST
return curr
mac = [0x11, 0x11,
random.randint(0x00, 0x29),
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff)]
return ':'.join(map(lambda x: "%02x" % x, mac))
def nmapScan(ranMAC):
global TOTAL_PORTS
OPEN_PORTS = []
out = subprocess.check_output(["nmap -p- " + " ".join(SWITCHES) + " --open --spoof-mac=" + ranMAC + " " + sys.argv[1]], shell=True)
for row in out.split('\n'):
if 'open' in row:
port = row.split('/')
port = str(port[0])
OPEN_PORTS.append(port)
ThreadName = threading.currentThread().getName()
# Separated for multihost logic later
if ThreadName == 'Thread0':
Thread0ports = OPEN_PORTS
TOTAL_PORTS.append(Thread0ports)
return
elif ThreadName == 'Thread1':
Thread1ports = OPEN_PORTS
TOTAL_PORTS.append(Thread1ports)
return
elif ThreadName == 'Thread2':
Thread2ports = OPEN_PORTS
TOTAL_PORTS.append(Thread2ports)
return
def main():
global THREAD_POOL, TOTAL_PORTS, SWITCHES
# Options
NoPing = raw_input("Pingless scan? (Y/N)")
if NoPing == "Y" or "y":
SWITCHES.append("-Pn")
# Start Threads
print "\n[+] Spinning up threads"
for x in range(0,3):
ranMAC = randomMAC()
t = threading.Thread(name='Thread' + str(x), target=nmapScan, args=(ranMAC,))
THREAD_POOL.append(t)
t.start()
# Kill Threads
for x in range(0,3):
killme = THREAD_POOL.pop()
killme.join()
print "[+] Threads killed\n"
# Total list
countin = list(itertools.chain.from_iterable(TOTAL_PORTS))
# Unique ports throughout the total
unique = sorted(set(countin))
print "[*] Host: " + sys.argv[1]
# Logic for open ports
for x in range(0, len(unique)):
if countin.count(str(unique[x])) == 3:
print "\tPort " + str(unique[x]) + " appears open"
if __name__ == '__main__':
main()
print "\n"
sys.exit(-1)