Skip to content

Instantly share code, notes, and snippets.

@ZeevoX
Last active March 10, 2018 23:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeevoX/7bea9deaf9dae4fd1bc307004469833e to your computer and use it in GitHub Desktop.
Save ZeevoX/7bea9deaf9dae4fd1bc307004469833e to your computer and use it in GitHub Desktop.
Unpack Android installable flashable zip files
#!/bin/bash
echo "***********************************************"
echo "* Installable flashable zip content extractor *"
echo "* by ZeevoX *"
echo "***********************************************"
echo "Preparing..."
##############################################
### THIS SCRIPT NEEDS 7ZIP v14+ INSTALLED! ###
##############################################
# To install 7zip
#sudo add-apt-repository -y ppa:eugenesan/ppa > /dev/null
# Refresh repo
# sudo apt-get -qq update
# Check all required dependencies are installed
#command -v 7z >/dev/null 2>&1 || { echo >&2 "I: 7z is not installed but required, installing..."; sudo apt-get -y -q install p7zip p7zip-full; }
# install latest 7zip regardless if installed or not
#sudo apt-get -y -q install p7zip p7zip-full
command -v git >/dev/null 2>&1 || { echo >&2 "I: wget is not installed but required, will install"; sudo apt-get -y -q install git; }
command -v python >/dev/null 2>&1 || { echo >&2 "I: wget is not installed but required, will install"; sudo apt-get -y -q install python; }
command -v unzip >/dev/null 2>&1 || { echo >&2 "I: unzip is not installed but required, will install"; sudo apt-get -y -q install unzip; }
command -v wget >/dev/null 2>&1 || { echo >&2 "I: wget is not installed but required, will install"; sudo apt-get -y -q install wget; }
echo -n "Please enter zip download link: "
read download_link
echo "Processing..."
filename=$(sed 's#.*/##' <<< $download_link)
mkdir ${filename:0:-4}
cd ${filename:0:-4}
#echo $filename
#read -n 1 -s -r -p "Press any key to continue"
echo "Downloading..."
# We use -c to not download the file again if it has already been downloaded or downloaded partially
wget -c $download_link
echo "Extracting raw data..."
unzip -qq $filename system.transfer.list system.new.dat
echo "Downloading conversion tool..."
git clone --quiet https://github.com/xpirt/sdat2img
echo "Converting raw data into disk image..."
python sdat2img/sdat2img.py system.transfer.list system.new.dat ${filename}.img > /dev/null
echo "Cleaning up..."
rm -rf system.transfer.list system.new.dat sdat2img/
echo "Extracting files..."
7z -y -bsp0 -bso0 x ${filename}.img
rm ${filename}.img ${filename}
# -y -bsp0 -bso0
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment