-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.py
98 lines (78 loc) · 3.68 KB
/
commands.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
92
93
94
95
96
97
98
import re
from MAC import MAC
import trackIP
import scanner
def help():
print("\n++++++++++++++++++++ Change MAC and MODE ++++++++++++++++++++")
print("--interface -i : Set the interface name")
print("--getMAC -gmac : GET MAC address")
print("--changeMAC -cmac : CHANGE MAC address")
print("--getMODE -gmode : GET Interface MODE")
print("--changeMODE -cmode : CHANGE Interface MODE")
print("\n++++++++++++++++++++++ Track IP Address ++++++++++++++++++++++")
print("--trackIP -tip : Track the given public IP\n")
print("\n++++++++++++++++++++++++ Scan Network ++++++++++++++++++++++++")
print("--scanNET -snet : Scan the network using scapy module\n")
print("exit : EXIT\n")
def rectify_command(command):
mc = MAC()
commandList = re.split("\s", command)
if commandList[0] != "macmon":
print("Invalid command!")
return -1
if commandList[1] == 'exit':
return 'exit'
commandDic = { '-i': None,
'--interface': None,
'-gmac': None,
'--getMAC': None,
'-cmac': None,
'--changeMAC': None,
'-gmode': None,
'--getMODE': None,
'-cmode': None,
'--changeMODE': None,
'--trackIP': None,
'-tip': None,
'--scanNET': None,
'-snet': None
}
if '-h' in commandList or '--help' in commandList:
help()
return -1
for i in range(1, len(commandList)):
if '-i' == commandList[i] or '--interface' == commandList[i]:
commandDic['-i'] = commandList[i+1]
commandDic['--interface'] = commandList[i+1]
if '-cmac' == commandList[i] or '--changeMAC' == commandList[i]:
commandDic['-cmac'] = commandList[i+1]
commandDic['--changeMAC'] = commandList[i+1]
if '-cmode' == commandList[i] or '--changeMODE' == commandList[i]:
commandDic['-cmode'] = commandList[i+1]
commandDic['--changeMODE'] = commandList[i+1]
if '-tip' == commandList[i] or '--trackIP' == commandList[i]:
commandDic['-tip'] = commandList[i+1]
commandDic['--trackIP'] = commandList[i+1]
if '-snet' == commandList[i] or '--scanNET' == commandList[i]:
commandDic['-snet'] = commandList[i+1]
commandDic['--scanNet'] = commandList[i+1]
if '-gmac' in commandList or '--getMAC' in commandList:
macAddr = mc.get_MAC(commandDic['-i'])
if macAddr is not None:
print("[+] Current MAC Address is " + macAddr)
if '-cmac' in commandList or '--changeMAC' in commandList:
if '-cmac' is not None and '--changeMAC' is not None:
newMAC = mc.change_MAC(commandDic['-i'], commandDic['-cmac'])
if '-gmode' in commandList or '--getMODE' in commandList:
mode = mc.get_mode(commandDic['-i'])
if mode is not None:
print("[+] Current Mode is " + mode)
if '-cmode' in commandList or '--changeMODE' in commandList:
if '-cmode' is not None and '--changeMODE' is not None:
newMODE = mc.change_mode(commandDic['-i'], commandDic['-cmode'])
if '-tip' in commandList or '--trackIP' in commandList:
if '-tip' is not None and '--trackIP' is not None:
trackIP.IPtrack(commandDic['-tip'])
if '-snet' in commandList or '--scanNET' in commandList:
if '-snet' is not None and '--scanNET' is not None:
scanner.arp_scan(commandDic['-i'], commandDic['-snet'])