美文网首页
iOS逆向学习笔记 - Logos 语法

iOS逆向学习笔记 - Logos 语法

作者: iOS_LeON | 来源:发表于2018-05-16 15:30 被阅读37次

    Logos语法

    http://iphonedevwiki.net/index.php/Logos

    • 1、新建Logos测试工程
    • 2、用class-dump导出头文件
    $class-dump -H 001-LogosDemo -o /Users/yaoqi/Desktop/LogosHeaders
    
    
    • 3、新建Monkey工程,将Logos测试工程重签名

    此时Monkey工程已经将libsubstrate.dylib库和RevealServer.framework库注入进去了,有了libsubstrate.dylib库就能写Logos语法了。

    1373790-aa9709c6ac77685d.png
    • 4、在Monkey中的Logos文件夹的.xm文件写Logos语法
    Logos语法 功能解释 事例
    %hook 需要hook哪个类 %hook Classname
    %end 代码块结束标记
    %group 分组 %group Groupname
    %new 添加新方法 %new(signature)
    %ctor 构造函数 %ctor { … }
    %dtor 析构函数 %dtor { … }
    %log 输出打印 %log; %log([(<type>)<expr>, …]);
    %orig 保持原有方法 %orig;%orig(arg1, …);

    _02_loginHookDemoDylib.xm

    // See http://iphonedevwiki.net/index.php/Logos
    
    #import <UIKit/UIKit.h>
    
    @interface ViewController: UIViewController
    
    - (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion NS_AVAILABLE_IOS(5_0);
    + (void)CL_classMethod;
    
    @end
    
    %hook ViewController
    
    - (void)loginBtnClicked:(id)arg1 {
        %log;
        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Hook成功了!!!" message:nil preferredStyle:(UIAlertControllerStyleAlert)];
        [alertVC addAction:[UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleCancel) handler:nil]];
        [self presentViewController:alertVC animated:YES completion:nil];
    }
    
    %new
    - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
        [self.view endEditing:YES];
        [self.class CL_classMethod];
    }
    
    %new
    + (void)CL_classMethod {
        NSLog(@"这是一个类方法!!!");
    }
    
    %end
    
    

    这里在ViewController中定义了一个方法presentViewController:animated:completion:,只是为了能编译通过,骗过Xcode编译器。

    5、运行成功后,Monkey工程就能Hook到001-LogosDemo工程里面的loginBtnClicked:

    Monkey工程注入FLEX库

    https://github.com/Flipboard/FLEX

    • 1、在Monkey的Dylib动态库中注入FLEX库

    在Monkey工程的根目录添加Podfile文件,Target为Monkey工程动态库的Target

    # Uncomment the next line to define a global platform for your project
    platform :ios, '9.0'
    
    target '002-loginHookDemoDylib' do
      use_frameworks!
      pod 'FLEX'
    end
    
    
    • 2、界面展示

    FLEX能查看App的文件、数据库、沙盒、界面层级。。。

    相关文章

      网友评论

          本文标题:iOS逆向学习笔记 - Logos 语法

          本文链接:https://www.haomeiwen.com/subject/sxgpdftx.html