-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfuzzing_proxy.sh
57 lines (49 loc) · 1.79 KB
/
fuzzing_proxy.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
#!/bin/bash
# this script starts a fuzzing proxy
display_help()
{
echo "Usage: $0 [options]" >&2
echo
echo "-s, --seed the seed to initialize the random fuzzing"
echo "-r, --ratio the ratio of flipped bits (default: 0.035 => 3.5%)"
echo "-d, --destination the destination the proxy should forward to (address:port)"
echo "-b, --byte_offset the bytes offset"
echo "-l, --listen the port on which the proxy listens for incoming PDUs"
exit 1
}
# set default values
SEED=$(date +%s)
RATIO=0.035
LISTEN_PORT=1884
DST_HOST=127.0.0.1:1883
# avoid fuzzing the packet type! TODO: where is the beginning? TCP PDU or TCP payload?
BYTES_OFFSET=1
# adapt values according to CLI arguments
while [ "$1" != "" ]; do
case $1 in
-s | --seed ) shift
SEED=$1
;;
-r | --ratio ) shift
RATIO=$1
;;
-d | --destination ) shift
DST_HOST=$1
;;
-b | --byte_offset ) shift
BYTES_OFFSET=$1
;;
-l | --listen ) shift
LISTEN_PORT=$1
;;
-h | --help ) display_help
exit
;;
* ) display_help
exit 1
esac
shift
done
echo "Starting Fuzzing-Proxy: 0.0.0.0:$LISTEN_PORT <-> $DST_HOST"
echo "Fuzzing parameters: Seed = $SEED, Ratio = $RATIO"
zzuf -s$SEED -n -p$LISTEN_PORT -b$BYTES_OFFSET- -A -r$RATIO socat TCP-LISTEN:$LISTEN_PORT,reuseaddr,fork TCP4:$DST_HOST