forked from GJDuck/e9patch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe9test.sh
More file actions
executable file
·81 lines (74 loc) · 2.47 KB
/
e9test.sh
File metadata and controls
executable file
·81 lines (74 loc) · 2.47 KB
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
#!/bin/bash
if [ -t 1 ]
then
RED="\033[31m"
GREEN="\033[32m"
YELLOW="\033[33m"
BOLD="\033[1m"
OFF="\033[0m"
else
RED=
GREEN=
YELLOW=
BOLD=
OFF=
fi
set -e
mkdir -p tmp
./e9compile.sh examples/nop.c >/dev/null 2>&1
# Setup the example.so plugin
g++ -std=c++11 -fPIC -shared -o example.so -O2 \
examples/plugins/example.cpp -I src/e9tool/ -I capstone/include/
export LIMIT=99999999999
for ACTION in \
'passthru' \
'call[naked,after] entry@nop' \
'call entry(asm,instr,rflags,rdi,rip,addr,target,next)@nop' \
'call entry(&rsp,&rax,&rsi,&rdi,&r8,&r15,staticAddr,0x1234)@nop' \
'call entry(&op[0],&src[0],&dst[0],&op[1],&src[1],&dst[1],&dst[7],&src[7])@nop' \
'call entry(reg[0],®[0],imm[0],&imm[0],&mem[0],reg[1],®[1],imm[1])@nop' \
'plugin(example).patch()' \
'print'
do
# Step (1): duplicate the tools
if ! ./e9tool ./e9tool --match true "--action=$ACTION" \
-o tmp/e9tool.patched -c 6 -s >/dev/null 2>&1
then
echo -e "${RED}FAILED${OFF}: e9tool ${YELLOW}$ACTION${OFF} [step (1)]"
continue
fi
if ! ./e9tool ./e9patch --match true "--action=$ACTION" \
-o tmp/e9patch.patched -c 6 -s >/dev/null 2>&1
then
echo -e "${RED}FAILED${OFF}: e9patch ${YELLOW}$ACTION${OFF} [step (1)]"
continue
fi
# Step (2): duplicate the tools with the duplicated tools
if ! tmp/e9tool.patched --backend "$PWD/tmp/e9patch.patched" \
./e9tool --match true "--action=$ACTION" -o tmp/e9tool.2.patched \
-c 6 -s >/dev/null 2>&1
then
echo -e "${RED}FAILED${OFF}: e9tool ${YELLOW}$ACTION${OFF} [step (2)]"
continue;
fi
if ! tmp/e9tool.patched --backend "$PWD/tmp/e9patch.patched" \
./e9patch --match true "--action=$ACTION" -o tmp/e9patch.2.patched \
-c 6 -s >/dev/null 2>&1
then
echo -e "${RED}FAILED${OFF}: e9patch ${YELLOW}$ACTION${OFF} [step (2)]"
continue
fi
# Step (3): Everything should be the same:
if diff tmp/e9tool.patched tmp/e9tool.2.patched > /dev/null
then
echo -e "${GREEN}PASSED${OFF}: e9tool ${YELLOW}$ACTION${OFF}"
else
echo -e "${RED}FAILED${OFF}: e9tool ${YELLOW}$ACTION${OFF}"
fi
if diff tmp/e9patch.patched tmp/e9patch.2.patched > /dev/null
then
echo -e "${GREEN}PASSED${OFF}: e9patch ${YELLOW}$ACTION${OFF}"
else
echo -e "${RED}FAILED${OFF}: e9patch ${YELLOW}$ACTION${OFF}"
fi
done