Skip to content

Instantly share code, notes, and snippets.

@0xallie
Last active December 18, 2022 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xallie/a812b1fecd3e95646fe524e7b0b28f85 to your computer and use it in GitHub Desktop.
Save 0xallie/a812b1fecd3e95646fe524e7b0b28f85 to your computer and use it in GitHub Desktop.
Decrypt app on a jailbroken iDevice
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "ERROR: Missing argument." >&2
echo "Usage: $0 --list|<name>"
exit 1
fi
if [ "$#" -gt 1 ]; then
echo "ERROR: Too many arguments." >&2
echo "Usage: $0 --list|<name>"
exit 1
fi
for cmd in awk plutil zip; do
if ! [ -x "$(command -v "$cmd")" ]; then
echo "ERROR: $cmd not found." >&2
exit 1
fi
done
if [ "$1" = "--list" ]; then
echo /var/containers/Bundle/Application/*/*.app | tr ' ' '\n' | awk -F/ '{ print $NF }' | sed 's/\.app$//' | sort
exit
fi
for bundle in /var/containers/Bundle/Application/*/"$1".app; do
echo "Processing: $bundle"
cd "$(mktemp -d)"
start=$SECONDS
cp -r "$bundle/.." Payload
#find "$bundle" -type f -executable | while read -r bin; do
for bin in "$bundle/$1"; do
echo "Decrypting: $bin"
relpath=${bin%/*.app}
output="Payload/$1.app/$relpath"
if [ -x "$(command -v fouldecrypt)" ]; then
if [ -x "$(command -v sudo)" ]; then
sudo fouldecrypt "$bin" "$relpath"
else
su root -c "fouldecrypt \"$bin\" \"$relpath\""
fi
elif [ -x "$(command -v flexdecrypt)" ]; then
if [ -x "$(command -v sudo)" ]; then
sudo flexdecrypt "$bin" --output "$output"
else
su root -c "flexdecrypt \"$bin\" --output \"$relpath\""
fi
else
echo "ERROR: No decryption tools found, please install fouldecrypt or flexdecrypt." >&2
exit 1
fi
done
bundleid=$(plutil -key CFBundleIdentifier "$bundle/Info.plist")
version=$(plutil -key CFBundleShortVersionString "$bundle/Info.plist")
ipa="/var/mobile/Documents/${bundleid}_${version}.ipa"
echo "Zipping: $ipa"
zip -FS -r "$ipa" Payload >/dev/null
rm -rf "$(realpath .)"
echo "Completed in $((SECONDS - start))s"
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment