-
Notifications
You must be signed in to change notification settings - Fork 0
/
bpineap
461 lines (419 loc) · 15.7 KB
/
bpineap
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
#!/bin/bash
# Function for Help
display_help() {
echo "Usage: ${0} <option> <value>"
echo -e "\nNOTICE: These changes made are not permanent in case of a error"
echo " a reboot will reset these changes. If you want to make them permanent"
echo " then use 'uci commit' this will commit ALL changes made!"
echo
echo -e "\nOptions:"
echo " karma [on or off]"
echo " beacon_interval [LOW, NORMAL or AGGRESSIVE]"
echo " beacon_response_interval [LOW, NORMAL or AGGRESSIVE]"
echo " beacon_responses [on or off]"
echo " broadcast_ssid_pool [on or off]"
echo " broadcast_ssid_pool_random [on or off]"
echo " mac_filter [black or white]"
echo " ssid_filter [black or white]"
echo " target_mac <MAC_ADDRESS>"
echo " handshakes_path <PATH>"
echo " ssid_db_path <PATH>"
echo " filters_db_path <PATH>"
echo " connect_notifications [on or off]"
echo " disconnect_notifications [on or off]"
echo " auto_ssid_filter [on or off]"
echo " auto_mac_filter [on or off]"
echo " pineape_passthrough [on or off]"
echo " hostapd_db_path <PATH>"
echo " recon_db_path <PATH>"
echo " pineap_mac <MAC_ADDRESS>"
echo " evil_ap_handshakes [on or off]"
echo " capture_ssids [on or off]"
echo " logging [on or off]"
echo " autostart [on or off]"
echo " pineap_interface [wlan1mon or wlan3mon]"
echo " run_scan [duration sec (0 = Continuous)] [Band: 0,1,2 (2.4GHz,5GHz,Both)] [capture handshakes: 0,1 (off,on)]"
echo " show_scan (Show current running scan, if any)"
echo " stop_scan (Stop current running scan, if any)"
echo " show_config (Show curent uci config)"
echo " clear_logs (Clears activity log [log.db])"
echo " start_handshake_capture [bssid] [channel]"
echo " stop_handshake_capture (Stop current handshake capture, if any)"
echo " deauth [AP MAC] [Client MAC] [Channel] [Count]"
}
# Function to restart pineapd
restart_pineapd() {
/etc/init.d/pineapd restart
echo "Pineapd restarted waiting a few seconds.."
sleep 5
}
# Function to prompt user to stop scan
prompt_stop_scan() {
read -e -p "A scan is already running. Would you like to stop it and continue? (Y/N): " choice
case "$choice" in
[yY])
pineap stop_scan
pineap handshake_capture_stop
echo "The running scan has been stopped."
;;
[nN])
echo "Use ${0} show_scan to check the status."
echo "Current scan not stopped. Exiting..."
exit 1
;;
*)
echo "Invalid choice. Exiting..."
exit 1
;;
esac
}
case $1 in
help)
display_help
;;
karma)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].karma="$2"
echo "Karma updated successfully."
restart_pineapd
else
echo "Invalid value for Karma. Use 'on' or 'off'."
fi
;;
beacon_interval)
if [ -n "$2" ]; then
uci set pineap.@config[0].beacon_interval="$2"
echo "Beacon Interval updated successfully."
restart_pineapd
else
echo "Invalid value for Beacon Interval. Please provide a valid value."
fi
;;
beacon_response_interval)
if [ -n "$2" ]; then
uci set pineap.@config[0].beacon_response_interval="$2"
echo "Beacon Response Interval updated successfully."
restart_pineapd
else
echo "Invalid value for Beacon Response Interval. Please provide a valid value."
fi
;;
beacon_responses)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].beacon_responses="$2"
echo "Beacon Responses updated successfully."
restart_pineapd
else
echo "Invalid value for Beacon Responses. Use 'on' or 'off'."
fi
;;
broadcast_ssid_pool)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].broadcast_ssid_pool="$2"
echo "Broadcast SSID Pool updated successfully."
restart_pineapd
else
echo "Invalid value for Broadcast SSID Pool. Use 'on' or 'off'."
fi
;;
broadcast_ssid_pool_random)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].broadcast_ssid_pool_random="$2"
echo "Broadcast SSID Pool Random updated successfully."
restart_pineapd
else
echo "Invalid value for Broadcast SSID Pool Random. Use 'on' or 'off'."
fi
;;
mac_filter)
if [ "$2" == "black" ] || [ "$2" == "white" ]; then
uci set pineap.@config[0].mac_filter="$2"
echo "MAC Filter updated successfully."
restart_pineapd
else
echo "Invalid value for MAC Filter. Use 'black' or 'white'."
fi
;;
ssid_filter)
if [ "$2" == "black" ] || [ "$2" == "white" ]; then
uci set pineap.@config[0].ssid_filter="$2"
echo "SSID Filter updated successfully."
restart_pineapd
else
echo "Invalid value for SSID Filter. Use 'black' or 'white'."
fi
;;
target_mac)
if [ -n "$2" ]; then
uci set pineap.@config[0].target_mac="$2"
echo "Target MAC updated successfully."
restart_pineapd
else
echo "Invalid value for Target MAC. Please provide a valid MAC address."
fi
;;
handshakes_path)
if [ -n "$2" ]; then
uci set pineap.@config[0].handshakes_path="$2"
echo "Handshakes Path updated successfully."
restart_pineapd
else
echo "Invalid value for Handshakes Path. Please provide a valid path."
fi
;;
ssid_db_path)
if [ -n "$2" ]; then
uci set pineap.@config[0].ssid_db_path="$2"
echo "SSID DB Path updated successfully."
restart_pineapd
else
echo "Invalid value for SSID DB Path. Please provide a valid path."
fi
;;
filters_db_path)
if [ -n "$2" ]; then
uci set pineap.@config[0].filters_db_path="$2"
echo "Filters DB Path updated successfully."
restart_pineapd
else
echo "Invalid value for Filters DB Path. Please provide a valid path."
fi
;;
connect_notifications)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].connect_notifications="$2"
echo "Connect Notifications updated successfully."
restart_pineapd
else
echo "Invalid value for Connect Notifications. Use 'on' or 'off'."
fi
;;
disconnect_notifications)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].disconnect_notifications="$2"
echo "Disconnect Notifications updated successfully."
restart_pineapd
else
echo "Invalid value for Disconnect Notifications. Use 'on' or 'off'."
fi
;;
auto_ssid_filter)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].auto_ssid_filter="$2"
echo "Auto SSID Filter updated successfully."
restart_pineapd
else
echo "Invalid value for Auto SSID Filter. Use 'on' or 'off'."
fi
;;
auto_mac_filter)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].auto_mac_filter="$2"
echo "Auto MAC Filter updated successfully."
restart_pineapd
else
echo "Invalid value for Auto MAC Filter. Use 'on' or 'off'."
fi
;;
pineape_passthrough)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].pineape_passthrough="$2"
echo "PineAPe Passthrough updated successfully."
restart_pineapd
else
echo "Invalid value for PineAPe Passthrough. Use 'on' or 'off'."
fi
;;
hostapd_db_path)
if [ -n "$2" ]; then
uci set pineap.@config[0].hostapd_db_path="$2"
echo "HostAPD DB Path updated successfully."
restart_pineapd
else
echo "Invalid value for HostAPD DB Path. Please provide a valid path."
fi
;;
recon_db_path)
if [ -n "$2" ]; then
uci set pineap.@config[0].recon_db_path="$2"
echo "Recon DB Path updated successfully."
restart_pineapd
else
echo "Invalid value for Recon DB Path. Please provide a valid path."
fi
;;
pineap_mac)
if [ -n "$2" ]; then
uci set pineap.@config[0].pineap_mac="$2"
echo "PineAP MAC updated successfully."
restart_pineapd
else
echo "Invalid value for PineAP MAC. Please provide a valid MAC address."
fi
;;
evil_ap_handshakes)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].evil_ap_handshakes="$2"
echo "Evil AP Handshakes updated successfully."
restart_pineapd
else
echo "Invalid value for Evil AP Handshakes. Use 'on' or 'off'."
fi
;;
capture_ssids)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].capture_ssids="$2"
echo "Capture SSIDs updated successfully."
restart_pineapd
else
echo "Invalid value for Capture SSIDs. Use 'on' or 'off'."
fi
;;
logging)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].logging="$2"
echo "Logging updated successfully."
restart_pineapd
else
echo "Invalid value for Logging. Use 'on' or 'off'."
fi
;;
autostart)
if [ "$2" == "on" ] || [ "$2" == "off" ]; then
uci set pineap.@config[0].autostart="$2"
echo "Autostart updated successfully."
restart_pineapd
else
echo "Invalid value for Autostart. Use 'on' or 'off'."
fi
;;
pineap_interface)
if [ -n "$2" ]; then
uci set pineap.@config[0].pineap_interface="$2"
echo "PineAP Interface updated successfully."
restart_pineapd
else
echo "Invalid value for PineAP Interface. Please provide a valid interface."
fi
;;
show_config)
echo "Current PineAP Config:"
echo
uci show pineap
;;
run_scan)
if [ $# -eq 4 ]; then
# Check if a scan is already running
scan_status=$(pineap get_status)
if [[ $scan_status =~ "\"bssid\":" && $scan_status =~ "\"captureRunning\": true" && $scan_status =~ "\"scanRunning\": false" ]]; then
prompt_stop_scan
elif [[ $scan_status =~ "\"scanRunning\": true" ]]; then
prompt_stop_scan
else
duration="$2"
band_choice="$3"
autocapture_choice="$4"
case $band_choice in
0|1|2)
# Valid band choice
;;
*)
echo "Invalid frequency band choice. Use 0 for 2.4GHz, 1 for 5GHz, or 2 for Both."
exit 1
;;
esac
case $autocapture_choice in
0|1)
# Valid autocapture choice
;;
*)
echo "Invalid autocapture choice. Use 0 for off or 1 for on."
exit 1
;;
esac
# Check if band_choice is 1 (5GHz) or 2 (Both) and interface is not wlan1 or wlan1mon
interface=$(uci show pineap | grep "pineap.@config\[0\].pineap_interface" | cut -d "'" -f 2)
if [ "$band_choice" -eq 1 ] || [ "$band_choice" -eq 2 ]; then
if [ "$interface" != "wlan1" ] && [ "$interface" != "wlan1mon" ]; then
# Execute the scan command with the provided arguments
pineap run_scan "$duration" "$band_choice" "$autocapture_choice"
echo "Scan started successfully."
else
echo "Cannot run scan on 5GHz or Both band when interface is wlan1 or wlan1mon."
fi
else
# Execute the scan command with the provided arguments
pineap run_scan "$duration" "$band_choice" "$autocapture_choice"
echo "Scan started successfully."
fi
fi
else
echo "Invalid number of arguments. Usage: ${0} scan <duration> <frequency_band> <autocapture>"
fi
;;
show_scan)
echo "Showing current scan status:"
echo
pineap get_status
echo
;;
stop_scan)
pineap stop_scan
echo "Stopped current scan"
;;
clear_logs)
pineap clear_logs
echo "Logs Cleared."
;;
start_handshake_capture)
if [ -n "$2" ] && [ -n "$3" ]; then
if pineap get_status | grep -q "\"bssid\":"; then
echo "Handshake capture is already running. Cannot start again."
else
echo "Starting handshake capture for BSSID: $2 and channel: $3"
echo
pineap handshake_capture_start $2 $3
fi
else
echo "Invalid arguments. Please provide both BSSID and channel."
fi
;;
stop_handshake_capture)
pineap handshake_capture_stop
echo "Stopped Handshake Capture"
;;
deauth)
IFACE=$(uci get pineap.@config[0].pineap_interface)
if [ -n "$2" ] && [ -n "$3" ] && [ -n "$4" ] && [ -n "$5" ]; then
if [[ ("$IFACE" = "wlan1" || "$IFACE" = "wlan1mon") && ( "$4" -ge 1 && "$4" -le 14) ]]; then
echo "Starting deauth with the following options:"
echo
echo "AP MAC: $2"
echo "Client MAC: $3"
echo "Channel: $4"
echo "Packet count: $5"
echo
pineap deauth $3 $2 $4 $5
elif [[ ("$IFACE" = "wlan3" || "$IFACE" = "wlan3mon") ]]; then
echo "Starting deauth with the following options:"
echo
echo "AP MAC: $2"
echo "Client MAC: $3"
echo "Channel: $4"
echo "Packet count: $5"
echo
pineap deauth $3 $2 $4 $5
else
echo "Invalid channel for 2.4GHz interface."
echo "Please enter a channel between 1 and 14 for $IFACE"
fi
else
echo "Invalid arguments. Please provide AP MAC address, Client MAC, channel, and packet count."
fi
;;
*)
# Display help menu if no arguments provided
echo "Usage: ${0} <option> <value>"
echo "Use ${0} help to see the available options and usage."
;;
esac