Reputation: 75
I use frida to hook class. In my case HmacBuilder. It has method hmacSha256Hex()
Here what method wants..
hmacSha256Hex('java.lang.String', 'java.lang.String', 'java.lang.String', 'okhttp3.RequestBody', 'java.lang.String')
If i call it and just pass strings for all of them.. like
instance.hmacSha256Hex("none","none","none","none","none"))
frida gives error
argument types do not match any of:\n\t.overload('java.lang.String', 'java.lang.String', 'java.lang.String', 'okhttp3.RequestBody', 'java.lang.String')"
Please advise, how should i call this method properly?(Preferably passing string as okhttp3.RequestBody?
My full inject_code.js
console.log("Script loaded successfully ");
Java.perform(function x() {
//Find an instance of the class and call function.
Java.choose("com.testapp.HmacBuilder", {
onMatch: function (instance) {
console.log("Found instance: " + instance);
console.log("Result of HMAC func: " + instance.hmacSha256Hex("none","none","none","none","none"));
},
onComplete: function () { }
});
});
console.log("Script finished ");
Upvotes: 0
Views: 934
Reputation: 42585
If there isn't an overloaded method that takes 4 String arguments you have to create and pass a RequestBody as fourth parameter, that is the way programming works. Why don't you try to create a RequestBody using RequestBody.create(MediaType contentType, String content)? For the MediaType MediaType.get(String) should be the correct method.
Translated to code it should be code like this (untested) code:
let requestBodyText = "my text"; // <- define the request body text here
let requestBodyClass = Java.use("okhttp3.RequestBody");
let mediaTypeClass = Java.use("okhttp3.MediaType");
let mediaType = mediaTypeClass.get("text/plain");
let requestBody = requestBodyClass.create(mediaType, requestBodyText);
instance.hmacSha256Hex("none","none","none",requestBody,"none"))
Upvotes: 2