LoginSignup
0
0

More than 3 years have passed since last update.

Pwnable.kr-[flag] writeup

Last updated at Posted at 2021-03-31

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

とりあえずwgetしてファイルを調べます。

soma@soma-E200HA:~/mine/pwnable/flag_pwn$ file flag
flag: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.24, BuildID[sha1]=96ec4cc272aeb383bd9ed26c0d4ac0eb5db41b16, not stripped
soma@soma-E200HA:~/mine/pwnable/flag_pwn$ ./flag
I will malloc() and strcpy the flag there. take it.

一見親切に見えますがgdbで何故かうまくデバッグできないのでstringsコマンドでもう一度調べると、UPXで圧縮されたファイルだとわかります。UPXって何だ?と思って調べてみると代表的な実行ファイル圧縮ソフトだそうです。こういうものがあるって教えてくれる問題みたいですね。
解凍して逆アセンブルします。

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

フラッグの場所そのまま書いてくれてますね。

(gdb) x/s *0x6c2070
0x496628:   "UPX...? sounds like a delivery service :)"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0