Skip to content

Instantly share code, notes, and snippets.

@DzMohaipa
Forked from jakeajames/patch.sh
Created November 16, 2019 21:53
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 DzMohaipa/454366b0e7224db891287c108d0bc8e8 to your computer and use it in GitHub Desktop.
Save DzMohaipa/454366b0e7224db891287c108d0bc8e8 to your computer and use it in GitHub Desktop.
Make h3lix work when installed not-via-Impactor. To be used with the latest h3lix.
if [ $# != 2 ]; then
echo "Usage: $0 /path/to/input_ipa /path/to/output_ipa"
exit 1
fi
if ! [ -f $1 ]; then
echo "'$1' does not exist"
exit 1
fi
if [ -f $2 ]; then
echo "'$2' already exists"
exit 1
fi
echo "Setting up environment"
mkdir /tmp/unpacked_h3lix
if [ $? != 0 ]; then
echo "mkdir create temporary directory"
exit 1
fi
echo "Extracting"
unzip $1 -d /tmp/unpacked_h3lix > /dev/null
if [ $? != 0 ]; then
echo "can't unzip '$1'"
rm -rf /tmp/unpacked_h3lix
exit 1
fi
echo "Patching"
# tada tada P\WX+1y~~z??ti.....
(printf '\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11' | dd of=/tmp/unpacked_h3lix/Payload/h3lix.app/h3lix bs=1 seek=30848 count=20 conv=notrunc) 2> /dev/null
(printf '\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11' | dd of=/tmp/unpacked_h3lix/Payload/h3lix.app/h3lix bs=1 seek=32920 count=20 conv=notrunc) 2> /dev/null
# i DoN'T hAz CS_GET_TASK_ALLOW?!?!??
(printf '\x00\x00\x00\x00' | dd of=/tmp/unpacked_h3lix/Payload/h3lix.app/h3lix bs=1 seek=31790 count=4 conv=notrunc) 2> /dev/null
# DeBuG Br34K
(printf '\x70\x47' | dd of=/tmp/unpacked_h3lix/Payload/h3lix.app/h3lix bs=1 seek=40800 count=2 conv=notrunc) 2> /dev/null
echo "Compressing"
CD=$(pwd)
cd /tmp/unpacked_h3lix
if [[ "$2" = /* ]]; then
zip -r $2 Payload/ > /dev/null
else
zip -r "$CD/$2" Payload/ > /dev/null
fi
if [ $? != 0 ]; then
echo "can't zip '$1'"
rm -rf /tmp/unpacked_h3lix
cd - > /dev/null
exit 1
fi
cd - > /dev/null
rm -rf /tmp/unpacked_h3lix
echo "Done"
exit 0
@jirayutza1
Copy link

if [ $# != 2 ]; then
echo "Usage: $0 /path/to/input_ipa /path/to/output_ipa"
exit 1
fi

if ! [ -f $1 ]; then
echo "'$1' does not exist"
exit 1
fi

if [ -f $2 ]; then
echo "'$2' already exists"
exit 1
fi

echo "Setting up environment"
mkdir /tmp/unpacked_h3lix
if [ $? != 0 ]; then
echo "mkdir create temporary directory"
exit 1
fi

echo "Extracting"
unzip $1 -d /tmp/unpacked_h3lix > /dev/null
if [ $? != 0 ]; then
echo "can't unzip '$1'"
rm -rf /tmp/unpacked_h3lix
exit 1
fi

echo "Patching"

tada tada P\WX+1y~~z??ti.....

(printf '\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11' | dd of=/tmp/unpacked_h3lix/Payload/h3lix.app/h3lix bs=1 seek=30848 count=20 conv=notrunc) 2> /dev/null
(printf '\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11' | dd of=/tmp/unpacked_h3lix/Payload/h3lix.app/h3lix bs=1 seek=32920 count=20 conv=notrunc) 2> /dev/null

i DoN'T hAz CS_GET_TASK_ALLOW?!?!??

(printf '\x00\x00\x00\x00' | dd of=/tmp/unpacked_h3lix/Payload/h3lix.app/h3lix bs=1 seek=31790 count=4 conv=notrunc) 2> /dev/null

DeBuG Br34K

(printf '\x70\x47' | dd of=/tmp/unpacked_h3lix/Payload/h3lix.app/h3lix bs=1 seek=40800 count=2 conv=notrunc) 2> /dev/null

echo "Compressing"

CD=$(pwd)
cd /tmp/unpacked_h3lix

if [[ "$2" = /* ]]; then
zip -r $2 Payload/ > /dev/null
else
zip -r "$CD/$2" Payload/ > /dev/null
fi

if [ $? != 0 ]; then
echo "can't zip '$1'"
rm -rf /tmp/unpacked_h3lix
cd - > /dev/null
exit 1
fi

cd - > /dev/null
rm -rf /tmp/unpacked_h3lix
echo "Done"
exit 0

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