IoT Fuzz 初探(路由器)
由于大创的原因,学了一下Fuzz。Fuzz在二进制文件代码量很大(实战里几乎全都很大)的时候很有用。大创选的是路由器,路由器固件的代码量完全不用Fuzz,当时不懂,为了带上智能化这个keyword就写上去了。
环境搭建
Binwalk(解包)
1 | git clone https://github.com/devttys0/binwalk |
AFL++
Download the lastest devel version with:
1 | git clone https://github.com/AFLplusplus/AFLplusplus |
AFL++ has many build options. The easiest is to build and install everything:
1 | make distrib |
Note that “make distrib” also builds llvm_mode, qemu_mode, unicorn_mode and more. If you just want plain afl then do “make all”, however compiling and using at least llvm_mode is highly recommended for much better results - hence in this case
1 | make source-only |
Radamsa( 测试用例生成器 )
1 | # please please please fuzz your programs. here is one way to get data for it: |
qemu(调试)
1 | sudo apt install ninja-build #依赖 |
Binwalk 识别&解压
sample: RT-AC68U
固件下载链接置于文末
1 | $ binwalk RT-AC68U_3.0.0.4_380_7743-g2cf84e9-fbwifi.trx |
binwalk识别出了文件系统,可以直接用binwalk -Me
解压
1 | $ binwalk -Me RT-AC68U_3.0.0.4_380_7743-g2cf84e9-fbwifi.trx |
解压完后在 squashfs-root/usr/sbin
文件夹下找到 httpd。
1 | $ file httpd |
AFL++
AFL++是一个fuzz工具,扩展了原版 AFL,并且有详细的文档和样例代码 。
运行
1 | $ sudo qemu-arm -L /path/to/squashfs-root/ ./httpd |
可以看到宿主机上缺少设备,但是不影响
固件获取
OPENWRT
这里测试的是ASUS RT-AC68U的固件
官网
TOTOLINK
FAST
极路由/hiwifi
TP-LINK
MERCURY
Tenda
磊科
维盟
艾泰
锐捷路由器
飞鱼星
newifi
b-link