iOS逆向:Cycript
2020-06-13 本文已影响0人
码小菜

目录
一,基本知识
二,常用语法
三,mjcript
四,实战练习
五,Reveal
一,基本知识
1,概念
-
它是
Objective-C
、C++
、JavaScript
、Java
等语言的混合物 -
它可以用来调试、修改
Mac
或iPhone
上正在运行的APP -
需要通过
Cydia
安装Cycript
工具,才能调试iPhone上的APP(软件源:http://apt.saurik.com)

2,ps命令
-
process status
(进程状态)的缩写,可以列举出系统所有正在运行的进程 -
iPhone上需要通过
Cydia
安装adv-cmds
工具(软件源:http://apt.saurik.com)

- 所有进程:
ps –A
(打开喜马拉雅APP)


- 搜索进程:
ps –A | grep 关键词

3,启动和退出
- 启动:
cycript -p 进程名称
- 退出:
control + d
- 清屏:
command + r

二,常用语法
1,UIApp
= UIApplication.sharedApplication()

2,定义变量:var 变量名 = 变量值

3,定义函数:function 函数名(...) { ... }

4,用内存地址获取对象:#内存地址

5,查看对象的所有成员变量:*对象

6,递归打印view的所有子控件:view.recursiveDescription().toString()

7,筛选出某种类型的对象:choose(类型)

三,mjcript
1,介绍
-
它是对
Cycript
的封装,提供了一些比较常用的函数
2,导入
- 将
mjcript.cy
文件拷贝到iPhone的/usr/lib/cycript0.9
目录下


- 进入
Cycript
环境,然后import
一下即可使用

3,常用函数
- 获取bundleId:
MJAppId

- 获取documents路径:
MJDocPath

- 获取根控制器:
MJRootVc()

- 获取当前显示的控制器:
MJFrontVc()

- 获取所有成员变量的名称:
MJIvarNames(...)

- 获取所有实例方法的名称:
MJInstanceMethodNames(...)

- 获取controller的层级结构:
MJChildVcs(...)

- 获取view的层级结构:
MJSubviews(...)

- 根据关键词进行筛选

- 添加动态库:
MJLoadFramework(...)

四,实战练习
1,利用python
打印字符

2,修改“立即登录”
- 查找



- 修改

- 效果

3,移除“VIP会员”
- 查找

- 移除

- 效果

4,添加“view”
- 添加

- 效果

5,调用“设置按钮点击方法”
- 查找

- 调用

- 效果

五,Reveal
1,介绍
-
它是一款调试UI界面的神器
2,配置
- 在iPhone上通过
Cydia
安装Reveal Loader
工具(软件源:http://apt.thebigboss.org)

- 在设置中打开需要调试的APP

- 将iPhone上的
/Library/MobileSubstrate/DynamicLibraries/RHRevealLoader.dylib
替换为Mac上的~/RevealServer.framework/RevealServer

- 重启iPhone(命令:
reboot
)和Reveal

