利用Xcode动态调试第三方APP
2018-04-24 本文已影响64人
呆呆滴木木菇凉
1、新建Xcode项目,项目名要和我们调试的项目名一样
2、添加一个脚本Run Script,这里我的目标App是XJCMClient
Run Script脚本如下:
/opt/iOSOpenDev/bin/iosod ----xcbp
#当前生成目标文件.app的目录
cd ${TARGET_BUILD_DIR}
#赋值不能用空格
bundleid=clf.XJCMClient
teamid="MCC8A54GCE"
targetpath=/Users/clf/Desktop/breakApp/XcodeRun/
appid="${teamid}.${bundleid}"
# 1.copy files
cp -rf ${targetpath}/XJCMClient.app `pwd`
cp ${targetpath}/embedded.mobileprovision ./XJCMClient.app/
rm -rf ./XJCMClient.app/_CodeSignature
chmod +x ./XJCMClient.app/XJCMClient
# 3.replace str
plutil -replace com.apple.developer.team-identifier -string ${teamid} ${targetpath}/entitlements.plist
plutil -replace application-identifier -string ${appid} ${targetpath}/entitlements.plist
plutil -replace CFBundleIdentifier -string ${bundleid} ./XJCMClient.app/Info.plist
# 4.resign
codesign -fs "iPhone Developer: 3183001079@qq.com (MCC8A54GCE)" --no-strict --entitlements=${targetpath}/entitlements.plist ./XJCMClient.app
该脚本实现偷梁换柱
首先将第三方app拷贝替换我们新建工程生成的app
然后对第三方app使用我们的证书进行签名
最后将签名后的第三方app安装至iPhone上
3.点击Debug-->Pause,就可以进入lldb调试
调试利用facebook的工具chisel
1)brew install chisel
2)~/.lldbinit (没有就新建)
3)command script import /path/to/fblldb.py
错误集:
1、X-code运行报错: This application’s application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed.
解决办法: application-identifier冲突,把手机上的软件卸载一下就OK了.