frida / frida-tools

Frida CLI tools
Other
344 stars 93 forks source link

repl: add quick command #105

Closed regomne closed 2 years ago

regomne commented 2 years ago

The feature "quick command" in frida REPL, like:

[Local::a.exe ]-> .d 401000 10
           0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  0123456789ABCDEF
00401000  55 8b ec 81 c4 fc fe ff ff 8b 45 0c 83 f8 01 75  U.........E....u

The quick cmd starts with '.' (same as nodejs REPL), and can be customized dynamically by the javascript loaded.

For example, set a new quick cmd 'u' in agent.js :

REPL.setQuickCmd(
    'u', // the quick cmd
    1, // at least 1 argument
    function disasm(addr, inst_cnt = 10) { ... } // target function
)

Which can be used in REPL:

[Local::a.exe ]-> .u 401000
00401000    push ebp
00401001    mov ebp, esp
00401003    add esp, 0xfffffefc
00401009    mov eax, dword ptr [ebp + 0xc]
0040100C    cmp eax, 1
0040100F    jne 0x401028
00401011    push dword ptr [0x403864]
00401017    push 1
00401019    push 0x466
0040101E    push dword ptr [ebp + 8]
regomne commented 2 years ago

@oleavr added REPL class support to repl.py

regomne commented 2 years ago

@oleavr Hey guy, what about this PR?

oleavr commented 2 years ago

Thanks! :fire: Merged with some minor tweaks. (Hopefully the changes make sense; if not feel free to open another PR!)