Last active
May 27, 2023 07:42
-
-
Save theonewolf/0a700ac24d0c1d7e016f to your computer and use it in GitHub Desktop.
Make Android-like ext4 File System for gammaray testing
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
#!/usr/bin/bash | |
truncate -s 0 ext4-match-android.raw | |
truncate -s 14540582912 ext4-match-android.raw | |
echo '' | |
echo 'Create a Single Primary Partition w/ Defaults' | |
read | |
sfdisk ext4-match-android.raw << EOF | |
# partition table of ext4-match-android.raw | |
unit: sectors | |
ext4-match-android.raw1 : start= 2048, size= 28397528, Id=83 | |
ext4-match-android.raw2 : start= 0, size= 0, Id= 0 | |
ext4-match-android.raw3 : start= 0, size= 0, Id= 0 | |
ext4-match-android.raw4 : start= 0, size= 0, Id= 0 | |
EOF | |
sudo kpartx -av ext4-match-android.raw | |
sudo mkfs.ext4 \ | |
-m 0 \ | |
-M '/data' \ | |
-O none,has_journal,ext_attr,resize_inode,filetype,sparse_super,large_file,uninit_bg,extent \ | |
-U '57f8f4bc-abf4-655f-bf67-946fc0f9f25b' \ | |
/dev/mapper/loop0p1 | |
sudo tune2fs \ | |
-E hash_alg=tea \ | |
-e remount-ro \ | |
-o \^user_xattr,\^acl \ | |
-C 108 \ | |
/dev/mapper/loop0p1 | |
sudo mkdir -p /data | |
sudo mount /dev/mapper/loop0p1 /data | |
# create some number of files to more closely match Android case | |
for i in {1..36164} | |
do | |
sudo touch /data/$i | |
done | |
# try to closely match used blocks | |
sudo dd if=/dev/zero of=/data/1 bs=4096 count=396647 | |
#sudo umount /data | |
echo '' | |
echo 'Finished Creating Fake Android File System in: ext4-match-android.raw' | |
echo 'Press ENTER for Sanity Check' | |
read | |
sudo tune2fs -l /dev/mapper/loop0p1 | |
echo '' | |
echo 'Press ENTER to run gammaray' | |
read | |
/home/bamos/repos/gammaray-gpt/bin/gray-crawler ext4-match-android.raw ext4-match-android.bson | |
echo '' | |
echo 'Press ENTER to examine gammaray BSON' | |
read | |
/home/bamos/repos/gammaray-gpt/bin/tools/bson-printer ext4-match-android.bson | less -R | |
sudo umount /data | |
sudo kpartx -dv ext4-match-android.raw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment