使用带有 -L 参数的 QEMU 用户模式到 运行 来自 IoT 固件的 ARM 二进制文件时出现问题

Problems when using QEMU user mode with -L parameter to run an ARM binary from IoT firmware

我尝试 运行 一个 ARM 二进制文件 - httpd 它来自 Ubuntu18.04 上的网络摄像头固件。我的电脑是基于 X64_86 所以我决定 运行 使用 QEMU 虚拟机。据我所知,QEMU提供了两种不同的模拟模式,分别是System ModeUser Mode。首先,我尝试了系统模式,二进制文件可以 运行 成功。通过这样做,我可以保证二进制文件是好的。

然后我尝试使用User Mode,更简洁快速。二进制文件是动态 linked 的,因此相关博客仍然建议了两种方法。第一种解决方案是将 qemu-arm 二进制文件和依赖的动态 link 库文件复制到固件的根路径 - squashfs-root 然后使用 chroot 命令,如 chroot ./qemu-arm ./usr/sbin/httpd。结果也很好

最后,我尝试将 qemu-arm-L 参数一起使用,这表明依赖动态 link 库文件的前缀。但是这次没有起作用,也没有报错,几分钟后就被kill掉了。我也试过 export LD_LIBRARY_PATH = . 都没有。我可以提供的一些信息如下。

apple@ubuntu:squashfs-root$ ls
bin  dev  drivers  etc  fuzz_in  fuzz_out  home  ldd_cp.sh  lib  lib64  linuxrc  mnt  proc  qemu-arm  qemu-arm-static  root  sbin  start_debug.sh  start.sh  sys  tmp  tmpfs  usr  var  www
apple@ubuntu:squashfs-root$ qemu-arm -L . ./usr/sbin/httpd
Killed
apple@ubuntu:squashfs-root$ file ./usr/sbin/httpd
./usr/sbin/httpd: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped

我应该提到的另一个信息是我没有二进制文件的源代码。我尝试使用 -g 参数和 gdb-multiarch 调试二进制文件,但出现如下所示的情况。

apple@ubuntu:squashfs-root$ qemu-arm -L . -g 2222 ./usr/sbin/httpd
Killed
apple@ubuntu:squashfs-root$ gdb-multiarch
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) set architecture arm
The target architecture is assumed to be arm
(gdb) file ./usr/sbin/httpd
Reading symbols from ./usr/sbin/httpd...(no debugging symbols found)...done.
(gdb) target remote: 2222
: 2222: Connection timed out.
(gdb) 

qemu-arm-static + chroot 的方式可以正常工作,已经过测试。 我之所以 我如此顽强地使用 QEMU 用户模式 ​​-L 是因为这项工作的最终目标是通过使用 afl-qemu 来模糊 httpd 二进制文件。前提条件是二进制文件应该能够 运行 与 QEMU 用户模式。 除了依赖的动态 link 库文件之外,我必须缺少一些东西。任何人都可以帮助我,甚至只是给我一些想法吗?非常感谢!!!

已添加:

apple@ubuntu:~$ qemu-arm --version
qemu-arm version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.34)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

您可以尝试更新新版QEMU实现-L功能。经测试,qemu-4.1.0满足-L功能