Skip to content

Instantly share code, notes, and snippets.

@eybisi
Last active January 30, 2021 13:00
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eybisi/8361e8d6619a6b8a7a30afd7efeac40c to your computer and use it in GitHub Desktop.
Save eybisi/8361e8d6619a6b8a7a30afd7efeac40c to your computer and use it in GitHub Desktop.
vim frida codeblock builder
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