rev120 points  Solved 134 times  Reversing  Arun Dunna

Let's start out with an easy, typical reversing problem.

The answer will not be in the typical sctf{flag} format, so when you do get it, you must put it into the format by doing sctf{flag_you_found}

ダウンロードしたファイルのファイルタイプをfileコマンドで確認します。Linux用の64bitバイナリのようです。

$ file rev1

rev1: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=82958aa51b05984108d0808209174e172dbf4338, not stripped

実行してみるとパスワードを聞いてきます。適当に入力するとそのまま終了してしまいます。

$ ./rev1
What is the magic password?
aaa

objdumpコマンドで逆アセンブルして動作を解析します。

$ objdump -s -D rev1 > bbb.txt

以下の箇所で、入力されたデータを数値として読み込み、0x5b74=23412との比較結果により分岐しています。

  400688:    bf 60 07 40 00           mov    $0x400760,%edi     #%d
  40068d:    b8 00 00 00 00           mov    $0x0,%eax
  400692:    e8 b9 fe ff ff           callq  400550 <scanf@plt>
  400697:    8b 45 fc                 mov    -0x4(%rbp),%eax
  40069a:    3d 74 5b 00 00           cmp    $0x5b74,%eax       #0x5b74=23412

  40069f:    75 16                    jne    4006b7 <main+0x61>

それではもう一度実行し、パスワードに23412を入力します。フラグが表示されました。

$ ./rev1

What is the magic password?
23412
Correct! Your flag is: h4x0r!!!

フラグは、

sctf{h4x0r!!!}

です。

熱血! アセンブラ入門
坂井弘亮
秀和システム
2015-06-12