Challenge pwn5 is about exploiting simple buffer overflow in statically linked mipsel binary. Running binary on x86 system requires using qemu in user mode that allows executing non-native target executable through emulation.
To interact with binary we will use qemu:
The idea for exploitation is to read shellcode to bss area and then execute it directly from there. In order to do that we need to launch scanf with the buffer pointing to bss area - that address should be stored in a1.
We can jump to 0x00400758 that will move v0 to a1 thus we need control over v0 register. That can be achieved by using following gadget:
Using found gadget we can craft payload that will set v0 with the address of bss area and jump to 0x00400758 that will follow with scanf and reading additional input.
Last step is to send payload that consists of the shellcode (it will be written into bss area) and address of the shellcode (it will overwrite return address at offest 348).