picoCTFのwriteupみたいなやつ (Reverse Engineering)

picoCTFのReverse Engineeringについてまとめていく。頻度は少ないかも。

開閉

packer

Reverse this linux executable?
ということで、何かしらのファイルが渡された。

└─# file out
out: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, no section header

何かしらの実行ファイルのようだ。

PROT_EXEC|PROT_WRITE failed.
$Info: This file is packed with the UPX executable packer http://upx.sf.net $
$Id: UPX 3.95 Copyright (C) 1996-2018 the UPX Team. All Rights Reserved. $

stringsコマンド出力の中に以上のような記述あり。何かしらのパッカーが使われているようだ。

知識(UPX)
UPX 実行ファイルをパッキングするツールのようだ。

(UPX 4.2.2 | ダウンロードと使い方)をもとにダウンロードしてunpackしてみた。

└─# ./upx -d ../out
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2024
UPX 4.2.2       Markus Oberhumer, Laszlo Molnar & John Reiser    Jan 3rd 2024

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
[WARNING] bad b_info at 0x4b718

[WARNING] ... recovery at 0x4b714

    877724 <-    336520   38.34%   linux/amd64   out

Unpacked 1 file.

できたようだ。

└─# file out
out: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=1c5ee6208dac5576d6893e662951fa6f35e49efc, for GNU/Linux 3.2.0, not stripped

先と内容が変わっている。strings out |grep picoをしても反応ないのでまだ足りないようだ。Reversingするにもめぼしをつけるためにstrings出力を見ていくと以下のようなものがあった。

Enter the password to unlock this file:
You entered: %s
Password correct, please see flag: 7069636f4354467b5539585f556e5034636b314e365f42316e34526933535f31613561336633397d
Access denied
xeon_phi
haswell

flagらしきものあり。cyberchefに投げてmagicしたらflagゲット。