2

I'm trying to emulate a MIPS binary on my Ubuntu 16.04 x86 system, but I'm not able to. I chroot into the squashfs-root filesystem that I got from binwalking the firmware image.

kan3k1@kaido:~/firmware/_firmware.bin.extracted/squashfs-root$ ls -l
total 3092
drwxr-xr-x 2 kan3k1 kan3k1    4096 Mar 18  2018 bin
drwxr-xr-x 5 kan3k1 kan3k1    4096 Mar 18  2018 dev
drwxr-xr-x 5 kan3k1 kan3k1    4096 Mar 18  2018 etc
drwxr-xr-x 3 kan3k1 kan3k1    4096 Mar 18  2018 lib
lrwxrwxrwx 1 kan3k1 kan3k1      11 Mar 18  2018 linuxrc -> bin/busybox
drwxr-xr-x 2 kan3k1 kan3k1    4096 Mar 18  2018 mnt
drwxr-xr-x 2 kan3k1 kan3k1    4096 Mar 18  2018 proc
-rwxr-xr-x 1 kan3k1 kan3k1 3120160 Dec 17 01:07 qemu-mips-static
drwxr-xr-x 2 kan3k1 kan3k1    4096 Mar 18  2018 sbin
drwxr-xr-x 2 kan3k1 kan3k1    4096 Mar 18  2018 sys
drwxr-xr-x 4 kan3k1 kan3k1    4096 Mar 18  2018 usr
drwxr-xr-x 2 kan3k1 kan3k1    4096 Mar 18  2018 var
drwxr-xr-x 9 kan3k1 kan3k1    4096 Mar 18  2018 web

kan3k1@kaido:~/firmware/_firmware.bin.extracted/squashfs-root$ sudo chroot . ./qemu-mips-static ./bin/ls
./bin/ls: Invalid ELF image for this architecture

kan3k1@kaido:~/firmware/_firmware.bin.extracted/squashfs-root$ sudo chroot . ./qemu-mips-static ./bin/busybox 
./bin/busybox: Invalid ELF image for this architecture

kan3k1@kaido:~/firmware/_firmware.bin.extracted/squashfs-root$ file bin/ls
bin/ls: symbolic link to busybox
kan3k1@kaido:~/firmware/_firmware.bin.extracted/squashfs-root$ file bin/busybox 
bin/busybox: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped

kan3k1@kaido:~/firmware/_firmware.bin.extracted/squashfs-root$ rabin2 -I ./bin/ls
arch     mips
baddr    0x400000
binsz    260852
bintype  elf
bits     32
canary   false
class    ELF32
crypto   false
endian   little
havecode true
intrp    /lib/ld-uClibc.so.0
laddr    0x0
lang     c
linenum  false
lsyms    false
machine  MIPS R3000
maxopsz  16
minopsz  1
nx       false
os       linux
pcalign  0
pic      false
relocs   false
relro    no
rpath    NONE
sanitiz  false
static   false
stripped true
subsys   linux
va       true

kan3k1@kaido:~/firmware/_firmware.bin.extracted/squashfs-root$ rabin2 -I ./bin/busybox 
arch     mips
baddr    0x400000
binsz    260852
bintype  elf
bits     32
canary   false
class    ELF32
crypto   false
endian   little
havecode true
intrp    /lib/ld-uClibc.so.0
laddr    0x0
lang     c
linenum  false
lsyms    false
machine  MIPS R3000
maxopsz  16
minopsz  1
nx       false
os       linux
pcalign  0
pic      false
relocs   false
relro    no
rpath    NONE
sanitiz  false
static   false
stripped true
subsys   linux
va       true

My system info:

kan3k1@kaido:~/firmware/_firmware.bin.extracted/squashfs-root$ uname -a
Linux kaido 4.15.0-29-generic #31~16.04.1-Ubuntu SMP Wed Jul 18 10:19:08 UTC 2018 i686 i686 i686 GNU/Linux

Any idea on how to resolve this? All the resources that I was able to find online have something to do with .so files causing the error.

1 Answer 1

1

It seems your binaries are little-endian, so you neeed qemu-mipsel.

1
  • Got it! sudo chroot . ./qemu-mipsel-static bin/ls worked. Thanks! Dec 17, 2019 at 13:06

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.