親手打造IconTool插件

最近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
希望對你們有用=鲑恕!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末雳殊,一起剝皮案震驚了整個(gè)濱河市哨颂,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌相种,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,657評論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件品姓,死亡現(xiàn)場離奇詭異寝并,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)腹备,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,889評論 3 394
  • 文/潘曉璐 我一進(jìn)店門衬潦,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人植酥,你說我怎么就攤上這事镀岛∠夷担” “怎么了?”我有些...
    開封第一講書人閱讀 164,057評論 0 354
  • 文/不壞的土叔 我叫張陵漂羊,是天一觀的道長驾锰。 經(jīng)常有香客問我,道長走越,這世上最難降的妖魔是什么椭豫? 我笑而不...
    開封第一講書人閱讀 58,509評論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮旨指,結(jié)果婚禮上赏酥,老公的妹妹穿的比我還像新娘。我一直安慰自己谆构,他們只是感情好裸扶,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,562評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著搬素,像睡著了一般呵晨。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上蔗蹋,一...
    開封第一講書人閱讀 51,443評論 1 302
  • 那天何荚,我揣著相機(jī)與錄音,去河邊找鬼猪杭。 笑死餐塘,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的皂吮。 我是一名探鬼主播戒傻,決...
    沈念sama閱讀 40,251評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼蜂筹!你這毒婦竟也來了需纳?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,129評論 0 276
  • 序言:老撾萬榮一對情侶失蹤艺挪,失蹤者是張志新(化名)和其女友劉穎不翩,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體麻裳,經(jīng)...
    沈念sama閱讀 45,561評論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡口蝠,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,779評論 3 335
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了津坑。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片妙蔗。...
    茶點(diǎn)故事閱讀 39,902評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖疆瑰,靈堂內(nèi)的尸體忽然破棺而出眉反,到底是詐尸還是另有隱情昙啄,我是刑警寧澤,帶...
    沈念sama閱讀 35,621評論 5 345
  • 正文 年R本政府宣布寸五,位于F島的核電站梳凛,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏播歼。R本人自食惡果不足惜伶跷,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,220評論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望秘狞。 院中可真熱鬧叭莫,春花似錦、人聲如沸烁试。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,838評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽减响。三九已至靖诗,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間支示,已是汗流浹背刊橘。 一陣腳步聲響...
    開封第一講書人閱讀 32,971評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留颂鸿,地道東北人促绵。 一個(gè)月前我還...
    沈念sama閱讀 48,025評論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像嘴纺,于是被迫代替她去往敵國和親败晴。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,843評論 2 354

推薦閱讀更多精彩內(nèi)容

  • Swift1> Swift和OC的區(qū)別1.1> Swift沒有地址/指針的概念1.2> 泛型1.3> 類型嚴(yán)謹(jǐn) 對...
    cosWriter閱讀 11,101評論 1 32
  • 工具 class-dump 用來提取已經(jīng)砸過殼的 app 的頭文件 下載地址 http://stevenygard...
    輝g_9274閱讀 2,604評論 1 7
  • 2016-2017年是插件化遍地開花的一年栽渴,各家大廠都開源了自己的插件化框架尖坤、熱修復(fù)技術(shù),網(wǎng)上也已經(jīng)有許多介紹和分...
    Geek帆哥閱讀 2,818評論 2 9
  • 8.第一個(gè)逆向程序 創(chuàng)建tweak工程? iOS /opt/theos/bin/nic.pl NIC 2.0 -...
    Flonger閱讀 2,949評論 0 1
  • 因果必報(bào)是符合自然法規(guī)就比如春天把種子埋在地里經(jīng)過溫度陽光雨水的滋潤它就發(fā)芽開花結(jié)果因果必報(bào)是需要時(shí)間過程不能因?yàn)?..
    孟現(xiàn)捧閱讀 154評論 0 0