I am trying to run an executable file that I dug out from an extracted file system of a DSL modem router. So first of all I needed to either have a MIPS Linux box or take the emulation path. After some research and effort I got QEMU running a Debian MIPS system with network access and USB support to copy the file in the emulated file system:
qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda debian_squeeze_mips_standard.qcow2 -append "root=/dev/sda1 console=tty0" -net nic -net tap -usb -device usb-host,hostbus=1,hostaddr=8
So I copied the file, changed the rwx
attributes and tried to execute it, but without success
root@debian-mips:~/myfiles/# ./generator
-bash: ./generator: No such file or directory
The file actually exists if I list the contents of the directory. After that I did notice some missing libraries :
root@debian-mips:~/myfiles# ldd generator
libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x2aaad000)
libc.so.0 => not found
libd1.so.2 => /lib/libd1.so.2 (0x2ac2d000)
libz.so.1 => /usr/lib/libz.so.1 (0x2ac41000)
libc.so.6 => /lib/libc.so.6 (0x2ac67000)
/lib/ld-uClibc.so.0 => /lib/ld.so.1 (0x55550000)
So I copied the missing libc.so.0
from the extracted router firmware files:
cp libc.so.0 /usr/lib
Then there was another missing file:
root@debian-mips:~/myfiles# ldd generator
libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x2aaad000)
libc.so.0 => /usr/lib/libc.so.0 (0x2ac2d00)
libd1.so.2 => /lib/libd1.so.2 (0x2ac8f000)
libz.so.1 => /usr/lib/libz.so.1 (0x2aca3000)
libc.so.6 => /lib/libc.so.6 (0x2acc9000)
/lib/ld-uClibc.so.0 => /lib/ld.so.1 (0x55550000)
ld-uClibc.so.0 => not found
Copied it again from the router extracted firmware:
cp ld-uClibc.so.0 /usr/lib
Everything seemed OK at this point:
root@debian-mips:~/myfiles# ldd generator
libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x2aaad000)
libc.so.0 => /usr/lib/libc.so.0 (0x2ac2d00)
libd1.so.2 => /lib/libd1.so.2 (0x2ac8f000)
libz.so.1 => /usr/lib/libz.so.1 (0x2aca3000)
libc.so.6 => /lib/libc.so.6 (0x2acc9000)
ld-uClibc.so.0 => /usr/lib/ld-uClibc,so,0 (0x2ae4b000)
/lib/ld-uClibc.so.0 => /lib/ld.so.1 (0x55550000)
However, I am still unable to execute the file. Some additional info about it:
root@debian-mips:~/myfiles# file generator
generator: ELF 32-bit MSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked (uses shared libs), stripped
I did mess around a bit more with the library files deleting those i copied and tried something like this :
ln -s /lib/libc.so.6 /lib/libc.so.0
root@debian-mips:~/myfiles# ldd generator
libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x2aaad000)
libc.so.0 => /lib/libc.so.0 (0x2ac2d000)
libd1.so.2 => /lib/libd1.so.2 (0x2adaf000)
libz.so.1 => /usr/lib/libz.so.1 (0x2adc3000)
/lib/ld-uClibc.so.0 => /lib/ld.so.1 (0x55550000)
Still the same disappointing "no such file or directory message"... Any kind of help would be appreciated cause it feels like a dead end after all this...
@ SYS_V It appear that the Debian Mips distro didnt have strace and apt-get install was failing. I had to manually find it and dpkg it so after all that gives :
[11036.872000] ------------[ cut here ]------------
[11036.884000] WARNING: at /build/linux-2.6-KrPu_f/linux-2.6-2.6.32/debian/build/source_mips_none/kernel/sched.c:2628 wake_up_process+0x48/0x50()
[11036.904000] Modules linked in: ipv6 loop mtdchar uhci_hcd ehci_hcd cfi_cmdset_0001 cfi_probe gen_probe cfi_util sg physmap mtd psmouse i2c_piix4 usbcore se_mood chipreg serio_raw evdev map_funcs nls_base cdrom i2c_core
[11037.180000] Call Trace:
[11037.196000] [<8010bb24>] dump_stack+0x8/0x34
[11037.208000] [<80138a10>] warn_slowpath_common+0x70/0xb0
[11037.216000] [<8013534c>] wake_up_process+0x48/0x50
[11037.232000] [<801116ac>] arch_ptrace+0x214/0x770
[11037.244000] [<801457e8>] sys_ptrace+0x9c/0x260
[11037.256000] [<80102210>] stack_done+0x20/0x3c
[11037.268000]
[11037.280000] ---[ end trace a7daf16cd1f695f3 ]---
[11823.624000] CE: MIPS Increasing min_delta_ns to 51830 nsec
[11823.624000] CE: MIPS Increasing min_delta_ns to 77744 nsec
and prompts right there infinitely and needs ctrl+c to return to linux prompt.
strace ./generator
?