forked from hani1990/bt-waf-crack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
134 lines (109 loc) · 3.25 KB
/
install.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
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
pluginPath=/www/server/panel/plugin/btwaf
dataPath=/www/server/panel/data
install_tmp='/tmp/bt_install.pl'
download_Url='http://download.bt.cn'
Install_btwaf()
{
Install_cjson
mkdir -p $pluginPath
echo '正在安装脚本文件...' > $install_tmp
cp ./plugin/btwaf/* $pluginPath/
cp ./conf/btwaf.conf /www/server/panel/vhost/nginx/
btwaf_path=/www/server/btwaf
mkdir -p $btwaf_path/html
python -m compileall $pluginPath/btwaf_init.py
if [ ! -f $btwaf_path/html/get.html ];then
cp ./server/btwaf/html/* $btwaf_path/html/
fi
mkdir -p $btwaf_path/rule
if [ ! -f $btwaf_path/rule/url.json ];then
cp ./server/btwaf/rule/* $btwaf_path/rule/
fi
if [ ! -f $btwaf_path/site.json ];then
cp ./server/btwaf/site.json $btwaf_path/site.json
fi
if [ ! -f $btwaf_path/config.json ];then
cp ./server/btwaf/config.json $btwaf_path/config.json
fi
if [ ! -f $btwaf_path/total.json ];then
cp ./server/btwaf/total.json $btwaf_path/total.json
fi
if [ ! -f $btwaf_path/drop_ip.log ];then
\cp -a -r ./server/btwaf/drop_ip.log $btwaf_path/drop_ip.log
fi
\cp -a -r ./server/btwaf/init.lua $btwaf_path/init.lua
\cp -a -r ./server/btwaf/waf.lua $btwaf_path/waf.lua
chmod +x $btwaf_path/waf.lua
chmod +x $btwaf_path/init.lua
mkdir -p /www/wwwlogs/btwaf
chmod 777 /www/wwwlogs/btwaf
chmod -R 755 /www/server/btwaf
chmod -R 666 /www/server/btwaf/rule
chmod -R 666 /www/server/btwaf/total.json
chmod -R 666 /www/server/btwaf/drop_ip.log
echo '' > /www/server/nginx/conf/luawaf.conf
python $pluginPath/btwaf_main.py
#if [ -f $pluginPath/btwaf_init.pyc ];then
# rm -f $pluginPath/btwaf_init.py
#fi
cp ./data/* $dataPath/
/etc/init.d/nginx reload
echo '安装完成' > $install_tmp
}
Install_cjson()
{
if [ -f /usr/bin/yum ];then
isInstall=`rpm -qa |grep lua-devel`
if [ "$isInstall" == "" ];then
yum install lua lua-devel -y
fi
else
isInstall=`dpkg -l|grep liblua5.1-0-dev`
if [ "$isInstall" == "" ];then
apt-get install lua5.1 lua5.1-dev -y
fi
fi
if [ ! -f /usr/local/lib/lua/5.1/cjson.so ];then
wget -O lua-cjson-2.1.0.tar.gz $download_Url/install/src/lua-cjson-2.1.0.tar.gz -T 20
tar xvf lua-cjson-2.1.0.tar.gz
rm -f lua-cjson-2.1.0.tar.gz
cd lua-cjson-2.1.0
make clean
make
make install
cd ..
rm -rf lua-cjson-2.1.0
ln -sf /usr/local/lib/lua/5.1/cjson.so /usr/lib64/lua/5.1/cjson.so
ln -sf /usr/local/lib/lua/5.1/cjson.so /usr/lib/lua/5.1/cjson.so
else
if [ -d "/usr/lib64/lua/5.1" ];then
ln -sf /usr/local/lib/lua/5.1/cjson.so /usr/lib64/lua/5.1/cjson.so
fi
if [ -d "/usr/lib/lua/5.1" ];then
ln -sf /usr/local/lib/lua/5.1/cjson.so /usr/lib/lua/5.1/cjson.so
fi
fi
}
Uninstall_btwaf()
{
rm -rf /www/server/panel/static/btwaf
if [ ! -d /www/server/panel/plugin/btwaf_httpd ];then
rm -rf /www/server/btwaf
fi
rm -f /www/server/panel/vhost/nginx/btwaf.conf
rm -rf $pluginPath
cat > /www/server/nginx/conf/luawaf.conf<<EOF
lua_shared_dict limit 10m;
lua_package_path "/www/server/nginx/waf/?.lua";
init_by_lua_file /www/server/nginx/waf/init.lua;
access_by_lua_file /www/server/nginx/waf/waf.lua;
EOF
}
if [ "${1}" == 'install' ];then
Install_btwaf
elif [ "${1}" == 'uninstall' ];then
Uninstall_btwaf
fi