-
Notifications
You must be signed in to change notification settings - Fork 5
/
local.sh
executable file
·57 lines (44 loc) · 1.82 KB
/
local.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
#!/usr/bin/env bash
NGINX=$(which nginx)
if [[ !$NGINX ]]; then
for n in "/usr/local/nginx/sbin/nginx" "/opt/nginx/sbin/nginx" "/usr/local/sbin/nginx" "/usr/sbin/nginx"; do
if [[ -x $n ]]; then
NGINX=$n
break
fi
done
fi
if [[ $NGINX == "" ]]; then
>&2 echo "nginx could not be found"
exit 1
fi
SCRIPT="$0"
if [[ $(readlink $SCRIPT) != "" ]]; then
SCRIPT=$(dirname $SCRIPT)/$(readlink $SCRIPT)
fi
if [[ $0 = ${0%/*} ]]; then
SCRIPT=$(pwd)/$0
fi
BADTLS_DIR=$(cd ${SCRIPT%/*}/.. && pwd -P)
MACHINE_TYPE=$(uname -sm | sed -e 's/ /-/' | tr '[:upper:]' '[:lower:]')
SOCAT="$BADTLS_DIR/bin/socat-$MACHINE_TYPE"
$NGINX -p "$BADTLS_DIR/nginx" -c "$BADTLS_DIR/nginx/conf/nginx.conf" &
NGINX_PID=$!
sleep 1.5
$SOCAT tcp:localhost:9990 openssl-listen:10003,reuseaddr,fork,cipher=EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:DES-CBC3-SHA,cert=./certs/auth.crt,key=./certs/host.key,dhparam=./certs/dhparam.pem,cafile=./certs/ca.crt,verify=1 &
SOCAT_CLIENT_AUTH_PID=$!
$SOCAT tcp:localhost:9992 openssl-listen:11004,reuseaddr,fork,cipher=EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:DES-CBC3-SHA,cert=./certs/weak-sig.crt,key=./certs/host.key,dhparam=./certs/dhparam.pem,verify=0 &
SOCAT_MD5_PID=$!
$SOCAT tcp:localhost:9992 openssl-listen:11008,reuseaddr,fork,cipher=RC4,cert=./certs/wildcard.crt,key=./certs/host.key,dhparam=./certs/dhparam.pem,verify=0 &
SOCAT_RC4_PID=$!
$SOCAT tcp:localhost:9992 openssl-listen:11009,reuseaddr,fork,cipher=RC4-MD5,cert=./certs/wildcard.crt,key=./certs/host.key,dhparam=./certs/dhparam.pem,verify=0 &
SOCAT_RC4_MD5_PID=$!
wait
cleanup() {
kill $NGINX_PID 2> /dev/null
kill $SOCAT_CLIENT_AUTH_PID 2> /dev/null
kill $SOCAT_MD5_PID 2> /dev/null
kill $SOCAT_RC4_PID 2> /dev/null
kill $SOCAT_RC4_MD5_PID 2> /dev/null
}
trap 'cleanup' 1 2 3 15 EXIT