6.2.5 re PicoCTF2014 Baleful

下载文件

题目解析

$ file baleful
baleful: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, stripped
$ strings baleful | grep -i upx
@UPX!
$Info: This file is packed with the UPX executable packer http://upx.sf.net $
$Id: UPX 3.91 Copyright (C) 1996-2013 the UPX Team. All Rights Reserved. $
UPX!u
UPX!
UPX!
$ upx -d baleful -o baleful_unpack
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2017
UPX 3.94        Markus Oberhumer, Laszlo Molnar & John Reiser   May 12th 2017

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
    144956 <-      6752    4.66%   linux/i386    baleful_unpack

Unpacked 1 file.
$ file baleful_unpack
baleful_unpack: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=35d1a373cbe6a675ecbbc904722a86f853f20ce3, stripped

经过简单地检查,我们发现二进制文件被加了壳,使用 upx 脱掉就好了。

运行下看看,典型的密码验证题:

逆向 VM 求解

打开 r2 开干吧!

fcn.0804898b 是程序主要的逻辑所在,很容易看出来它其实是实现了一个虚拟机:

使用 Pin 求解

就像上面那样逆向实在是太难了,不如 Pin 的黑科技。

编译 32 位 pintool:

随便输入几个长度不同的密码试试:

指令执行的次数呈递增趋势,完美,这样只要递增到这个次数有不同时,就可以得到正确的密码长度:

好,密码长度为 30,接下来是逐字符爆破,首先要确定字符不同对 count 没有影响:

确实没有,写下脚本:

简单到想哭。

参考资料

Last updated

Was this helpful?