Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are options to compile these binaries? #9

Open
jjang3 opened this issue May 5, 2023 · 0 comments
Open

What are options to compile these binaries? #9

jjang3 opened this issue May 5, 2023 · 0 comments

Comments

@jjang3
Copy link

jjang3 commented May 5, 2023

Hello, thank you for sharing these examples.

I'm just curious, how did you compile binaries for the linux_x64?

I am able to successfully exploit the binary that comes with the repository as shown below:

~/Downloads/ROP_STEP_BY_STEP/linux_x64 (master*) » python3 exp5.py                        
[*] '/home/Downloads/ROP_STEP_BY_STEP/linux_x64/level3'
    Arch:     amd64-64-little
    RELRO:    Partial RELRO
    Stack:    No canary found
    NX:       NX enabled
    PIE:      No PIE (0x400000)
[+] Starting local process './level3': pid 74600
[*] Switching to interactive mode
Hello, World
$ pwd
/home/Downloads/ROP_STEP_BY_STEP/linux_x64
$ exit
[*] Got EOF while reading in interactive
$
[*] Process './level3' stopped with exit code -11 (SIGSEGV) (pid 74600)
[*] Got EOF while sending in interactive

However, if I try to compile the binary by myself such as using the option shown below:
gcc level3.c -o level3_custom -fno-stack-protector -no-pie

Then it won't work:

~/Downloads/ROP_STEP_BY_STEP/linux_x64 (master*) » python3 exp5.py 
[*] '/home/Downloads/ROP_STEP_BY_STEP/linux_x64/level3_custom'
    Arch:     amd64-64-little
    RELRO:    Partial RELRO
    Stack:    No canary found
    NX:       NX enabled
    PIE:      No PIE (0x400000)
[+] Starting local process './level3_custom': pid 75948
[*] Switching to interactive mode
Hello, World
[*] Got EOF while reading in interactive
$ whoami
[*] Process './level3_custom' stopped with exit code -11 (SIGSEGV) (pid 75948)
[*] Got EOF while sending in interactive

I have made sure to adjust the exp5.py by using gdb to figure out what is the system@plt address with 0x401040:

~/Downloads/ROP_STEP_BY_STEP/linux_x64 (master*) » gdb ./level3_custom 
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
...
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./level3_custom...(no debugging symbols found)...done.
>>> disas callsystem
Dump of assembler code for function callsystem:
   0x0000000000401142 <+0>:     push   %rbp
   0x0000000000401143 <+1>:     mov    %rsp,%rbp
   0x0000000000401146 <+4>:     lea    0xeb7(%rip),%rdi        # 0x402004
   0x000000000040114d <+11>:    callq  0x401040 <system@plt>
   ...

Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant