Search code examples
gdbmipsfirmware

How to debug binaries from a MIPS firmware


I'm trying to exploit the binaries from Damn vulnerable Router Firmware but I have issues with debuggging with gdb. to run the program i use this command : sudo chroot . ./qemu-mipsel-static ./pwnable/Intro/stack_bof_01 and it works but when i try to run gdb with :

sudo chroot . ./qemu-mipsel-static gdb ./pwnable/Intro/stack_bof_01 

I have that :

(gdb) r

Starting program: /pwnable/Intro/stack_bof_01

qemu: Unsupported syscall: 4026

Cannot exec /bin/bash: No such file or directory.

qemu: Unsupported syscall: 4026 Could not open /proc/12532/status

I tried to copy the binary in a qemu VM but I don't have the whole system so it don't work.

So , please , what's is the best way to debug a program from a firmware on a different architecture than x86 ?


Solution

  • In qemu user mode, run the program using the command with the option -g:

    sudo chroot . ./qemu-mipsel-static -g 1234 ./pwnable/Intro/stack_bof_01
    

    then start the gdb-multiarch (or gdb that corresponds to that architecture), and attach to it like this:

    target remote 127.0.0.1:1234
    

    then you can debug it happily.