Last active
February 19, 2025 22:25
-
-
Save eybisi/8361e8d6619a6b8a7a30afd7efeac40c to your computer and use it in GitHub Desktop.
vim frida codeblock builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command! -nargs=+ FridaV call FridaV(<f-args>) | |
command! -nargs=+ Frida call Frida(<f-args>) | |
function! FridaV( ... ) | |
let class = split(a:1,"\\V.") | |
let last = class[len(class)-1] | |
let S = ":normal i" | |
let S .= "\tvar %s = Java.use(\"%s\")\n" | |
execute printf(S,last,a:1) | |
call Frida(last,a:2,a:3) | |
endfunction | |
function! Frida( ... ) | |
let params = ["a","b","c","d","e","f","g","h","j","g","h"] | |
let cnt = a:3 | |
echo cnt | |
if cnt | |
let prm = params[0] | |
let c = 1 | |
while c < cnt | |
let prm .= "," | |
let prm .= params[c] | |
let c += 1 | |
endwhile | |
endif | |
let S = ":normal i" | |
let S .= "\t%s.%s.implementation = function(" | |
if cnt | |
let S .= "%s" | |
endif | |
let S .= "){\n" | |
if cnt | |
let S .= "var retval = this.%s(%s)\n" | |
else | |
let S .= "var retval = this.%s()\n" | |
endif | |
let S .= "console.log(\"hooked %s\")\n" | |
let S .= "console.log(\"hooked %s\ \" + retval)\n" | |
let S .= "send(retval)\n" | |
if cnt | |
let S .= "console.log(\"hooked %s\",%s)\n" | |
endif | |
let S .= "return retval\n}" | |
if cnt | |
execute printf(S,a:1,a:2,prm,a:2,prm,a:2,a:2,a:2,prm) | |
else | |
execute printf(S,a:1,a:2,a:2,a:2,a:2) | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment