ssongk
ssongk
ssongk
전체 방문자
오늘
어제

공지사항

  • resources
  • 분류 전체보기 (627)
    • CTF (24)
    • background (79)
      • fuzzing (5)
      • linux (29)
      • linux kernel (15)
      • windows (2)
      • web assembly (1)
      • embedded (0)
      • web (13)
      • crypto (9)
      • mobile (1)
      • AI (1)
      • etc.. (3)
    • write-up(pwn) (171)
      • dreamhack (102)
      • pwn.college (4)
      • pwnable.xyz (51)
      • pwnable.tw (3)
      • pwnable.kr (5)
      • G04T (6)
    • write-up(rev) (32)
      • dreamhack (24)
      • reversing.kr (8)
    • write-up(web) (195)
      • dreamhack (63)
      • LOS (40)
      • webhacking.kr (69)
      • websec.fr (3)
      • wargame.kr (6)
      • webgoat (1)
      • G04T (7)
      • suninatas (6)
    • write-up(crypto) (19)
      • dreamhack (16)
      • G04T (1)
      • suninatas (2)
    • write-up(forensic) (53)
      • dreamhack (5)
      • ctf-d (47)
      • suninatas (1)
    • write-up(misc) (14)
      • dreamhack (13)
      • suninatas (1)
    • development (31)
      • Linux (14)
      • Java (13)
      • Python (1)
      • C (2)
      • TroubleShooting (1)
    • 자격증 (8)
    • 이산수학 (1)
    • 정보보안 (0)
hELLO · Designed By 정상우.
ssongk

ssongk

write-up(pwn)/pwnable.kr

[pwnable.kr] flag write-up

2023. 5. 13. 22:01

upx packing 이라는 개념을 몰랐어서 라업을 보고 푼 문제입니다.

실행하면 다음과 같이 나옵니다.

I will malloc() and strcpy the flag there. take it.

 

gdb로 보면 심볼이 없다고 나옵니다.

다음과 같은 명령어로 upx 패킹이 되어 있다는 것을 알 수 있다고 합니다.

$ strings flag | grep packed
$Info: This file is packed with the UPX executable packer http://upx.sf.net $

 

이걸 다음과 같은 명령어로 언패킹할 수 있습니다.

$ upx -d ./flag

 

이제 disassemble 해보면 다음과 같습니다.

gdb-peda$ disassemble main
Dump of assembler code for function main:
   0x0000000000401164 <+0>:     push   rbp
   0x0000000000401165 <+1>:     mov    rbp,rsp
   0x0000000000401168 <+4>:     sub    rsp,0x10
   0x000000000040116c <+8>:     mov    edi,0x496658
   0x0000000000401171 <+13>:    call   0x402080 <puts>
   0x0000000000401176 <+18>:    mov    edi,0x64
   0x000000000040117b <+23>:    call   0x4099d0 <malloc>
   0x0000000000401180 <+28>:    mov    QWORD PTR [rbp-0x8],rax
   0x0000000000401184 <+32>:    mov    rdx,QWORD PTR [rip+0x2c0ee5]        # 0x6c2070 <flag>
   0x000000000040118b <+39>:    mov    rax,QWORD PTR [rbp-0x8]
   0x000000000040118f <+43>:    mov    rsi,rdx
   0x0000000000401192 <+46>:    mov    rdi,rax
   0x0000000000401195 <+49>:    call   0x400320
   0x000000000040119a <+54>:    mov    eax,0x0
   0x000000000040119f <+59>:    leave  
   0x00000000004011a0 <+60>:    ret    
End of assembler dump.

 

malloc을 호출 한 뒤 0x400320 함수로 플래그를 작성하는 것으로 보입니다.

gdb-peda$ x/gx $rbp-8
0x7fffffffdf38: 0x00000000006c96b0

 

malloc으로 할당된 주소는 0x6c96b0입니다.

main+49까지 실행된 후 해당 주소를 읽어보면 플래그가 나옵니다.

gdb-peda$ x/s 0x00000000006c96b0
0x6c96b0:       "UPX...? sounds like a delivery service :)"

 


레퍼런스

https://jaimelightfoot.com/blog/pwnable-kr-flag-walkthrough/

 

Pwnable.kr: ‘flag’ Walkthrough

The fourth challenge in the “Toddler’s Bottle” series is called “flag.” Here’s our hint, gumshoes: Papa brought me a packed present! let’s open it. Download : http://pwnable.kr/bin/flag This is reversing task. all you need is binary malloc W

jaimelightfoot.com

'write-up(pwn) > pwnable.kr' 카테고리의 다른 글

[pwnable.kr] passcode write-up  (0) 2023.06.14
[pwnable.kr] bof write-up  (0) 2023.05.01
[pwnable.kr] collision write-up  (0) 2023.05.01
[pwnable.kr] fd write-up  (0) 2023.04.29
    'write-up(pwn)/pwnable.kr' 카테고리의 다른 글
    • [pwnable.kr] passcode write-up
    • [pwnable.kr] bof write-up
    • [pwnable.kr] collision write-up
    • [pwnable.kr] fd write-up
    ssongk
    ssongk
    벌레 사냥꾼이 되고 싶어요

    티스토리툴바