nongiach / arm_now

arm_now is a qemu powered tool that allows instant setup of virtual machines on arm cpu, mips, powerpc, nios2, x86 and more, for reverse, exploit, fuzzing and programming purpose.
https://github.com/nongiach/arm_now/wiki
MIT License
867 stars 87 forks source link

mips64-n32 failed to start #14

Open bannsec opened 6 years ago

bannsec commented 6 years ago

Attempting to use mips64-n32, i get the following:

arm_now start mips64-n32
(use --clean next time) An aarch64 image exists, delete ? (y/n) y

Downloading /root/.config/arm_now/templates/mips64-n32.tar.xz from https://github.com/nongiach/arm_now_templates/raw/master/mips64-n32.tar.xz                                                                                                                                                                                  [*] 1.4 MB / 1.4 MB @ 3.0 MB/s [##################] [100%, 0s left]
[+] Installed
Tempdir /tmp/tmpuk8185gs
File not found by ext2_lookup
WARNING: e2rm file already suppressed
Starting qemu-system-mips64
stty intr ^]
       export QEMU_AUDIO_DRV="none"
       qemu-system-mips64 -kernel arm_now/kernel -hda arm_now/rootfs.ext2 -append 'root=/dev/hda console=ttyS0 rw physmap.enabled=0 noapic'                -m 256M                -nographic                -serial stdio -monitor /dev/null                                  -no-reboot
       stty intr ^c

WARNING: Image format was not specified for 'arm_now/rootfs.ext2' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
qemu-system-mips64: qemu: could not load kernel 'arm_now/kernel': Failed to load ELF
+++++++++++++++++++++++++++ Checking the filesystem ++++++++++++++++++++++++++++
e2fsck 1.44.1 (24-Mar-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

         397 inodes used (1.59%, out of 24960)
           0 non-contiguous files (0.0%)
           1 non-contiguous directory (0.3%)
             # of inodes with ind/dind/tind blocks: 19/4/0
        9061 blocks used (8.85%, out of 102400)
           0 bad blocks
           0 large files

          60 regular files
          41 directories
           1 character device file
           0 block device files
           0 fifos
           0 links
         286 symbolic links (286 fast symbolic links)
           0 sockets
------------
         388 files
mingfure commented 5 years ago

I met the same issue,have you solved this?

dcommander commented 5 years ago

+1

enkiusz commented 4 years ago

The kernel file downloaded by the script from https://github.com/nongiach/arm_now_templates/blob/master/mips64-n32.tar.xz is an empty file:

(default) ➜  _M4000_SIP_F7.20A.258.119.cmp.extracted wget https://github.com/nongiach/arm_now_templates/blob/master/mips64-n32.tar.xz\?raw\=true
--2020-09-25 11:07:43--  https://github.com/nongiach/arm_now_templates/blob/master/mips64-n32.tar.xz?raw=true
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github.com/nongiach/arm_now_templates/raw/master/mips64-n32.tar.xz [following]
--2020-09-25 11:07:43--  https://github.com/nongiach/arm_now_templates/raw/master/mips64-n32.tar.xz
Reusing existing connection to github.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/nongiach/arm_now_templates/master/mips64-n32.tar.xz [following]
--2020-09-25 11:07:43--  https://raw.githubusercontent.com/nongiach/arm_now_templates/master/mips64-n32.tar.xz
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.112.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.112.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1467500 (1.4M) [application/octet-stream]
Saving to: 'mips64-n32.tar.xz?raw=true'

mips64-n32.tar.xz?raw=true                 100%[========================================================================================>]   1.40M  5.48MB/s    in 0.3s

2020-09-25 11:07:43 (5.48 MB/s) - 'mips64-n32.tar.xz?raw=true' saved [1467500/1467500]

(default) ➜  _M4000_SIP_F7.20A.258.119.cmp.extracted mv mips64-n32.tar.xz\?raw=true mips64-n32.tar.xz
(default) ➜  _M4000_SIP_F7.20A.258.119.cmp.extracted tar -xJvf mips64-n32.tar.xz
arm_now/
arm_now/rootfs.ext2
arm_now/kernel
arm_now/arch
(default) ➜  _M4000_SIP_F7.20A.258.119.cmp.extracted ls -lh arm_now
total 101M
-rw-r--r-- 1 enki enki   10 Jun  3  2018 arch
-rw-r--r-- 1 enki enki    0 Jun  3  2018 kernel
-rw-r--r-- 1 enki enki 100M Jun  3  2018 rootfs.ext2
(default) ➜  _M4000_SIP_F7.20A.258.119.cmp.extracted

When you specify --real-source it downloads the proper kernel from bootlin:

(default) ➜  _M4000_SIP_F7.20A.258.119.cmp.extracted arm_now install --real-source mips64-n32
Scrawling kernel for arch 'mips64-n32'
Kernel=https://toolchains.bootlin.com/downloads/releases/toolchains/mips64-n32/test-system/mips64-n32--glibc--stable-2020.02-2-vmlinux, DTB=None, rootfs=https://toolchains.bootlin.com/downloads/releases/toolchains/mips64-n32/test-system/mips64-n32--glibc--stable-2020.02-2-rootfs.ext2

Downloading arm_now/kernel from https://toolchains.bootlin.com/downloads/releases/toolchains/mips64-n32/test-system/mips64-n32--glibc--stable-2020.02-2-vmlinux
 [*] 8.2 MB / 8.2 MB @ 2.6 MB/s [##################] [100%, 0s left]

Downloading arm_now/rootfs.ext2 from https://toolchains.bootlin.com/downloads/releases/toolchains/mips64-n32/test-system/mips64-n32--glibc--stable-2020.02-2-rootfs.ext2
 [*] 60.0 MB / 60.0 MB @ 1.8 MB/s [##################] [100%, 0s left]
[+] Installed
(default) ➜  _M4000_SIP_F7.20A.258.119.cmp.extracted ls -lh arm_now
total 69M
-rw-rw-r-- 1 enki enki   10 Sep 25 11:09 arch
-rw-rw-r-- 1 enki enki 8.2M Sep 25 11:08 kernel
-rw-rw-r-- 1 enki enki  60M Sep 25 11:09 rootfs.ext2

and boots correctly:

(default) ➜  _M4000_SIP_F7.20A.258.119.cmp.extracted arm_now start mips64-n32
WARNING: arm_now/ already exists, use --clean to restart with a fresh filesystem
Tempdir /tmp/tmpm636kpn5
File not found by ext2_lookup
WARNING: e2rm file already suppressed
Starting qemu-system-mips64
stty intr ^]
       export QEMU_AUDIO_DRV="none"
       qemu-system-mips64 -kernel arm_now/kernel -hda arm_now/rootfs.ext2 -append 'root=/dev/hda console=ttyS0 rw physmap.enabled=0 noapic'                -m 256M                -nographic                -serial stdio -monitor null  -nic user                                 -no-reboot
       stty intr ^c

WARNING: Image format was not specified for 'arm_now/rootfs.ext2' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
Linux version 4.19.91 (root@runner-37d48167-project-3290221-concurrent-2) (gcc version 8.4.0 (Buildroot 2020.02-00011-g7ea8a52)) #1 SMP Sat Apr 4 23:30:09 UTC 2020
earlycon: uart8250 at I/O port 0x3f8 (options '38400n8')

[...]

Saving random seed: random: dd: uninitialized urandom read (512 bytes read)
OK
pcnet32 0000:00:0b.0 eth0: link up
press ctrl+] to kill qemu

Welcome to arm_now
buildroot login: root
# uname -m
mips64

The https://github.com/nongiach/arm_now_templates/blob/master/mips64-n32.tar.xz should be rebuilt to properly fix this.

SakiiR commented 4 years ago

Congrats, you found the issue 👍

What about you introduce a fix via a pull request ? :)