Skip to content

Instantly share code, notes, and snippets.

@llamaonsecurity
Last active July 21, 2023 11:05
Show Gist options
  • Save llamaonsecurity/fc6860fc62ecd5e5c1a6fa348622cfbf to your computer and use it in GitHub Desktop.
Save llamaonsecurity/fc6860fc62ecd5e5c1a6fa348622cfbf to your computer and use it in GitHub Desktop.
Frida script - Peek http req/res
Java.perform(function() {
var res2 = Java.use('com.android.okhttp.Response$Builder');
res2.build.implementation = function() {
var response = this.build();
console.log(response.headers())
//console.log(response.message())
var rBody = response.body();
//console.log(rBody.source())
console.log("## REQ ### ");
console.log(response.request());
console.log(response.request().headers());
console.log("## -REQ- ### ");
return response;
};
var base64 = Java.use('android.util.Base64');
var RealResponseBody = Java.use('com.android.okhttp.internal.http.RealResponseBody');
RealResponseBody.$init.overload('com.android.okhttp.Headers', 'com.android.okhttp.okio.BufferedSource').implementation = function(par1, par2) {
console.log("ResponseBody");
//breaks app, because readByteArray function clears input stream
var body = par2.readByteArray() //Comment this line if you want app to process request
console.log(base64.encodeToString(body, 0)); //Comment this line if you want app to process request
this.$init(par1, par2);
}
});
@TheDevFreak
Copy link

This doesn't seem to work for me.
I am getting:

C:\Users\Ben\frida>frida -U -l frida-hybrid-peek-android-okhttp.js com.google.android.apps.chromecast.app
     ____
    / _  |   Frida 12.6.11 - A world-class dynamic instrumentation toolkit
   | (_| |
    > _  |   Commands:
   /_/ |_|       help      -> Displays the help system
   . . . .       object?   -> Display information about 'object'
   . . . .       exit/quit -> Exit
   . . . .
   . . . .   More info at http://www.frida.re/docs/home/

[Xiaomi Redmi Note 5::com.google.android.apps.chromecast.app]-> TypeError: cannot write property 'implementation' of undefined
    at [anon] (../../../frida-gum/bindings/gumjs/duktape.c:57666)
    at /repl1.js:18
    at frida/node_modules/frida-java/lib/vm.js:42
    at E (frida/node_modules/frida-java/index.js:348)
    at frida/node_modules/frida-java/index.js:300
    at frida/node_modules/frida-java/lib/vm.js:42
    at frida/node_modules/frida-java/index.js:280
    at /repl1.js:31
[Xiaomi Redmi Note 5::com.google.android.apps.chromecast.app]->```
Ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment