-
Notifications
You must be signed in to change notification settings - Fork 0
/
old-run.sh
82 lines (71 loc) · 1.98 KB
/
old-run.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
cc -m64 -z execstack main.c -o demo_w_exec
cc -m64 main.c -o demo_no_exec
cc -m64 personality.c -z execstack -o demo_personality_w_exec
cc -m64 personality.c -o demo_personality_no_exec
cc -m64 malloctest.c -o demo_malloc_no_exec
cc -m64 mmapalloc.c -o demo_mmapalloc_no_exec
echo binary execstack flags are
execstack -q demo_*
echo linux kernel is
uname -r
echo Running demo_w_exec - compiled with -z execstack
#Expect this to SUCCEED
./demo_w_exec
ERR=$?
if [ $ERR -eq 0 ]
then
echo "SUCCESS - Successfully ran executable code"
else
echo "FAIL to run executable code despite -z execstack"
fi
echo ' '
echo Running demo_no_exec - compiled without -z execstack
#Expect this to CRASH
./demo_no_exec
ERR=$?
if [ $ERR -eq 0 ]
then
echo "FAIL - Without -z execstack this should crash but did not"
else
echo "SUCCESS - Without -z execstack this should crash"
fi
echo ' '
echo Running demo_personality_w_exec - compiled with -z execstack
./demo_personality_w_exec
ERR=$?
if [ $ERR -eq 0 ]
then
echo "SUCCESS - with -z execstack should succeed"
else
echo "FAILED - with -z execstack should succeed"
fi
echo ' '
echo Running demo_personality_no_exec - compiled with -z execstack
./demo_personality_no_exec
ERR=$?
if [ $ERR -eq 0 ]
then
echo "SUCCESS - without -z execstack this should now succeed"
else
echo "FAILED - without -z execstack this should now succeed but did not"
fi
echo ' '
echo Running demo_malloc_no_exec - no execstack use mprotect to enable execute
./demo_malloc_no_exec
ERR=$?
if [ $ERR -eq 0 ]
then
echo "SUCCESS - without -z execstack this should still succeed due to mprotect"
else
echo "FAILED - with mprotect this should succeed but failed"
fi
echo ' '
echo Running demo_mmapalloc_no_exec - no execstack use mprotect to enable execute
./demo_mmapalloc_no_exec
ERR=$?
if [ $ERR -eq 0 ]
then
echo "SUCCESS - mprotect execute of mmapped memory worked"
else
echo "FAILED - mprotect execute of mmapped memory failed to work"
fi