-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_tests.sh
executable file
·92 lines (84 loc) · 2.45 KB
/
run_tests.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
#!/bin/bash
random_name() {
cat /dev/urandom | tr -c -d 'a-zA-Z0-9' | head -c 10
}
plt_hijack_shell() {
echo "---------------------------------------------------------------------------------------"
echo "[*] Testing .plt.got hijack with \"$1\" and a parasite that spawns a shell"
testtarget="$(random_name)"
cp -v "$1" "$testtarget"
"$INFECTOR" -p shell.o "$testtarget"
fname=`random_name`
echo "touch $fname" | "./$testtarget"
stat "$fname"
if [[ "$?" -ne "0" ]]
then
echo "[!] Test failed"
exit 1
fi
rm -v "$fname"
rm -v "./$testtarget"
echo "[+] Test passed!"
}
dtors_hijack_shell() {
echo "---------------------------------------------------------------------------------------"
echo "[*] Testing __do_global_dtors_aux hijack with \"$1\" and a parasite that spawns a shell"
testtarget="$(random_name)"
cp -v "$1" "$testtarget"
"$INFECTOR" -d shell.o "$testtarget"
fname=`random_name`
echo "touch $fname" | "./$testtarget"
stat "$fname"
if [[ "$?" -ne "0" ]]
then
echo "[!] Test failed"
exit 1
fi
rm -v "$fname"
rm -v "./$testtarget"
echo "[+] Test passed!"
}
plt_hijack_hello() {
echo "----------------------------------------------------------------------------"
echo "[*] Testing .plt.got hijack with \"$1\" and a simple parasite"
testtarget="$(random_name)"
cp -v "$1" "$testtarget"
"$INFECTOR" -p hello.o "$testtarget"
"./$testtarget" | grep "ABCD"
if [[ "$?" -ne "0" ]]
then
echo "[!] Test failed"
exit 1
fi
rm -v "./$testtarget"
echo "[+] Test passed!"
}
dtors_hijack_hello() {
echo "----------------------------------------------------------------------------"
echo "[*] Testing __do_global_dtors_aux hijack with \"$1\" and a simple parasite"
testtarget="$(random_name)"
cp -v "$1" "$testtarget"
"$INFECTOR" -d hello.o "$testtarget"
"./$testtarget" | grep "ABCD"
if [[ "$?" -ne "0" ]]
then
echo "[!] Test failed"
exit 1
fi
rm -v "./$testtarget"
echo "[+] Test passed!"
}
TESTDIR="./test"
PLTDIR="./plt"
NOPLTDIR="./noplt"
INFECTOR="../infect_cxa_finalize"
make clean && make debug=on
cd "$TESTDIR"
plt_hijack_hello "plt/kill_plt"
dtors_hijack_hello "noplt/kill_noplt"
plt_hijack_shell "plt/kill_plt"
dtors_hijack_shell "noplt/kill_noplt"
plt_hijack_shell "plt/ls_plt"
dtors_hijack_shell "noplt/ls_noplt"
cd -
make clean