Skip to content

Instantly share code, notes, and snippets.

@scottt
Last active February 3, 2016 19:19
Show Gist options
  • Save scottt/067bc8859b6aac13c8e1 to your computer and use it in GitHub Desktop.
Save scottt/067bc8859b6aac13c8e1 to your computer and use it in GitHub Desktop.
file s
set disable-randomization on
set disassemble-next-line on
# break on call 'swap@plt' in main
break *0x0804857c
break 'swap@plt'
run
si
disassemble 'swap@plt'
printf "\n\ninfo symbol 0x804a014: "
info symbol 0x804a014
# swap's entry in s's got.plt
# should point to <swap@plt+6>, i.e. the push instruction in swap@plt
x/a 0x804a014
si
si
si
printf "\n\ns's plt[0]\n"
x/4i 0x8048430
printf "\n\ns's swap@got.plt\nshould point to <swap@plt+6>, i.e. the push instruction in swap@plt\n"
x/a 0x804a014
printf "\n\ns's got.plt[2]\ninfo symbol 0x804a008: "
info symbol 0x804a008
x/a 0x804a008
info symbol 0xf7ff08c0
printf "\n\nLet the dynamic linker resolve swap()\n"
finish
printf "\n\ns's swap@got.plt\nshould point to swap() in swap.so\n"
x/a 0x804a014
info addr swap
quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment