Created
August 13, 2022 17:54
-
-
Save 0xca7/33916013f07815461108cfe28f6a51b9 to your computer and use it in GitHub Desktop.
script to create fake flash drive and mount a JFFS2 image to it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# change this if needed | |
TOTAL_RAM_SIZE=32768 | |
ERASE_SIZE=256 | |
# just the usage prompt | |
print_usage() { | |
echo "usage ./mount_jffs2.sh [ path to image ]" | |
echo "RUN THIS WITH SUDO / AS ROOT" | |
} | |
echo "[+] this script creates a fake flash drive" | |
echo " and mounts a JFFS2 image to it." | |
# check if arg was supplied | |
if [ "$#" -ne 1 ]; then | |
print_usage | |
exit 1 | |
fi | |
# check if root perms | |
if [ "$EUID" -ne 0 ]; then | |
print_usage | |
exit 1 | |
fi | |
echo "[+] modprobe mtdram and mtdblock" | |
# mtdram - simulates NOR flash in RAM | |
# mtdblock - presents flash memory as a block device you can use to | |
# format and mount as a filesystem | |
modprobe mtdram total_size=$TOTAL_RAM_SIZE erase_size=$ERASE_SIZE | |
modprobe mtdblock | |
echo "[+] created /mnt/disk to mount to" | |
mkdir -p /mnt/disk | |
echo "[+] using dd to write image to /dev/mtdblock0" | |
dd if=$1 of=/dev/mtdblock0 | |
echo "[+] mounting image to /mnt/disk" | |
mount -t jffs2 /dev/mtdblock0 /mnt/disk | |
echo "[+] done, see /mnt/disk:" | |
ls -l /mnt/disk% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment