日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

qemu模拟armlinux执行目标文件系统的可执行文件

發布時間:2025/3/19 linux 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 qemu模拟armlinux执行目标文件系统的可执行文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

--------------------以下是2020年更新的內容

不需要自己編譯qemu,直接apt安裝一個靜態編譯版本的qemu apt install qemu-user-static進入解包的arm固件root,并復制一個qemu副本 cd ~/squashfs-root cp /usr/bin/qemu-arm-static ./chroot切換root模式運行qemu-arm-static,并模擬運行rootfs的/usr/bin/lua chroot . ./qemu-arm-static /usr/bin/lua Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio (double int32) security >成功了

--------------------以下是第一次寫的內容

squashfs
yum install -y xz-devel
wget https://jaist.dl.sourceforge.net/project/squashfs/squashfs/squashfs4.3/squashfs4.3.tar.gz
tar xzvf squashfs4.3.tar.gz
cd squashfs4.3/squashfs-tools
vi Makefile
有一些support是可以打開的例如 LZMA1 LZMA2之類的
make
make install


cd ~/
unsquash rootfs.bin
cd squash-root
cp /usr/local/bin/qemu-arm* ./


[root@centos squashfs-root]# ./bin/aescrypt2?
-bash: ./bin/aescrypt2: cannot execute binary file
[root@centos squashfs-root]# chroot . ./qemu-arm ./bin/aescrypt2?


? aescrypt2 <mode> <input filename> <output filename>


? <mode>: 0 = encrypt, 1 = decrypt


? example: aescrypt2 0 file file.aes

很屌。。qemu模擬了armlinux環境執行了這個嵌入式文件系統的elf可執行文件

?

?



下面是mount jffs2文件系統的腳本 mountjffs2.sh
#!/bin/bash


## Script to mount jffs2 filesystem using mtd kernel modules.
## EMAC, Inc. 2009


if [[ $# -lt 2 ]]
then
? ? echo "Usage: $0 FSNAME.JFFS2 MOUNTPOINT [ERASEBLOCK_SIZE]"
? ? exit 1
fi


if [ "$(whoami)" != "root" ]
then
? ? echo "$0 must be run as root!"
? ? exit 1
fi


if [[ ! -e $1 ]]
then
? ? echo "$1 does not exist"
? ? exit 1
fi


if [[ ! -d $2 ]]
then
? ? echo "$2 is not a valid mount point"
? ? exit 1
fi


if [[ "$3" == "" ]]
then
? ? ? ? esize="128"
else
? ? ? ? esize="$3"
fi


# cleanup if necessary
umount /dev/mtdblock0 &>/dev/null
modprobe -r mtdram &>/dev/null
modprobe -r mtdblock &>/dev/null


modprobe mtdram total_size=32768 erase_size=$esize || exit 1
modprobe mtdblock || exit 1
dd if="$1" of=/dev/mtdblock0 || exit 1
mount -t jffs2 /dev/mtdblock0 $2 || exit 1


echo "Successfully mounted $1 on $2"
exit 0




[root@centos ~]# ./mountjffs2.sh?
Usage: ./mountjffs2.sh FSNAME.JFFS2 MOUNTPOINT [ERASEBLOCK_SIZE]
[root@centos ~]# mkdir /mnt/jffs2
[root@centos ~]# ./mountjffs2.sh? file_system.img? /mnt/jffs2 128
3072+0 records in
3072+0 records out
1572864 bytes (1.6 MB) copied, 0.0215566 s, 73.0 MB/s
Successfully mounted file_system.img on /mnt/jffs2


[root@centos squashfs-root]# cp /mnt/jffs2/hw_ctree.xml ./hw_ctree.xml.gz
[root@centos squashfs-root]# chroot . ./qemu-arm ./bin/aescrypt2 1 ./hw_ctree.xml.gz ./tmpfile
[root@centos squashfs-root]# gunzip hw_ctree.xml.gz?
[root@centos squashfs-root]# cat hw_ctree.xml

總結

以上是生活随笔為你收集整理的qemu模拟armlinux执行目标文件系统的可执行文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。