Frida 命令行

本页为社区译文;如有疑义,请以英文原文为准。 英文原文

Frida CLI 是一个 REPL 接口,旨在仿效 IPython(或 Cycript)的诸多优秀特性, 让你能够更贴近自己的代码,从而快速制作原型并轻松调试。

# Connect Frida to an iPad over USB and start debugging Safari
$ frida -U Safari

[USB::iPad 4::Safari]->

会话示例

# Connect Frida to a locally-running Calculator.app
$ frida Calculator

# Look at the local variables/context
[Local::ProcName::Calculator]-> <TAB>
Backtracer           Process
CpuContext           Proxy
Dalvik               Socket
DebugSymbol          Stalker
File                 Thread
Frida                WeakRef
Instruction          clearInterval
Interceptor          clearTimeout
Memory               console
MemoryAccessMonitor  gc
Module               ptr
NULL                 recv
NativeCallback       send
NativeFunction       setInterval
NativePointer        setTimeout
ObjC
# Look at things exposed through the ObjC interface
[Local::ProcName::Calculator]-> ObjC.<TAB>
Object            implement         selector
available         mainQueue         selectorAsString
classes           schedule
# List the first 10 classes (there are a lot of them!)
[Local::...::Calculator]-> Object.keys(ObjC.classes).slice(0, 10)
[
    "NSDrawer",
    "GEOPDETAFilter",
    "NSDeserializer",
    "CBMutableCharacteristic",
    "NSOrthographyCheckingResult",
    "DDVariable",
    "GEOVoltaireLocationShiftProvider",
    "LSDocumentProxy",
    "NSPreferencesModule",
    "CIQRCodeGenerator"
]

加载脚本

# Connect Frida to a locally-running Calculator.app and load calc.js
$ frida Calculator -l calc.js

# The code in calc.js has now been loaded and executed. Any changes will be reloaded automatically
[Local::ProcName::Calculator]->

# Manually reload it from file at any time
[Local::ProcName::Calculator]-> %reload
[Local::ProcName::Calculator]->

启用兼容 Node.js 的调试器

# Connect Frida to a locally-running Calculator.app
# and load calc.js with the debugger enabled
$ frida Calculator -l calc.js --debug

Debugger listening on port 5858
# We can now run node-inspector and start debugging calc.js
[Local::ProcName::Calculator]->