Skip to content

Instantly share code, notes, and snippets.

@defparam
Last active October 30, 2025 10:21
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.

Revisions

  1. defparam revised this gist Feb 28, 2023. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions flexdump
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/bin/bash
    # Copyright 2021 Evan Custodio (@defparam)
    # 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,
    @@ -62,20 +62,20 @@ elif [ "$1" == "dump" ]; then
    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"
    flexdecrypt file "$j" &> /dev/null
    echo "[+] Decrypting: $j"
    flexdecrypt2 "$j" &> /dev/null
    mv "/tmp/$(basename "$j")" "${TEMPDIR}/Payload/$j"
    #echo "[+] Self-signing: $j"
    echo "[+] Self-signing: $j"
    ldid -S "${TEMPDIR}/Payload/$j"
    fi
    done
    done
    echo "[+] Packaging final IPA file..."
    cd "${TEMPDIR}"
    mkdir -p "/var/mobile/Documents/Flexdump"
    zip -qr /var/mobile/Documents/Flexdump/"$OUTFILE" ./Payload
    mkdir -p "/var/root/dump"
    zip -qr /var/root/dump/"$OUTFILE" ./Payload
    rm -rf "${TEMPDIR}"
    echo "[+] Generated: /var/mobile/Documents/Flexdump/$OUTFILE"
    echo "[+] Generated: /var/root/dump/$OUTFILE"
    fi
    done
    echo "[+] Done!"
  2. defparam created this gist Jun 17, 2021.
    89 changes: 89 additions & 0 deletions flexdump
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    #!/bin/bash
    # Copyright 2021 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"
    flexdecrypt file "$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/mobile/Documents/Flexdump"
    zip -qr /var/mobile/Documents/Flexdump/"$OUTFILE" ./Payload
    rm -rf "${TEMPDIR}"
    echo "[+] Generated: /var/mobile/Documents/Flexdump/$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