CSC 472/583 Software Security Return-oriented programming (ROP)
- Dr. Si Chen (schen@wcupa.edu)
ss 6 Cl Class CSC 472/583 Software Security Return-oriented - - PowerPoint PPT Presentation
ss 6 Cl Class CSC 472/583 Software Security Return-oriented programming (ROP) Dr. Si Chen (schen@wcupa.edu) Compile the code gcc -m32 fno-stack-protector z execstack o ./overflow2 ./overflow2.c Page 2 No eXecute (NX) -z
Page § 2
Page § 3
Page § 4
After the function returns, the program will set the instruction pointer to 0xbfff0000 and attempt to execute the instructions at that address. However, since the region of memory mapped at that address has no execution permissions, the program will crash.
Page § 5
Page § 6
Page § 7
Page § 8
Page § 9
–
–
Page § 10
Page § 11
[1] -Buchanan, E.; Roemer, R.; Shacham, H.; Savage, S. (October 2008)
[2] -
Shacham, Hovav; Buchanan, Erik; Roemer, Ryan; Savage, Stefan. Retrieved 2009-08-12.
Page § 12
Page § 13
insn insn insn insn instruction pointer
Page § 14
instruction
Page § 15
Page § 16
Page § 17
Page § 18
Page § 19
Page § 20
Page § 21
Page § 22
Page § 23
Basic Structure of Return Chaining
Page § 24
Function Address Return Address (Old EIP) Arguments
Page § 25
Dummy Character “A”s Address for Add_bin() Address for Add_bash() Address for exec_string()
main() à vulnerable_function (hacked) à add_bash() à add_bin() à exec_string() à Spawn shell Execution Path
Page § 26
Dummy Character “A”s Address for Add_bin() Address for Add_bash() 0xdeadbeef Address for exec_string()
à add_bin() à magic == 0xdeadbeef à add_bash() à magic1 == 0xcafebabe à magic2 == 0x0badf00d à exec_string() à Spawn shell
Execution Path
à magic == 0xdeadbeef
Function Address Return Address (Old EIP) Arguments
Page § 27
Dummy Character “A”s Address for Add_bin() Address for pop_ret 0xdeadbeef Address for Add_bash()
à add_bin() à magic == 0xdeadbeef à add_bash() à magic1 == 0xcafebabe à magic2 == 0x0badf00d à exec_string() à Spawn shell
Execution Path
à magic == 0xdeadbeef
Page § 28
Dummy Character “A”s Address for Add_bin() Address for pop_ret 0xdeadbeef Address for Add_bash() Address for pop_pop_ret 0xcafebabe 0x0badf00d
à add_bin() à magic == 0xdeadbeef à add_bash() à magic1 == 0xcafebabe à magic2 == 0x0badf00d à exec_string() à Spawn shell
Execution Path
à magic1 == 0xcafebabe à magic2 == 0x0badf00d
Page § 29
Dummy Character “A”s Address for Add_bin() Address for pop_ret 0xdeadbeef Address for Add_bash() Address for pop_pop_ret 0xcafebabe 0x0badf00d Address for exec_string()
à add_bin() à magic == 0xdeadbeef à add_bash() à magic1 == 0xcafebabe à magic2 == 0x0badf00d à exec_string() à Spawn shell
Execution Path
Page § 30
Page § 31
Page § 32
Page § 33
fwrite() write() interrupt 0x80 sys_write() Kernel Application C Run Time Library API (Windows) Kernel ./program libc.a libc.so libc.a libc.so ./vlinuxz
Page § 34
Page § 35
– execve("/bin/sh", {0}, {0})
Page § 36
– eax - holds the number of the syscall to be called – ebx - a pointer to the string containing the file name to be executed – ecx - a pointer to the array of string pointers representing argv – edx - a pointer to the array of string pointers representing envp
Page § 37