Stack Overflow Experiments & Results
Stack Corruption Experiments & Results
I used the following code to experiment user space stack corruption features.
Stack corruption experiment when -fstack-protector is disabled:
root@babu-VirtualBox:~/tools/stk_corruption#
gcc -fno-stack-protector stk_corrupt.c -o stk_corrupt
root@babu-VirtualBox:~/tools/stk_corruption#
./stk_corrupt
Enter the buffer:
sdsadsjsdfsdjfsdfjlskfj
Segmentation fault (core
dumped)
root@babu-VirtualBox:~/tools/stk_corruption#
Stack corruption experiment when -fstack-protector is enabled:
root@babu-VirtualBox:~/tools/stk_corruption#
gcc -fstack-protector stk_corrupt.c -o stk_corrupt
root@babu-VirtualBox:~/tools/stk_corruption# ./stk_corrupt
Enter the buffer:
asd
asd
Survived Stack corruption
root@babu-VirtualBox:~/tools/stk_corruption#
root@babu-VirtualBox:~/tools/stk_corruption#
root@babu-VirtualBox:~/tools/stk_corruption# ./stk_corrupt
Enter the buffer:
asdfgg
*** stack smashing detected ***:
./stk_corrupt terminated
Aborted (core dumped)
Aborted (core dumped)
root@babu-VirtualBox:~/tools/stk_corruption#
So, -fstack-protector has helped to clearly identify the segmentation fault is due to stack overflow.
No comments:
Post a Comment