forked from assist-project/dtls-fuzzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·113 lines (101 loc) · 3.55 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
#!/usr/bin/env bash
#
# Installs some necessary packages and then installs DTLS-Fuzzer.
# SCRIPT_DIR should correspond to DTLS-Fuzzer's root directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
readonly SCRIPT_DIR
readonly PATCHES_DIR="$SCRIPT_DIR/experiments/patches"
readonly PROTOCOLSTATEFUZZER_COMMIT="398c9bc"
readonly PROTOCOLSTATEFUZZER_REP_URL="https://github.com/protocol-fuzzing/protocol-state-fuzzer.git"
readonly PROTOCOLSTATEFUZZER_FOLDER="ProtocolState-Fuzzer"
readonly TLSATTACKER_VERSION="v5.3.0"
readonly TLSATTACKER_REP_URL="https://github.com/tls-attacker/TLS-Attacker.git"
readonly TLSATTACKER_FOLDER="TLS-Attacker"
readonly TLSATTACKER_PATCH="$PATCHES_DIR/TLS-Attacker-$TLSATTACKER_VERSION.patch"
function check_java() {
if ! command -v java &> /dev/null
then
echo "JDK is not installed ('java' command not in PATH)"
if command -v apt-get &> /dev/null
then
echo "Installing java using apt-get"
sudo apt-get install openjdk-17-jdk
else
echo "Install JDK >= 17, add it to PATH and re-run"
exit
fi
else
java_vm=$(java -version 2>&1 >/dev/null | grep -o "Server VM\|Client VM")
if [[ ! $java_vm == "Server VM" ]]
then
echo "Required Java Server VM (a JDK instead of JRE), found $java_vm"
echo "Install JDK >= 17, add it to PATH and re-run"
exit
fi
fi
}
function check_mvn() {
if ! command -v mvn &> /dev/null
then
echo "maven is not installed ('mvn' command not in PATH)"
if command -v apt-get &> /dev/null
then
echo "Installing maven using apt-get"
sudo apt-get install maven
else
echo "Install Apache maven, add it to PATH and re-run"
exit
fi
fi
}
function clone_rep() {
sut_dir=$1
rep_url=$2
rep_com=$3
echo "Cloning repository $rep_url commit $rep_com to $sut_dir"
echo git clone "$rep_url" "$sut_dir"
git clone "$rep_url" "$sut_dir"
if [[ -n "$rep_com" ]]; then
( cd "$sut_dir" || exit ; git checkout "$rep_com" )
fi
}
function install_protocolstatefuzzer() {
echo $PROTOCOLSTATEFUZZER_FOLDER
if [[ -d $PROTOCOLSTATEFUZZER_FOLDER ]]; then
echo "$PROTOCOLSTATEFUZZER_FOLDER folder already exists"
echo "Skipping ProtocolState-Fuzzer setup"
else
clone_rep $PROTOCOLSTATEFUZZER_FOLDER $PROTOCOLSTATEFUZZER_REP_URL $PROTOCOLSTATEFUZZER_COMMIT
(
cd $PROTOCOLSTATEFUZZER_FOLDER || exit
echo "Installing ProtocolState-Fuzzer"
mvn install -DskipTests
)
fi
}
function install_tlsattacker() {
echo $TLSATTACKER_FOLDER
if [[ -d $TLSATTACKER_FOLDER ]]; then
echo "$TLSATTACKER_FOLDER folder already exists"
echo "Skipping TLS-Attacker setup"
else
clone_rep "$TLSATTACKER_FOLDER" "$TLSATTACKER_REP_URL" "$TLSATTACKER_VERSION"
(
cd $TLSATTACKER_FOLDER || exit
echo "Patching TLS-Attacker to remove deplicate discard and fragment reordering."
git apply "$TLSATTACKER_PATCH"
echo "Installing TLS-Attacker"
mvn install -DskipTests
)
fi
}
# Check for the presence of Java and maven and if 'apt-get' is present, install them
check_java
check_mvn
# Checkout and install ProtocolState-Fuzzer
install_protocolstatefuzzer
# Checkout TLS-Attacker repo, patch it and install it
install_tlsattacker
# Install DTLS-Fuzzer
echo "Installing DTLS-Fuzzer..."
mvn clean install