forked from xtr4nge/FruityWifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-FruityWiFi-PHP7.sh
executable file
·289 lines (230 loc) · 7.38 KB
/
install-FruityWiFi-PHP7.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
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
#!/bin/bash
# CONFIG
version="2.4.1"
# --------------------------------------------------------
# Setup PHP version -> options: PHP5 | PHP7
# The chosen version needs to be in the repository
# --------------------------------------------------------
fruitywifi_php_version="PHP7"
# --------------------------------------------------------
# Setup log path. default=/usr/share/fruitywifi/logs
# --------------------------------------------------------
fruitywifi_log_path="/usr/share/fruitywifi/logs"
# --------------------------------------------------------
# --------------------------------------------------------
# FruityWiFi set defaults [init.d]
# --------------------------------------------------------
fruitywifi_init_defaults="onboot"
# --------------------------------------------------------
find FruityWifi -type d -exec chmod 755 {} \;
find FruityWifi -type f -exec chmod 644 {} \;
root_path=`pwd`
mkdir tmp-install
cd tmp-install
apt-get update
echo "--------------------------------"
echo "Creates user fruitywifi"
echo "--------------------------------"
adduser --disabled-password --quiet --system --home /var/run/fruitywifi --no-create-home --gecos "FruityWiFi" --group fruitywifi
usermod -a -G inet fruitywifi
echo "[fruitywifi user has been created]"
echo
apt-get -y install gettext make intltool build-essential automake autoconf uuid uuid-dev dos2unix curl sudo unzip lsb-release python-scapy tcpdump python-netifaces python-pip
pip install netifaces
cmd=`gcc --version|grep "4.7"`
if [[ $cmd == "" ]]
then
echo "--------------------------------"
echo "Installing gcc 4.7"
echo "--------------------------------"
apt-get -y install gcc-4.7
apt-get -y install g++-4.7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
echo "[gcc setup completed]"
else
echo "--------------------------------"
echo "gcc 4.7 already installed"
echo "--------------------------------"
echo
fi
echo
if [ ! -f "/usr/sbin/dnsmasq" ]
then
echo "--------------------------------"
echo "Installing dnsmasq"
echo "--------------------------------"
# INSTALL DNSMASQ
apt-get -y install dnsmasq
echo "[dnsmasq setup completed]"
else
echo "--------------------------------"
echo "dnsmasq already installed"
echo "--------------------------------"
echo
fi
echo
if [ ! -f "/usr/sbin/hostapd" ]
then
echo "--------------------------------"
echo "Installing hostapd"
echo "--------------------------------"
# INSTALL HOSTAPD
apt-get -y install hostapd
echo "[hostapd setup completed]"
else
echo "--------------------------------"
echo "hostapd already installed"
echo "--------------------------------"
echo
fi
echo
if [ ! -f "/usr/sbin/airmon-ng" ] && [ ! -f "/usr/local/sbin/airmon-ng" ]
then
echo "--------------------------------"
echo "Installing aircrack-ng"
echo "--------------------------------"
# INSTALL AIRCRACK-NG
apt-get -y install libssl-dev wireless-tools iw
#VERSION="aircrack-ng-1.2-beta1" # [OLD_VERSION]
VERSION="aircrack-ng-1.2-rc4"
wget http://download.aircrack-ng.org/$VERSION.tar.gz
tar -zxvf $VERSION.tar.gz
cd $VERSION
make
make install
ln -s /usr/local/sbin/airmon-ng /usr/sbin/airmon-ng
ln -s /usr/local/sbin/airbase-ng /usr/sbin/airbase-ng
cd ../
echo "[aircrack-ng setup completed]"
else
echo "--------------------------------"
echo "aircrack-ng already installed"
echo "--------------------------------"
echo
fi
echo
# BACK TO ROOT-INSTALL FOLDER
cd $root_path
echo "--------------------------------"
echo "Installing Nginx"
echo "--------------------------------"
# NGINX INSTALL
apt-get -y install nginx
#apt-get -y install nginx php5-fpm
echo
# SSL
echo "--------------------------------"
echo "Create Nginx ssl certificate"
echo "--------------------------------"
cd $root_path
mkdir /etc/nginx/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
# REMOVE DEFAULT SITE
rm /etc/nginx/sites-enabled/default
# SETUP NGINX AND PHP5|PHP7
cp nginx-setup/nginx.conf /etc/nginx/
if [[ $fruitywifi_php_version == "PHP7" ]]
then
# INSTALL PHP7
apt-get -y install php7.0-fpm php7.0-curl php7.0-cli php7.0-xml
cp nginx-setup/FruityWiFi-PHP7 /etc/nginx/sites-enabled/
cp nginx-setup/fpm-PHP7/8000.conf /etc/php/7.0/fpm/pool.d/
cp nginx-setup/fpm-PHP7/8443.conf /etc/php/7.0/fpm/pool.d/
# RESTART NGINX + PHP7-FPM
/etc/init.d/nginx restart
/etc/init.d/php7.0-fpm restart
else
# INSTALL PHP5
apt-get -y install php5-fpm php5-curl php5-cli
cp nginx-setup/FruityWifi /etc/nginx/sites-enabled/
cp nginx-setup/fpm/8000.conf /etc/php5/fpm/pool.d/
cp nginx-setup/fpm/8443.conf /etc/php5/fpm/pool.d/
# RESTART NGINX + PHP5-FPM
/etc/init.d/nginx restart
/etc/init.d/php5-fpm restart
fi
echo "[nginx setup completed]"
echo
DIR="/usr/share/fruitywifi"
if [ -d "$DIR" ]; then
echo "--------------------------------"
echo "BACKUP CORE AND MODULES"
echo "--------------------------------"
cmd=`date +"%Y-%m-%d-%H-%M-%S"`
mv $DIR fruitywifi.BAK.$cmd
echo
fi
echo "--------------------------------"
echo "Setup FruityWiFi"
echo "--------------------------------"
cd $root_path
echo
echo "--------------------------------"
echo "Config log path"
echo "--------------------------------"
EXEC="s,^\$log_path=.*,\$log_path=\""$fruitywifi_log_path"\";,g"
sed -i "$EXEC" FruityWifi/www/config/config.php
EXEC="s,^log-facility=.*,log-facility="$fruitywifi_log_path"/dnsmasq.log,g"
sed -i "$EXEC" FruityWifi/conf/dnsmasq.conf
EXEC="s,^dhcp-leasefile=.*,dhcp-leasefile="$fruitywifi_log_path"/dhcp.leases,g"
sed -i "$EXEC" FruityWifi/conf/dnsmasq.conf
EXEC="s,^Defaults:fruitywifi logfile =.*,Defaults:fruitywifi logfile = "$fruitywifi_log_path"/sudo.log,g"
sed -i "$EXEC" sudo-setup/fruitywifi
echo "[logs setup completed]"
echo
echo "--------------------------------"
echo "Setup Sudo"
echo "--------------------------------"
cd $root_path
cp -a sudo-setup/fruitywifi /etc/sudoers.d/
chown root:root /etc/sudoers.d/fruitywifi
echo "[sudo setup completed]"
echo
cmd=`lsb_release -c |grep -iEe "jessie|kali|sana"`
if [[ ! -z $cmd ]]
then
echo "--------------------------------"
echo "Setup DNSMASQ"
echo "--------------------------------"
EXEC="s,^server=,#server=,g"
sed -i $EXEC FruityWifi/conf/dnsmasq.conf
echo "[dnsmasq setup completed]"
echo
fi
cp -a FruityWifi /usr/share/fruitywifi
#mkdir $fruitywifi_log_path
ln -s $fruitywifi_log_path /usr/share/fruitywifi/www/logs
echo
# START/STOP SERVICES
if [[ $fruitywifi_init_defaults == "onboot" ]]
then
echo "--------------------------------"
echo "START SERVICES"
echo "--------------------------------"
update-rc.d ssh defaults
update-rc.d nginx defaults
update-rc.d ntp defaults
/etc/init.d/nginx restart
if [[ $fruitywifi_php_version == "PHP7" ]]
then
update-rc.d php7.0-fpm defaults
/etc/init.d/php7.0-fpm restart
else
update-rc.d php5-fpm defaults
/etc/init.d/php5-fpm restart
fi
fi
apt-get -y remove ifplugd
echo
echo "---------------------------"
echo "WEB-INTERFACE"
echo "---------------------------"
echo "http://localhost:8000 [http]"
echo "https://localhost:8443 [https]"
echo "user: admin"
echo "pass: admin"
echo
echo "GitHub: https://github.com/xtr4nge/FruityWifi"
echo "Twitter: @xtr4nge, @FruityWifi"
echo "ENJOY!"
echo ""