参考文献:免越狱版 iOS 抢红包插件
$ otool -L WeChatRedEnvelopesHelper.dylib
WeChatRedEnvelopesHelper.dylib (architecture armv7):
/Library/MobileSubstrate/DynamicLibraries/WeChatRedEnvelopesHelper.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1450.14.0)
/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation (compatibility version 150.0.0, current version 1450.14.0)
/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
/System/Library/Frameworks/AVFoundation.framework/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
/System/Library/Frameworks/CoreLocation.framework/CoreLocation (compatibility version 1.0.0, current version 2237.0.22)
/System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 3698.33.6)
WeChatRedEnvelopesHelper.dylib (architecture arm64):
/Library/MobileSubstrate/DynamicLibraries/WeChatRedEnvelopesHelper.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1450.14.0)
/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation (compatibility version 150.0.0, current version 1450.14.0)
/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
/System/Library/Frameworks/AVFoundation.framework/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
/System/Library/Frameworks/CoreLocation.framework/CoreLocation (compatibility version 1.0.0, current version 2237.0.22)
/System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 3698.33.6)
可以看到路径下/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate 并不是有效执行文件,因为这是越狱手机才有的,这时候应该用越狱手机拷贝出来,然后植入待签名包中。
- 从越狱手机拷贝 CydiaSubstrate 到桌面
scp -P 2222 root@localhost:/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate ~/Desktop
重命名CydiaSubstrate 为 libsubstrate.dylib 然后执行以下命令修改.dylib中CydiaSubstrate的路径
install_name_tool -change /Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate @loader_path/libsubstrate.dylib WeChatRedEnvelopesHelper.dylib
然后cd 到optool文件路径下(没有可以去下载https://github.com/alexzielenski/optool.git
)进行注入
./optool install -c load -p "@executable_path/WeChatRedEnvelopesHelper.dylib" -t WeChat.app/WeChat
然后注入成功就可以以下代码
$ ./optool install -c load -p "@executable_path/WeChatRedEnvelopesHelper.dylib" -t WeChat.app/WeChat
Found FAT Header
Found thin header...
Found thin header...
Inserting a LC_LOAD_DYLIB command for architecture: arm
Successfully inserted a LC_LOAD_DYLIB command for arm
Inserting a LC_LOAD_DYLIB command for architecture: arm64
Successfully inserted a LC_LOAD_DYLIB command for arm64
Writing executable to WeChat.app/WeChat...
最后别忘了将libsubstrate.dylib WeChatRedEnvelopesHelper.dylib 拷贝到WeChat.app目录下
cp libsubstrate.dylib WeChatRedEnvelopesHelper.dylib WeChat.app
最后就是签名了。。。。