依赖
- 环境
- frida: 15.0.2
- node
- vscode
- root iphone
- 原理
通过frida-compile
把TypeScript
编译成js代码。可实现ts,js混写,文件内容更改,即时内存注入。
开始
- 初始化
mkdir fridatool && cd fridatool
mkdir dist src
# 初始化NPM
npm init -y
package.json如下:
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "frida-compile src/index.ts -o dist/index.js -c",
"watch": "frida-compile src/index.ts -o dist/index.js -w",
"hook": "frida -U appName --debug --runtime=v8 --no-pause -l ./dist/index.js"
},
"devDependencies": {
"@types/frida-gum": "^16.2.0",
"@types/node": "^14.14.10",
"frida-compile": "^10.0.0"
}
}
- 安装TypeScript
npm install -g typescript
tsc --init
修改tsconfig.json
"outDir": "./dist",
"rootDir": "./src",
- 依次建文件
tree #结构如下
.
├── dist
│ └── index.js
├── package-lock.json
├── package.json
├── src
│ ├── common
│ │ └── hooktools.js
│ ├── index.ts
│ ├── main.js
│ └── test
│ └── hooktest1.js
└── tsconfig.json
- 写代码
// index.ts
require("./main.js");
// main.js
require("./test/hooktest1")
/// hooktest.js
var tool = require("../common/hooktools")
console.log("begin");
tool.hook_ocMethod("-[CLLocation *]", args => { }, retval => { })
npm install
后运行,可以在vscode中package.json
直接点
npm run watch
npm run hook
后记
- 配置完成后,每次修改文件都会重新运行,并进行hook。
- ts,js可混写。
chrome DelTools
附加调试。找开chrome://inspect下断即可,可按左下角{}
按钮进行格式化。- 利用webpack,可不用ts。