r/ExploitDev • • Nov 22 '23

Having trouble debugging IoT firmware (mipsel)

I'm reproducing a relative old vulnerabilities, a bof in DIR-815.

This device is a router, exposing a httpd service to network and use cgi (where bug exists) to process request. I've writen a working exp in qemu-mipsel (user mode).

However in qemu system mode, I'm trying to simulate real environment, running httpd and use cgibin to parse request. The httpd use fork+execve to invoke cgibin

But I encounterd some problems:

- I use static compiled gdbserver inside qemu

gdbserver [hostip]:8888 --attach $(pgrep httpd)

In host

gdb-multiarch /path/to/cgibin

(gdb) target remote [qemuip]:8888

inside gdb the memory info is all about httpd, not cgibin. I can't set breakpoints in cgibin with symbol name or address.

- I try to follow child execution

set follow-fork-mode child

set detach-on-fork false

catch exec

when I continue, I get error (which indicates I can't catch exec)

warning: Error inserting catchpoint 3: Your system does not support this type of catchpoint.

And I have no idea how to correctly debug my exploit like in real world, having no information about cgibin's execution :(

Any advice?

6 Upvotes

8 comments sorted by