summaryrefslogtreecommitdiff
path: root/run-ws
blob: 5e09541047b540f45b385a6b88509a46c7f6822c (plain)
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
#!/bin/bash

if [ $# -lt 2 ]; then
	echo "Usage: $0 /path/to/wireshark capture.pcapng [ssl debug file] [--] [other wireshark options]"
	exit 1
fi

DEBUGGER=()
case $1 in
gdb|*/gdb)
	while :; do
		arg=$1; shift
		DEBUGGER+=("$arg")
		[[ $arg != --args ]] || break
	done
	;;
valgrind|*/valgrind)
	while :; do
		arg=$1; shift
		DEBUGGER+=("$arg")
		[[ $arg != -- ]] || break
	done
	;;
esac

SSLKEYLOGFILE=${SSLKEYLOGFILE:-$PWD/premaster.txt}
WIRESHARK=$1
CAPTFILE=$2
SSLDEBUG=
shift 2

# set SSL debug file only if ssl debug file is given
case $1 in
-*|'') ;;
*) SSLDEBUG=$1 ; shift ;;
esac

# -- marks end of our options and the begin of wireshark options
case $1 in
--) shift ;;
esac

if [ ! -x "$WIRESHARK" ]; then
	echo "$WIRESHARK: not an executable"
	exit 1
fi

if [ ! -s "$CAPTFILE" ]; then
	echo "$CAPTFILE: file is empty or does not exist"
	exit 1
fi

[ -z "$SSLDEBUG" ] || set -- -o ssl.debug_file:"$SSLDEBUG" "$@"

# Set AddressSanitizer options if not already
if [ -z "$ASAN_OPTIONS" ]; then
	# Abort so it can be caught by gdb
	ASAN_OPTIONS=abort_on_error=1
	# Strip source path (assume /tmp/wireshark/)
	ASAN_OPTIONS+=strip_path_prefix=/tmp/wireshark/
	export ASAN_OPTIONS
fi

# For ASAN, disable slice allocator and use g_malloc directly.
if [ -z "$G_SLICE" ]; then
	export G_SLICE=always-malloc
fi

"${DEBUGGER[@]}" \
"$WIRESHARK" -r "$CAPTFILE" \
	-o http.ssl.port:443,4430-4433 \
	-o ssl.keylog_file:"$SSLKEYLOGFILE" \
	-o dtls.keylog_file:"$SSLKEYLOGFILE" \
	"$@"