-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_ols_modsec.sh
executable file
·69 lines (62 loc) · 1.53 KB
/
config_ols_modsec.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
#!/bin/bash
# /********************************************************************
# HTTP2 Benchmark Modify Server for ModSecurity config OpenLitespeed modsec
# *********************************************************************/
silent() {
if [[ $debug ]] ; then
"$@"
else
"$@" >/dev/null 2>&1
fi
}
### Tools
echoY() {
echo -e "\033[38;5;148m${1}\033[39m"
}
echoG() {
echo -e "\033[38;5;71m${1}\033[39m"
}
echoR()
{
echo -e "\033[38;5;203m${1}\033[39m"
}
fail_exit(){
echoR "${1}"
}
fail_exit_fatal(){
echoR "${1}"
if [ $# -gt 1 ] ; then
popd "+${2}"
fi
exit 1
}
if [ $# -lt 3 ] ; then
if [ $# -eq 0 ]; then
./modsec.sh "openlitespeed"
exit $?
fi
fail_exit_fatal "Needs to be run by modsec.sh"
fi
TEMP_DIR="${1}"
OWASP_DIR="${2}"
OLSDIR="${3}"
if [ $# -eq 4 ] ; then
COMODO=1
else
COMODO=0
fi
config_olsModSec(){
silent grep 'module mod_security {' $OLSDIR/conf/httpd_config.conf
if [ $? -eq 0 ] ; then
echoG "OpenLitespeed already configured for modsecurity"
return 0
fi
cp -f $OLSDIR/conf/httpd_config.conf $OLSDIR/conf/httpd_config.conf.nomodsec
if [ $COMODO -eq 1 ] ; then
RULES_FILE='rules.conf.main'
else
RULES_FILE='modsec_includes.conf'
fi
sed -i "s=module cache=module mod_security {\nmodsecurity on\nmodsecurity_rules \`\nSecRuleEngine On\n\`\nmodsecurity_rules_file $OWASP_DIR/$RULES_FILE\n ls_enabled 1\n}\n\nmodule cache=" $OLSDIR/conf/httpd_config.conf
}
config_olsModSec