I am attempting to figure the canary value setting and checking mechanism.
#include int main(void) { return printf("Hi!\n"); }
When disassemble the main, I get
(gdb) disas main 0x080483f4 : lea 0x4(%esp),%ecx 0x080483f8 : and $0xfffffff0,%esp 0x080483fb : pushl -0x4(%ecx) 0x080483fe : push %ebp 0x080483ff : mov %esp,%ebp 0x08048401 : push %ecx 0x08048402 : sub $0x14,%esp 0x08048405 : mov %gs:0x14,%eax 0x0804840b : mov %eax,-0x8(%ebp) 0x0804840e : xor %eax,%eax 0x08048410 : movl $0x8048500,(%esp) 0x08048417 : call 0x8048320 0x0804841c : mov -0x8(%ebp),%edx 0x0804841f : xor %gs:0x14,%edx 0x08048426 : je 0x804842d 0x08048428 : call 0x8048330 0x0804842d : add $0x14,%esp 0x08048430 : pop %ecx 0x08048431 : pop %ebp 0x08048432 : lea -0x4(%ecx),%esp 0x08048435 : ret
I set a breakpoint at 0x0804840e using
b *0x0804840e
After the program flow stops at this breakpoint I would like gdb
to go to the next instruction instead of next line of c code. I don't think I can use next
for this. So what other option do I have apart from setting a breakpoint at every instruction?
Sure: jump *0x1234 will jump to instruction at address 0x1234 .
If you want to execute the entire function with one keypress, type "next" or "n". This is equivalent to the "step over" command of most debuggers. If you want gdb to resume normal execution, type "continue" or "c". gdb will run until your program ends, your program crashes, or gdb encounters a breakpoint.
You want to use stepi
, aka si
. it steps by one machine instruction.
(Or ni
to step over call
instructions.)
Check the GDB manual's section on continuing and stepping, which has an entry for it.
Or inside GDB, help
/ help running
will show you that si
exists, and help stepi
will show you more about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With