美文网首页
【iOS逆向】- Cycript

【iOS逆向】- Cycript

作者: fanglaoda | 来源:发表于2018-11-07 21:46 被阅读0次

    简介

    Cycript allows developers to explore and modify running applications on either iOS or Mac OS X using a hybrid of Objective-C++ and JavaScript syntax through an interactive console that features syntax highlighting and tab completion.
    (It also runs standalone on Android and Linux and provides access to Java, but without injection.)

    该语言可以用来动态调试我们的程序,查看内存中的状态,官网地址,点开手机的Cydia可以看到这个插件

    常见用法

    开启/关闭调试

    cycript -p 进程名称
    
    或者
    
    cycript -p 进程ID
    

    比如我们想调试我们的桌面程序SpringBoard

    15415960608710.jpg

    退出: 键盘Ctrl + D

    简单使用

    (1). UIApp / [UIApplication sharedApplication]

    15415964138396.jpg

    UIApp[UIApplication sharedApplication]是等价的

    (2). 获取keyWindow 和 rootViewController

    15415965250824.jpg

    (3). 通过地址获取对象

    语法:

        #对象的地址
    
    15415966170483.jpg

    (4). 获取已经加载的所有类

    ObjectiveC .classes
    

    内容太长不截图了

    (5).获取对象的所有成员变量

    语法

    * 对象
    
    15415973015883.jpg

    (6). 获取当前view中某个类型的子类型

    choose(类型)
    
    15415975280306.jpg

    (7). 获取当前展示的界面的所有view的子控件

    view.recursiveDescription().toString()
    
    15415976387392.jpg

    每次都敲这些东西很麻烦,你可以定义方法,写到文件.cy结尾放到手机的/usr/lib/cycript0.9

    15415977934401.jpg
    //根控制器
    LDRootVC = () => UIApp.keyWindow.rootViewController;
    
    LDKeyWindow = () => UIApp.keyWindow;
    
    
    LDBundleId = [NSBundle mainBundle].bundleIdentifier;
    
    // 沙盒目录
    LDDocumentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
    
    
    // 沙盒目录
    LDCachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
    
    // 获取当前展示的viewController
    LDCurrentViewController = _ => _innerCurrentVC(LDRootVC());
    
    const _innerCurrentVC = (fromViewController) =>  {
    
    if ([fromViewController isKindOfClass:[UINavigationController class]]) {
        return _innerCurrentVC(fromViewController.viewControllers.lastObject());
    } else if([fromViewController isKindOfClass:[UITabBarController class]]) {
        return _innerCurrentVC(fromViewController.selectedViewController);
    } else if(fromViewController.presentedViewController) {
        return _innerCurrentVC(fromViewController.presentedViewController);
    } else {
        return fromViewController;
    
    };
    }
    
    //获取某个类的所有子类
    LDSubClassWithView = (classView) => choose(classView);
    
    
    //获取某个view的所有子view
    LDSubViews = (view) => view.recursiveDescription() .description;
    
    
    //对外输出的接口提示使用者用 没有具体含义
    exports.LDInterface = [
    'LDRootVC',
    'LDkeyWindow',
    'LDBundleId',
    'LDDocumentPath',
    'LDCachePath',
    'LDCurrentViewController',
    'LDSubClassWithView'
    ];
    
    

    用法如下

    15415980079446.jpg

    这样就不用每次都写了,不使用该文件也是可以的,无非就是麻烦些而已

    相关文章

      网友评论

          本文标题:【iOS逆向】- Cycript

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