最近ios13.1.3可以越獄了虐呻,就把手機(jī)越獄了象泵,卻發(fā)現(xiàn)可用的插件少的可憐,對于開發(fā)來講好多東西都不方便斟叼,比如查看BundleID,找到app的bundle目錄偶惠,找到沙盒目錄,好麻煩朗涩。之前的IconTool還失效了忽孽,一氣之下就寫了一個(gè)自用的IconTool。
要想操作logo就要先找SpringBoard進(jìn)程,然后用cy動(dòng)態(tài)注入(iOS13 cy用不了兄一,只能用cyrun輔助啟動(dòng)厘线,大佬的東西就是好用)。
先大致了解一下當(dāng)前頁面結(jié)構(gòu)
UIApp.keyWindow.recursiveDescription().toString ()
瞬間太多內(nèi)容出革,找到一個(gè)可疑的:SBIconView隨便找一個(gè)造壮,SetHidden:YES試一下,果然有一個(gè)隱藏了骂束,那就是他了耳璧。
找到SBIconView的頭文件,有touchesBegan和touchesEnded方法栖雾,先實(shí)現(xiàn)捕捉logo上滑的操作楞抡。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
%orig;
UITouch *touch = [touches anyObject];
gestureStartPoint= [touch locationInView:[(UIView *)self superview]];//開始觸摸
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
%orig;
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:[(UIView *)self superview]];
CGFloat deltaX = (gestureStartPoint.x - currentPosition.x);
CGFloat deltaY = gestureStartPoint.y - currentPosition.y;
float MINDISTANCE = sqrt(deltaX * deltaX + deltaY * deltaY)/2;
if(fabs(deltaY) > fabs(deltaX))
{
if (deltaY > MINDISTANCE)
{
[self handleSwipeFrom];
}
}
}
上滑之后彈出UIAlertController,先定下目標(biāo),一個(gè)一個(gè)實(shí)現(xiàn)析藕,有copyBundleID召廷,修改App的名字,修改角標(biāo)账胧,在Filza跳轉(zhuǎn)到app的Bundle路徑竞慢,跳轉(zhuǎn)到沙盒路徑
-(void)handleSwipeFrom
{
NSString * bundleID = [[self icon] applicationBundleID];
id app = [[self icon] application];
if (bundleID)
{
currentVC = [self getCurrentVC];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:bundleID message:nil preferredStyle: UIAlertControllerStyleActionSheet];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *archiveAction = [UIAlertAction actionWithTitle:@"復(fù)制BundleID" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
pastboard.string = bundleID;
}];
UIAlertAction *ReNameIcon = [UIAlertAction actionWithTitle:@"圖標(biāo)重命名" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self iconRenameWithBundleID:bundleID onTheApp:app];
}];
UIAlertAction *setBadgeAction = [UIAlertAction actionWithTitle:@"自定義角標(biāo)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self myBadgeNumberOnTheApp:app];
}];
UIAlertAction *getBundleAction = [UIAlertAction actionWithTitle:@"在Filza中打開(App)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString * bundlePath = [(NSURL *)[self applicationBundleURL] path];
[self jumpToApp:bundlePath];
}];
UIAlertAction *getSandBoxAction = [UIAlertAction actionWithTitle:@"在Filza中打開(Data)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString * homePath = [(NSURL *)[[app info] dataContainerURL] path];
[self jumpToApp:homePath];
}];
[alertController addAction:cancelAction];
[alertController addAction:archiveAction];
[alertController addAction:ReNameIcon];
[alertController addAction:setBadgeAction];
[alertController addAction:getBundleAction];
[alertController addAction:getSandBoxAction];
[currentVC presentViewController:alertController animated:YES completion:nil];
}
}
功能一:獲取BundleID
在dump出的SBIconView.h文件中發(fā)現(xiàn),有個(gè)icon 屬性比較可疑治泥,就在cy中去運(yùn)行一下得到另一個(gè)類:SBApplicationIcon,查看這個(gè)類的頭文件就發(fā)現(xiàn)另一個(gè)很重要的信息applicationBundleID筹煮,cy嘗試一下,果然可以居夹。還意外的發(fā)現(xiàn)了一個(gè)application屬性败潦,得到了當(dāng)前的程序SBApplication。第一個(gè)順利解決W贾=侔恰!
功能二:圖標(biāo)重命名
在SBIconView.h文件中搜索Label狸膏,果然有一個(gè)方法
-(void)labelView;
嘗試一下得到SBIconLegibilityLabelView沟饥,此類中有一個(gè)imageParameters,得到SBIconLabelImageParameters湾戳,再往下找有個(gè)text屬性贤旷,找到了。那我們開始,但是要替換砾脑,必須要搞一個(gè)文件保存幼驶,就借鑒一下之前的老版的IconTool的方法,以bundleID為鍵韧衣,以輸入的文本為值县遣,保存在plist文件中糜颠。然后刷新UI,在加載的時(shí)候hook加載的方法萧求,更改特定的程序名稱為新值其兴。
下一步找加載的方法,找了好多displayname夸政,都是readonly元旬,無法修改,那就直接hook守问,找到當(dāng)前的程序類SBApplication匀归,hook該類的方法:
-(id)displayName;
上代碼
-(void)iconRenameWithBundleID:(NSString *)bundleID onTheApp:(id)app
{
SBIconLegibilityLabelView * labelView = [self labelView];
SBIconLabelImageParameters * Parameters = [labelView imageParameters];
NSString *title = [NSString stringWithFormat:@"%@ 圖標(biāo)重命名",Parameters.text];
UIAlertController *ReNameAlertVC = [UIAlertController alertControllerWithTitle:title message:@"請輸入新的名稱" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* actionDefault = [UIAlertAction actionWithTitle:@"更改" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//保存數(shù)據(jù)
NewIconName = [ReNameAlertVC.textFields firstObject].text;
NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithContentsOfFile:@kSettingsFilePath];
if (dic.allKeys>0)
{
[dic setObject:NewIconName forKey:bundleID];
[dic writeToFile:@kSettingsFilePath atomically:YES];
}else
{
NSMutableDictionary * dic1 = [[NSMutableDictionary alloc]init];
[dic1 setObject:NewIconName forKey:bundleID];
[dic1 writeToFile:@kSettingsFilePath atomically:YES];
}
//刷新UI,借用更改角標(biāo)來刷新UI;
id str = [app badgeValue];
[app setBadgeValue:0];
[app setBadgeValue:str];
}];
UIAlertAction* recoverDefault = [UIAlertAction actionWithTitle:@"恢復(fù)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithContentsOfFile:@kSettingsFilePath];
if (dic.allKeys>0)
{
if ([dic.allKeys containsObject:bundleID])
{
[dic removeObjectForKey:bundleID];
[dic writeToFile:@kSettingsFilePath atomically:YES];
}
}
//刷新UI,借用更改角標(biāo)來刷新UI耗帕;
id str = [app badgeValue];
[app setBadgeValue:0];
[app setBadgeValue:str];
}];
UIAlertAction* actionCancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[ReNameAlertVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
}];
[ReNameAlertVC addAction:actionDefault];
[ReNameAlertVC addAction:recoverDefault];
[ReNameAlertVC addAction:actionCancel];
[currentVC presentViewController:ReNameAlertVC animated:YES completion:nil];
}
%hook SBApplication
- (id)displayName{
NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithContentsOfFile:@kSettingsFilePath];
if (dic.allKeys>0)
{
for (int i = 0; i < dic.allKeys.count; i++)
{
if ([self.bundleIdentifier isEqualToString:dic.allKeys[i]])
{
return [dic objectForKey:dic.allKeys[i]];
}
}
}
return %orig;
}
%end
第二個(gè)功能完工穆端。
功能三:修改角標(biāo)
這個(gè)比較簡單,因?yàn)槲以谡倚薷膎ame的時(shí)候發(fā)現(xiàn)了SBApplication類中有個(gè)方法:-(void)setBadgeValue;正中下懷仿便。
-(void)myBadgeNumberOnTheApp:(id)app
{
SBIconLegibilityLabelView * labelView = [self labelView];
SBIconLabelImageParameters * Parameters = [labelView imageParameters];
NSString *title = [NSString stringWithFormat:@"%@ 設(shè)定角標(biāo)",Parameters.text];
UIAlertController *badgeAlertVC = [UIAlertController alertControllerWithTitle:title message:@"請輸入新的角標(biāo)" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* actionDefault = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
id number = [badgeAlertVC.textFields firstObject].text;
[app setBadgeValue:number];
}];
UIAlertAction* actionCancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[badgeAlertVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
}];
[badgeAlertVC addAction:actionDefault];
[badgeAlertVC addAction:actionCancel];
[currentVC presentViewController:badgeAlertVC animated:YES completion:nil];
}
功能四五:跳轉(zhuǎn)到Filza中對應(yīng)的bundle位置和沙盒位置
先通過SBApplication找到程序的信息
其中最初的SBIconView有一個(gè)方法
-(id)applicationBundleURL;
剛好可以得到bundle地址体啰。
至于沙盒路徑通過SBApplication的info屬性得到SBApplicationInfo類,SBApplicationInfo類找到
-(id)dataContainerURL;
分析完畢嗽仪。
UIAlertAction *getBundleAction = [UIAlertAction actionWithTitle:@"在Filza中打開(App)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString * bundlePath = [(NSURL *)[self applicationBundleURL] path];
[self jumpToApp:bundlePath];
}];
UIAlertAction *getSandBoxAction = [UIAlertAction actionWithTitle:@"在Filza中打開(Data)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString * homePath = [(NSURL *)[[app info] dataContainerURL] path];
[self jumpToApp:homePath];
}];
全部分析完畢荒勇,至于代碼我發(fā)布到了Github,但是現(xiàn)在僅限于iOS13.1.3闻坚,沒有其他設(shè)備不能嘗試沽翔。。窿凤。
https://github.com/GFGWin/IconToolForiOS13.1.3
希望對你們有用=鲑恕!