首先,
使用THEOS创建 [2.] iphone/application_modern 项目.
以上就不详细说了.
剩下的内容分为以下几步.
1. main.m 中增加代码.
//请注意这个是针对 coolstar的electra越狱(绝大大部分越狱用户使用的都是electra). 而非pwn20wnd的unc0ver [https://github.com/pwn20wndstuff/Undecimus]
//原因请参考 https://github.com/coolstar/electra/blob/master/docs/getting-started.md
#import "XYAppDelegate.h"
//增加的头文件
#include <dlfcn.h>
//增加的函数
void patch_setuidandplatformize()
{
void* handle = dlopen("/usr/lib/libjailbreak.dylib", 1);
if (handle)
{
dlerror();
typedef void (*fix_setuid_prt_t)(pid_t pid);
fix_setuid_prt_t ptr_setuid = (fix_setuid_prt_t)dlsym(handle, "jb_oneshot_fix_setuid_now");
typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what);
fix_entitle_prt_t ptr_entitle = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now");
if(!dlerror())
{
ptr_setuid(getpid());
}
setuid(0);
setgid(0);
setuid(0);
if(!dlerror())
{
ptr_entitle(getpid(),2LL);
}
}
}
int main(int argc, char *argv[]) {
//增加的调用
patch_setuidandplatformize();
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass(XYAppDelegate.class));
}
}
2.增加postinst脚本
在项目根目录下 增加 layout/DEBIAN/ 目录
然后增加脚本文件 postinst
postinst文件内容
#!/bin/sh
#请遵循 Makefile 中的 APPLICATION_NAME = XYUtil 进行替换
killall -9 XYUtil
chown 0:0 /Applications/XYUtil.app/XYUtil
chmod 6755 /Applications/XYUtil.app/XYUtil
su mobile -c uicache
killall -9 SpringBoard
exit 0
这样 打包的时候就postinst文件就会被打包进入DEBIAN目录下.
说一下postinst功能,
首先杀死自身
然后 修改自身分组 root:wheel
然后 修改自身权限 可读可写可执行.
然后刷新桌面图标
然后 杀死桌面进程(不然安装完了运行起来黑屏...我也不知道咋回事)
然后脚本退出
3.进行签名
签名这个问题是遵循
https://github.com/coolstar/electra/blob/master/docs/getting-started.md
Platformizing a binary
In addition to signing your binary with the platform-application entiltement using ldid, you will also need to call jailbreakd to ensure your binary is correctly platformized. Sample code for this can be found below:
coolstar明确说明了 需要对二进制文件进行签名, 增加对应权限,
platform-application
我在别的有Root权限的二进制文件中导出了一份
导出命令
ldid -e 二进制文件名 >ent.xml
签名命令
ldid -Sent.xml 二进制文件名
第一个key标签中就是 冷星 说的 权限.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>platform-application</key>
<true/>
<key>com.apple.private.mobileinstall.allowedSPI</key>
<array>
<string>Lookup</string>
<string>Install</string>
<string>Browse</string>
<string>Uninstall</string>
<string>LookupForLaunchServices</string>
<string>InstallForLaunchServices</string>
<string>BrowseForLaunchServices</string>
<string>UninstallForLaunchServices</string>
<string>CopyDiskUsageForLaunchServices</string>
<string>InstallLocalProvisioned</string>
</array>
<key>com.apple.private.security.no-container</key>
<true/>
<key>com.apple.private.skip-library-validation</key>
<true/>
<key>com.apple.lsapplicationworkspace.rebuildappdatabases</key>
<true/>
<key>com.apple.private.MobileContainerManager.allowed</key>
<true/>
<key>com.apple.private.MobileGestalt.AllowedProtectedKeys</key>
<true/>
<key>com.apple.managedconfiguration.profiled-access</key>
<true/>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudDocuments</string>
<string>CloudKit</string>
</array>
<key>run-unsigned-code</key>
<true/>
<key>dynamic-codesigning</key>
<true/>
<key>get-task-allow</key>
<true/>
</dict>
</plist>
但是这个时候有点问题,如何在打包的时候顺便签名?
我查阅了一下资料并整理了一下 Makefile
export ARCHS = arm64
THEOS_DEVICE_IP=192.168.0.132
THEOS_DEVICE_PORT=22
include $(THEOS)/makefiles/common.mk
APPLICATION_NAME = XYUtil
XYUtil_FILES = main.m XYAppDelegate.m XYRootViewController.m
XYUtil_FRAMEWORKS = UIKit CoreGraphics
XYUtil_CODESIGN_FLAGS = -Sent.xml
#_CODESIGN_FLAGS是THEOS提供的 可使用指定权限文件签名的Flag 而 ent.xml(放在项目根目录) 是刚刚导出的那个权限xml
include $(THEOS_MAKE_PATH)/application.mk
然后 首先使用
make clean 清理之前的make 文件
然后使用 make package 生成包 或者 直接使用 make package install 进行安装.
到此 处理完成!!!
[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法