本文主要介绍 IoT 固件逆向中,常用的一些小工具,对于黑盒分析固件十分有用。
- 查找固件基地址:rbasefind
- 为原始固件增加ELF头或节表,方便IDA反编译:addelfinfo
- 还原标准库中的符号表:sibyl
- 逆向分析:miasm2
- 跨平台的嵌入式程序:embedded-toolkit
- Linux 常用命令:busybox
rbasefind
rbasefind 是一款暴力查找固件在内存中的基地址的工具。项目地址:https://github.com/sgayou/rbasefind。
在拿到固件的第一步,最重要的就是确定基地址,这样才能让 IDA 识别更多的函数和字符串。rbasefind 就是这样一款工具,是 @mncoppola’s basefind.py 以及 @rsaxvc’s basefind.cpp 的 rust 实现,因此需要有 rust 环境
安装 rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
讯享网
提示信息
讯享网Rust is installed now. Great! To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically. To configure your current shell run source $HOME/.cargo/env
也就是说,需要添加相应的环境变量,即可使用 rust 相关命令
源码安装 rbasefind
$ git clone https://github.com/sgayou/rbasefind.git $ cd rbasefind $ cargo build
添加环境变量
讯享网source $HOME/.cargo/env
使用案例
lys@ubuntu:~/Documents/test$ rbasefind u-boot.bin Located 10 strings Located 72155 pointers Scanning with 8 threads... 0x: 8 0xff22d000: 1 0xfe3a6000: 1 0xfdb83000: 1 0xfca84000: 1 0xfbf1d000: 1 0xfb: 1 0xf965e000: 1 0xf7bae000: 1 0xf777a000: 1
addelfinfo
为原始的二进制添加ELF头和节表,自研小工具,项目地址:https://github.com/liyansong2018/Tools2Firmware
sibyl
sibyl 可以将一些原始的二进制文件中的标准库函数还原,识别库函数的符号表。
项目地址:https://github.com/cea-sec/Sibyl。该项目所需依赖:Miasm2,请注意,版本是 v0.1.1(https://github.com/cea-sec/miasm/releases/tag/v0.1.1),最新版 Miasm 不能在此工作
安装(仅仅支持 python2)
讯享网$ git clone https://github.com/cea-sec/Sibyl.git $ cd Sibyl $ python setup.py build # Add the resulting build directory in your PYTHONPATH, or: $ sudo python setup.py install
用法
lys@ubuntu:~/Tools/miasm-0.1.1$ sibyl Usage: /usr/local/bin/sibyl [action] Actions: config Configuration management find Function guesser func Function discovering learn Learn a new function
打印函数
讯享网sibyl func -a arml u-boot.bin.elf > funcs.txt
转换函数
sibyl find -a arml -b ABI_ARM u-boot.bin.elf funcs.txt
效果
讯享网Python> Launch identification on 3085 function(s) Found memcpy at 0x Found memmove at 0xc Found memset at 0x Found strcat at 0x80571a8 Found strchr at 0x80571cc Found strcmp at 0x Found strcpy at 0x Found strlen at 0x Found strncmp at 0x Found strncpy at 0x Found strnlen at 0x80572a8 Found strrchr at 0x80572c0 Found memcmp at 0x80572ff Found strsep at 0x80576ac Found strspn at 0x Found stricmp at 0xc Found strpbrk at 0x8057ab8 Found strtok at 0x8057b30 Found strcmp at 0x8057b48 Found atoi at 0x805df1c Current: 64.83% (sub_0x80b4ab3)| Estimated time remaining: 14.45s Found atoi at 0x80f1cf3 Current: 100.00% (sub_0x80f7a93)| Estimated time remaining: 0.00s Finished ! Found 21 candidates in 42.70s Results are also available in 'sibyl_res'
Miasm2
Miasm 是一个免费和开源(GPLv2)逆向工程框架。Miasm 旨在分析/修改/生成二进制程序,例如符号执行、沙盒模拟。项目地址:https://github.com/cea-sec/miasm

安装
$ git clone https://github.com/cea-sec/miasm.git $ cd miasm $ pip install -r requirements.txt $ sudo python setup.py install
最新版支持 python2、python3
官方提供了非常详细有趣的示例,有兴趣的同学可以尝试一下。
embedded-toolkit
严格意义上来说,这并不是一个工具,而是一个编译好的工具集,包括
- tcpdump (statically linked
- gawk (statically linked)
- lsof (statically linked)
- gdbserv (statically linked)
- tshd (statically linked)
- mawk (statically linked)
- libpcap (static library, used for linking into tcpdump so not present in this repo)
这些已经编译好的二进制,包含了多个平台,如 x86、arm、mips,如果不想花时间在交叉编译上,可以使用它们,但不保证二进制有没有安全问题。项目地址:https://github.com/akpotter/embedded-toolkit
busybox
BusyBox 是一个集成了三百多个最常用Linux命令和工具的软件。BusyBox 包含了一些简单的工具,例如ls、cat和echo等等,还包含了一些更大、更复杂的工具,例grep、find、mount以及telnet。有些人将 BusyBox 称为 Linux 工具里的瑞士军刀。
各种二进制下载地址:https://busybox.net/downloads/binaries/

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/45184.html