Question: A much more sophisticated form of buffer attack involves supplying a string that encodes actual machine in- structions. The exploit string then overwrites the return
A much more sophisticated form of buffer attack involves supplying a string that encodes actual machine in- structions. The exploit string then overwrites the return pointer with the starting address of these instructions on the stack. When the calling function (in this case getbuf) executes its ret instruction, the program will start executing the instructions on the stack rather than returning. With this form of attack, you can get the program to do almost anything. The code you place on the stack is called the exploit code. This style of attack is tricky, though, because you must get machine code onto the stack and set the return pointer to the start of this code. Within the file bufbomb there is a function bang having the following C code: int global_value = 0; void bang(int val) { if (global_value == cookie) { printf("Bang!: You set global_value to 0x%x ", global_value); validate(2); } else printf("Misfire: global_value = 0x%x ", global_value); exit(0); } 7 Similar to Levels 0 and 1, your task is to get BUFBOMB to execute the code for bang rather than returning to test. Before this, however, you must set global variableglobal_valueto your userids cookie. Your exploit code should set global_value, push the address of bang on the stack, and then execute a ret instruction to cause a jump to the code for bang
My dump code for getbuf and bang are 0x804926e
and for bang ///////////////////////////////////////////////// 0x08048a02 <+0>: push %ebp 0x08048a03 <+1>: mov %esp,%ebp 0x08048a05 <+3>: push %ebx 0x08048a06 <+4>: sub $0x4,%esp 0x08048a09 <+7>: call 0x8048840 <__x86.get_pc_thunk.bx> 0x08048a0e <+12>: add $0xc35f2,%ebx 0x08048a14 <+18>: mov 0x24d4(%ebx),%eax 0x08048a1a <+24>: mov %eax,%edx 0x08048a1c <+26>: mov 0x24cc(%ebx),%eax 0x08048a22 <+32>: cmp %eax,%edx 0x08048a24 <+34>: jne 0x8048a4e
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
