iOS之cycript
简介
Cycript是由Cydia创始人Saurik推出的一款脚本语言,Cycript混合了OC、JavaScript语法的解释器,我们能够在一个命令中使用Oc或者JavaScript,甚至两者并用。它能够挂钩正在运行的进程,能够在运行时修改很多东西。
使用方法
1.越狱手机安装Cycript插件,ssh登录到手机中
1 |
|
2.使用MonkeyDev新建MonkeyApp工程,运行需要动态调试的App,Monkey默认开启了Cycript服务:
1 |
|
我们只需要Cycript链接到目标应用:
1 |
|
常用命令
- UIApp
- NSHomeDirectory()
- [[NSBundle mainBundle] bundleIdentifier]
- UIApp.delegate
- UIApp.keyWindow
- UIApp.keyWindow.recursiveDescription().toString()
- UIApp.keyWindow.rootViewController
- #address :获取该对象
- *#address:打印该对象成员变量
- ?exit
弹窗
1 |
|
调用
1 |
|
案例
将手机语言设置未英文(方便定位),进入设置-关于
打印当前页面的所有信息
1
2
3
4UIApp.keyWindow.recursiveDescription().toString()
//只显示一部分
<PSTableCell: 0x10392e000; baseClass = UITableViewCell; frame = (0 290; 375 44); text = 'Network'; autoresize = W; tag = 4; layer = <CALayer: 0x2811e46a0>>\n可以看见Network的PSTableCell以及对象地址
隐藏/显示
1
2
3
4//隐藏
[#0x10392e000 setHidden:YES]
//显示
[#0x10392e000 setHidden:NO]通过nextResponder找到cell对应的controller
通过三次nextResponder最终找到了controller->PSGAboutController
修改controller的标题
1
[#0x104137400 setTitle:"Cola"]