Need tips on emulation of MIPS-BE system using QEMU with the help of squashfs image file and uBoot Kernel image file extracted from the firmware file.

Long Version:

- What I have:

  1. A cheap unpopular GPON (Fiber ONU) device, which I have root shell access to.
  2. A computer
  3. Beginner skills (binwalk, gdb, basic stackoverflow etc.)
  4. High enthusiasm towards hacking

- What I want:

The router runs an ancient webserver called Boa and this has several publicly available vulnerabilties. But, I have tested each and every one against the target router ; but none of it worked. The firmware is released on this year; so, I'm almost sure that the vendor has patched them. However, I have already found an vulnerability, which I've disclosed to the vendor. But, I don't want to stop there, as I am pretty sure that this webserver contains tons of other vulnerabilities. My research found out that vendor has precompiled the webserver binaries as a stripped file and all of the server side processing functions are compiled as a stripped custom library file. What I want is to dynamically analyze the library file and catch the function calls from the webserver to the library file using gdb. To do that, I have tried the following steps:

  • Placed a pre-compiled gdbserver binary and tried to run it directly in the router. But, whenever I try to do this, it gets killed automatically. (Most probably due to the low ram)
  • Tried to execute the webserver binary using QEMU user mode. But, failed with custom error messages. These custom error messages aren't very descriptive and has no documentation available on the whole internet
  • Emulated a MIPS system via QEMU (using debian kernel image and drive image from here), copied the extraced file system from the firmware to QEMU , chrooted into the copied file system and executed BusyBox shell from the firmware file system. Even though the BusyBox shell works inside QEMU, I cannot start the webserver inside QEMU as it throws the same custom errors as before.
  • Tried to statically analyze the library using Ghidra. But, since the symbols are stripped, it didn't made any sense to me at all.
  • Converted the rootfs to qcow2 image and used it with debian kernel image, but QEMU couldn't boot from it, since it couldn't detect the disk image.

As far as my research went, the only option for me to dynamically analyze the web server is to make the web server run in QEMU with the kernel image and rootfs image I extracted from the firmware. So, what are my next steps? How can I perform a full system emulation with QEMU, using the squashfs image and uBoot kernel image?

  • The webserver is open source, can't you statically analyze it for vulnerabilities, and check whether they are exploitable using fuzzing? Not exactly what you want, but maybe that's a temp solution until you figure out how to dynamically analyze the executable. Apr 6, 2021 at 11:33
  • Not exactly. The vendor has all the server side scripting compiled as a custom library and Boa server uses that library. So, that means Analyzing the source code of Boa server is not worth it ( Also, I have already done it) .
    – secnigma
    Apr 7, 2021 at 12:04
  • Ah I see, makes sense. Apr 7, 2021 at 13:48


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.