-
The App Store package is
加壳
encrypted, you need to decrypt and unpack it before resigning (Itunes 12.6.3 can download the genuine App ipa package, there is a link at the end of the article)- Decryption method, generally when running from the real machine, dump the decrypted package from the memory
- Check whether the app executable file is encrypted, use otool -l weChat|grep cryptid
- cryptid 0 //0 is not encrypted, 1 encryption method 1, 2 encryption method 2
-
View signature information
###查看签名信息
###dir ==> /Payload (当前目录) /WeChat.app/WeChat
#codesign -d -vv WeChat.app
- Find locally available signing certificates
#security find-identity -v -p codesigning
- If there is a plug-in, you can delete the plug-in (plug-in, watch, normal development account, signature can't be done)
- Re-signature, executable files (requires
可执行权限
chmod +x) and all frameworks are required
###dir ==> /Payload/WeChat.app(当前目录)/WeChat
#codesign -fs "上一步的证书名称" 签名文件或framwork
-
Description file
- Directly create a new project, select real machine-compile, and find embedded.mobileprovision in the compiled package
- Copy the description file to WeChat.app in the WeChat package
- Modify the bundleid of WeChat Info.plist to the bundleid of the first step
-
Permission file
- Use the command: #security cms -D -i embedded.mobileprovision After displaying, find the Entitlements field (security cms -D -i embedded.mobileprovision> embedded.plist)
- In the xcode project, create a new property file and copy the contents of the previous step (command export: /usr/libexec/PlistBuddy -x -c'Print:Entitlements' embedded.plist> entitlements.plist)
- Save as entitlements.plist //get-task-allow = true allows debugging
- copy entitlements.plist to /Payload/entitlements.plist
-
Signature (--no-strict does not strictly check)
#codesign -fs "证书名称" --no-strict --entitlements=entitlements.plist WeChat.app
##打包
#zip -ry WeChatp.ipa Payload
After re-signing the installation, you can attach to view debug
- Install xcode or other tools to the phone
- In the project created at the step of the description file, Debug-Attach to Process -> wechat
- After the attachment is successful, you can click view debug for dynamic debugging
Use xcode to directly re-sign the debug operation
- Unzip the package, and clean up unused plugins, etc.
- Sign the framework and back up the processed package
- Create a new project with the same name (WeChat), and compile it under the real machine target
- Open the compiled WeChat.app and replace it with the package processed in the previous step
- Run to install to the real machine, and run
Script, xcode directly resign
- Create a new project and run it again on the real machine
- Add ${SRCROOT}/appsign.sh in Build Phases-Run Script
- Just run
PS shell script
- $source filename //Generally used to execute configuration files, the environment will take effect immediately
- $bash filename //default, recommended
- $csh/ksh/sh/tcsh filename // cat /etc/shells can see which shells you have
##appsign.sh
# ${SRCROOT} 它是工程文件所在的目录
TEMP_PATH="${SRCROOT}/Temp"
#资源文件夹,我们提前在工程目录下新建一个APP文件夹,里面放ipa包
ASSETS_PATH="${SRCROOT}/APP"
#目标ipa包路径
TARGET_IPA_PATH="${ASSETS_PATH}/*.ipa"
#清空Temp文件夹
rm -rf "${SRCROOT}/Temp"
mkdir -p "${SRCROOT}/Temp"
#----------------------------------------
# 1. 解压IPA到Temp下
unzip -oqq "$TARGET_IPA_PATH" -d "$TEMP_PATH"
# 拿到解压的临时的APP的路径
TEMP_APP_PATH=$(set -- "$TEMP_PATH/Payload/"*.app;echo "$1")
# echo "路径是:$TEMP_APP_PATH"
#----------------------------------------
# 2. 将解压出来的.app拷贝进入工程下
# BUILT_PRODUCTS_DIR 工程生成的APP包的路径
# TARGET_NAME target名称
TARGET_APP_PATH="$BUILT_PRODUCTS_DIR/$TARGET_NAME.app"
echo "app路径:$TARGET_APP_PATH"
rm -rf "$TARGET_APP_PATH"
mkdir -p "$TARGET_APP_PATH"
cp -rf "$TEMP_APP_PATH/" "$TARGET_APP_PATH"
#----------------------------------------
# 3. 删除extension和WatchAPP.个人证书没法签名Extention
rm -rf "$TARGET_APP_PATH/PlugIns"
rm -rf "$TARGET_APP_PATH/Watch"
#----------------------------------------
# 4. 更新info.plist文件 CFBundleIdentifier
# 设置:"Set : KEY Value" "目标文件路径"
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $PRODUCT_BUNDLE_IDENTIFIER" "$TARGET_APP_PATH/Info.plist"
#----------------------------------------
# 5. 给MachO文件上执行权限
# 拿到MachO文件的路径
APP_BINARY=`plutil -convert xml1 -o - $TARGET_APP_PATH/Info.plist|grep -A1 Exec|tail -n1|cut -f2 -d\>|cut -f1 -d\<`
#上可执行权限
chmod +x "$TARGET_APP_PATH/$APP_BINARY"
#----------------------------------------
# 6. 重签名第三方 FrameWorks
TARGET_APP_FRAMEWORKS_PATH="$TARGET_APP_PATH/Frameworks"
if [ -d "$TARGET_APP_FRAMEWORKS_PATH" ];
then
for FRAMEWORK in "$TARGET_APP_FRAMEWORKS_PATH/"*
do
#签名
/usr/bin/codesign --force --sign "$EXPANDED_CODE_SIGN_IDENTITY" "$FRAMEWORK"
done
fi
#---------------------------------------------
# 7.注入我们编写的动态库
echo "开始注入..."
#需要注入的动态库路径 -- 注意这里写死了。今后更改
INJECT_FRAMEWORK_PATH="Frameworks/libhankHookto.dylib"
#通过工具注入
#yololib "$TARGET_APP_PATH/$APP_BINARY" "$INJECT_FRAMEWORK_PATH"
echo "End!脚本执行完毕"
Author: co5der
link: https: //www.jianshu.com/p/736aee2495ed