-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_sidechannel_evaluation.sh
executable file
·237 lines (178 loc) · 7.55 KB
/
run_sidechannel_evaluation.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
## run_sidechannel_evaluation.sh
# CAUTION
# Run this script within its folder. Otherwise the paths might be wrong!
#####################################
# chmod +x run_sidechannel_evaluation.sh
# ./run_sidechannel_evaluation.sh
#
trap "exit" INT
#####################
number_of_runs=30
time_bound=1800 #30min
step_size_eval=30
declare -a subjects=(
"blazer_login_unsafe"
"blazer_login_safe"
"themis_jetty_unsafe"
"themis_jetty_safe"
"stac_ibasys_unsafe"
"rsa_modpow_1717"
"rsa_modpow_834443"
"rsa_modpow_1964903306"
)
declare -a classpaths=(
"./bin-instr/" # "blazer_login_unsafe"
"./bin-instr/" # "blazer_login_safe"
"./bin-instr/" # "themis_jetty_unsafe"
"./bin-instr/" # "themis_jetty_safe"
"./bin-instr/" # "stac_ibasys_unsafe"
"./bin-instr/" # "rsa_modpow_1717"
"./bin-instr/" # "rsa_modpow_834443"
"./bin-instr/" # "rsa_modpow_1964903306"
)
declare -a drivers=(
"Login_fuzz" # blazer_login_unsafe"
"Login_fuzz" # blazer_login_safe"
"FuzzDriver" # "themis_jetty_unsafe"
"FuzzDriver" # "themis_jetty_safe"
"FuzzDriver" # "stac_ibasys_unsafe"
"FuzzDriver" # "rsa_modpow_1717"
"FuzzDriver" # "rsa_modpow_834443"
"FuzzDriver" # "rsa_modpow_1964903306"
)
# Check array sizes
if [[ ${#subjects[@]} != ${#classpaths[@]} ]]
then
echo "[Error in script] the array sizes of subjects and classpaths do not match!. Abort!"
exit 1
fi
if [[ ${#subjects[@]} != ${#drivers[@]} ]]
then
echo "[Error in script] the array sizes of subjects and drivers do not match!. Abort!"
exit 1
fi
run_counter=0
total_number_subjects=${#subjects[@]}
total_number_experiments=$(( $total_number_subjects * $(($number_of_runs * 3)))) #3 because of fuzzing+symexe+hybrid
if [ "$(uname)" == "Darwin" ]; then
echo "set DYLD_LIBRARY_PATH to ../../../../tool/symbolicexecution/jpf-symbc-differential/lib"
export DYLD_LIBRARY_PATH=../../../../tool/symbolicexecution/jpf-symbc-differential/lib
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
echo "set LD_LIBRARY_PATH to ../../../../tool/symbolicexecution/jpf-symbc-differential/lib"
export LD_LIBRARY_PATH=../../../../tool/symbolicexecution/jpf-symbc-differential/lib
else
echo "OS not supported!"
exit 1
fi
echo
echo "Run complete evaluation..."
cd ../subjects
# Run just fuzzing
for (( i=0; i<=$(( $total_number_subjects - 1 )); i++ ))
do
cd ./${subjects[i]}/fuzzing/
for j in `seq 1 $number_of_runs`
do
run_counter=$(( $run_counter + 1 ))
echo "[$run_counter/$total_number_experiments] Run fuzzing analysis for ${subjects[i]}, round $j .."
mkdir ../fuzzer-out-$j/
# Start Kelinci server
nohup java -cp ${classpaths[i]} edu.cmu.sv.kelinci.Kelinci ${drivers[i]} @@ > ../fuzzer-out-$j/server-log.txt &
server_pid=$!
sleep 5 # Wait a little bit to ensure that server is started
# Start modified AFL
AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 nohup ../../../../tool/fuzzing/afl-differential/afl-fuzz -i in_dir -o ../fuzzer-out-$j -c regression -S afl -t 999999999 ../../../../tool/fuzzing/kelinci-differential/fuzzerside/interface @@ > ../fuzzer-out-$j/afl-log.txt &
afl_pid=$!
# Wait for timebound
sleep $time_bound
# Stop AFL and Kelinci server
kill $afl_pid
kill $server_pid
# Wait a little bit to make sure that processes are killed
sleep 10
done
cd ../../
# Evaluate run
python3 ../scripts/evaluate_cost_fuzz.py ${subjects[i]}/fuzzer-out- $number_of_runs $time_bound $step_size_eval
done
# Run just symexe
for (( i=0; i<=$(( $total_number_subjects - 1 )); i++ ))
do
cd ./${subjects[i]}/
for j in `seq 1 $number_of_runs`
do
run_counter=$(( $run_counter + 1 ))
echo "[$run_counter/$total_number_experiments] Run symexe analysis for ${subjects[i]}, round $j .."
mkdir ./symexe-out-$j/
cd ./symexe/
# Start SPF
nohup java -Xmx6144m -cp "../../../../tool/symbolicexecution/badger-differential/build/*:../../../../tool/symbolicexecution/badger-differential/lib/*:../../../../tool/symbolicexecution/jpf-symbc-differential/build/*:../../../../tool/symbolicexecution/jpf-symbc-differential/lib/*:../../../../tool/symbolicexecution/jpf-core/build/*" edu.cmu.sv.badger.app.BadgerRunner config_symexe $j > ../symexe-out-$j/spf-log.txt &
spf_pid=$!
# Wait for timebound
sleep $time_bound
# Stop SPF
kill $spf_pid
# Assess.
cd ../fuzzing
# Start Kelinci server
nohup java -cp ${classpaths[i]} edu.cmu.sv.kelinci.Kelinci ${drivers[i]} @@ > ../symexe-out-$j/server-log.txt &
server_pid=$!
sleep 5 # Wait a little bit to ensure that server is started
# Start modified AFL
AFL_IMPORT_FIRST=1 AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 ../../../../tool/fuzzing/afl-differential/afl-fuzz-import -i in_dir -o ../symexe-out-$j -c regression -S afl -t 999999999 ../../../../tool/fuzzing/kelinci-differential/fuzzerside/interface @@ > ../symexe-out-$j/afl-log.txt
kill $server_pid
# Wait a little bit to make sure that processes are killed
sleep 10
cd ../
done
cd ../
# Evaluate run
python3 ../scripts/evaluate_cost_symexe.py ${subjects[i]}/symexe-out- $number_of_runs $time_bound $step_size_eval
done
# Run just hybrid analysis
for (( i=0; i<=$(( $total_number_subjects - 1 )); i++ ))
do
cd ./${subjects[i]}/
for j in `seq 1 $number_of_runs`
do
run_counter=$(( $run_counter + 1 ))
echo "[$run_counter/$total_number_experiments] Run hybrid analysis for ${subjects[i]}, round $j .."
mkdir ./hydiff-out-$j/
cd ./fuzzing/
# Start Kelinci server
nohup java -cp ${classpaths[i]} edu.cmu.sv.kelinci.Kelinci ${drivers[i]} @@ > ../hydiff-out-$j/server-log.txt &
server_pid=$!
sleep 5 # Wait a little bit to ensure that server is started
# Start modified AFL
AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 nohup ../../../../tool/fuzzing/afl-differential/afl-fuzz -i in_dir -o ../hydiff-out-$j -c regression -S afl -t 999999999 ../../../../tool/fuzzing/kelinci-differential/fuzzerside/interface @@ > ../hydiff-out-$j/afl-log.txt &
afl_pid=$!
cd ../symexe/
# Start SPF
nohup java -Xmx6144m -cp "../../../../tool/symbolicexecution/badger-differential/build/*:../../../../tool/symbolicexecution/badger-differential/lib/*:../../../../tool/symbolicexecution/jpf-symbc-differential/build/*:../../../../tool/symbolicexecution/jpf-symbc-differential/lib/*:../../../../tool/symbolicexecution/jpf-core/build/*" edu.cmu.sv.badger.app.BadgerRunner config_hybrid $j > ../hydiff-out-$j/spf-log.txt &
spf_pid=$!
# Wait for timebound
sleep $time_bound
# Stop SPF, AFL and Kelinci server
kill $spf_pid
kill $afl_pid
kill $server_pid
# Wait a little bit to make sure that processes are killed
sleep 10
####
# Assess only spf run to determine later the times for the first delta > 0.
cd ../fuzzing
# Start Kelinci server
nohup java -cp ${classpaths[i]} edu.cmu.sv.kelinci.Kelinci ${drivers[i]} @@ > ../hydiff-out-$j/server-spf-log.txt &
server_pid=$!
sleep 5 # Wait a little bit to ensure that server is started
# Start modified AFL
AFL_IMPORT_FIRST=1 AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 ../../../../tool/fuzzing/afl-differential/afl-fuzz-import-spf -i in_dir -o ../hydiff-out-$j -c regression -S spf-replay -t 999999999 ../../../../tool/fuzzing/kelinci-differential/fuzzerside/interface @@ > ../hydiff-out-$j/spf-replay-log.txt
kill $server_pid
# Wait a little bit to make sure that processes are killed
sleep 10
cd ../
done
cd ../
# Evaluate run
python3 ../scripts/evaluate_cost_hydiff.py ${subjects[i]}/hydiff-out- $number_of_runs $time_bound $step_size_eval
done