Rui*_*iro 3 linux reverse-engineering
我有一个可执行文件,它不能像往常/预期的那样很好地进行反汇编或反编译。
file并ldd给出与通常不同的输出:
$ file exe_file
exe_file: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), statically linked, stripped
$ ldd exe_file
not a dynamic executable
Run Code Online (Sandbox Code Playgroud)
strings 还提示某些事情已关闭:
$strings exe_file
UPX!
.....
PROT_EXEC|PROT_WRITE failed.
$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. $
Run Code Online (Sandbox Code Playgroud)
还:
$ ls -la exe_file
-rwxr-xr-x 1 root root 59896 Jan 22 15:26 exe_file
Run Code Online (Sandbox Code Playgroud)
怎么了?
从特征签名来看,我们正在处理一个打包的UPX可执行文件。
UPX 是一个免费的、可移植的、可扩展的、高性能的可执行打包程序,适用于多种可执行格式。
通常UPX用于打包/屏蔽二进制文件/恶意软件/病毒,因为它的签名/核心在大多数 AV 解决方案中被列入白名单。
请注意,在某些恶意软件可执行文件中,UPX 可以是外层,并且在“解包”UPX 层之后,您可能会拥有另一个其他打包/压缩技术的“内部”打包程序。
要解压二进制文件,必须安装upx.
使用 MacPorts 在 MacOS 中安装 UPX:
sudo port install upx
Run Code Online (Sandbox Code Playgroud)
在 Debian 中安装 UPX 并派生:
sudo apt-get install upx-ucl
Run Code Online (Sandbox Code Playgroud)
解压可执行二进制文件:
upx -d exe_file
Run Code Online (Sandbox Code Playgroud)
打包:
upx exe_file
Run Code Online (Sandbox Code Playgroud)
为了比较,解压exe_file后:
upx -d exe_file
Run Code Online (Sandbox Code Playgroud)
我们重新运行问题中的命令,结果大不相同:
$ file exe_file
exe_file: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3c233e12c466a83aa9b2094b07dbfaa5bd10eccd, stripped
$ ldd exe_file
linux-vdso.so.1 (0x00007ffd431d3000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f7f7fb7d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7f7f7de000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f7f7f56b000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7f7f367000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7f7ffc6000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7f7f14a000)
# ls -la exe_file
-rwxr-xr-x 1 root root 130736 Jan 22 15:26 exe_file
Run Code Online (Sandbox Code Playgroud)