Skip to content

Instantly share code, notes, and snippets.

@defparam
Last active July 24, 2024 01:41
Show Gist options
  • Save defparam/71d67ee738341559c35c684d659d40ac to your computer and use it in GitHub Desktop.
Save defparam/71d67ee738341559c35c684d659d40ac to your computer and use it in GitHub Desktop.
Flexdump - A script that wraps flexdecrypt to dump, decrypt, re-sign, re-package iOS apps
#!/bin/bash
# Copyright 2021-2023 Evan Custodio (@defparam)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
echo " _____ _ _ "
echo " | ___| | _____ ____| |_ _ _ __ ___ _ __ "
echo " | |_ | |/ _ \ \/ / _\` | | | | '_ \` _ \| '_ \ "
echo " | _| | | __/> < (_| | |_| | | | | | | |_) |"
echo " |_| |_|\___/_/\_\__,_|\__,_|_| |_| |_| .__/ "
echo " |_| "
echo ""
echo " by @defparam"
echo ""
if [ "$1" == "list" ]; then
echo "[+] Application List:"
echo "[+] -----------------"
find /private/var/containers/Bundle/Application/ -maxdepth 2 -iname *.app | while read -r app; do
echo "[+] $(basename "$app")"
done
exit 0
elif [ "$1" == "dump" ]; then
if [ $# -ne 2 ]; then
echo "[+] Error: Incorrect number of arguments"
echo "[+] "
echo "[+] flexdump dump <appname> - To decrypt and dump app into IPA"
exit 1
fi
echo "[+] Searching for $2..."
find /private/var/containers/Bundle/Application/ -maxdepth 2 -iname *.app | while read -r appdir; do
if [ "$(basename "$appdir")" == "$2" ]; then
cd $(dirname "$appdir"/)
echo "[+] Found app at: $appdir"
APPNAME="$(basename "$appdir")"
APPNAME="${APPNAME::-4}"
APPNAME="${APPNAME/" "/"_"}"
VERSTR="$(cat "$appdir/Info.plist" | grep -A 1 CFBundleShortVersionString | grep -o '[0-9.]\+')"
if [ -z "$VERSTR" ]; then
VERSTR="0.0.0"
fi
OUTFILE="${APPNAME}_${VERSTR}_fd.ipa"
echo "[+] App name: $APPNAME"
echo "[+] App version: $VERSTR"
TEMPDIR="$(mktemp -d)"
echo "[+] Preparing working directory at: ${TEMPDIR}/Payload"
mkdir -p "${TEMPDIR}/Payload"
echo "[+] Copying application to: ${TEMPDIR}/Payload/$2 , please wait..."
cp -rf "$appdir" "${TEMPDIR}/Payload"
echo "[+] Decrypting and signing binaries..."
find . -type d -name "_CodeSignature" | while read -r i; do
find "$(dirname "$i")" -maxdepth 1 -type f | while read -r j; do
if file "$j" | grep -q "Mach-O"; then
echo "[+] Decrypting: $j"
flexdecrypt2 "$j" &> /dev/null
mv "/tmp/$(basename "$j")" "${TEMPDIR}/Payload/$j"
echo "[+] Self-signing: $j"
ldid -S "${TEMPDIR}/Payload/$j"
fi
done
done
echo "[+] Packaging final IPA file..."
cd "${TEMPDIR}"
mkdir -p "/var/root/dump"
zip -qr /var/root/dump/"$OUTFILE" ./Payload
rm -rf "${TEMPDIR}"
echo "[+] Generated: /var/root/dump/$OUTFILE"
fi
done
echo "[+] Done!"
exit 0
else
echo "[+] Error: Incorrect arguments supplied"
echo "[+] "
echo "[+] flexdump list - To list all installed apps"
echo "[+] flexdump dump <appname> - To decrypt and dump app into IPA"
exit 1
fi
@defparam
Copy link
Author

updated gist to use fouldecrypt (https://github.com/NyaMisty/fouldecrypt)

@Mabdelwanis
Copy link

can be used in rootles ios 15.4.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment