Reputation: 105
I'm trying to hook m6517 method in the gha class:
package o;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
public class gha {
private static byte[] f4427 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".getBytes();
static {
Package packageR = gha.class.getPackage();
if (packageR != null) {
packageR.getName();
}
}
/* renamed from: ı reason: contains not printable characters */
public static String m6517(byte[] bArr) {
int i;
int length = bArr.length;
byte[] bArr2 = new byte[(((length + 2) / 3) << 2)];
int i2 = 0;
while (i2 < length) {
int i3 = i2;
int i4 = 0;
while (true) {
i = i2 + 3;
if (i3 >= i) {
break;
}
i4 <<= 8;
if (i3 < length) {
i4 |= bArr[i3] & 255;
}
i3++;
}
int i5 = (i2 / 3) << 2;
byte[] bArr3 = f4427;
bArr2[i5] = bArr3[(i4 >> 18) & 63];
bArr2[i5 + 1] = bArr3[(i4 >> 12) & 63];
byte b = 61;
bArr2[i5 + 2] = i2 + 1 < length ? bArr3[(i4 >> 6) & 63] : 61;
int i6 = i5 + 3;
if (i2 + 2 < length) {
b = f4427[i4 & 63];
}
bArr2[i6] = b;
i2 = i;
}
return new String(bArr2);
}
}
stackoverflow notify me that I should add some more details))
And then it is printing me that:
MyHook:
Java.perform(function () {
var hash = Java.use("o.gha");
hash.m6517.overload().implementation = function(str){
console.log('original: ' + str);
console.log('hashed: ' + hash.m6517(str));
return hash.m6517(str);
}
});
What should I do to resolve this problem? stackoverflow notify me that I should add some more details))
Upvotes: 0
Views: 3939
Reputation: 3055
Well it's kinda look like base64 but that's not what ur asking for..
You need to pass method's signature
m6517
receives byte array [
means array in smali, and B
is byte
hash.m6517.overload('[B').implementation = function(str){
...
btw, if you want to invoke it (it's static so no need for an instance) to pass byte array use
m6517( Java.array('byte', [ 41, 41, 42, 43 ]) );
Update:
I see now it's renamed due to non printable characters
Either try to trace entire class or updated with the following script output
Java.use('gha').class.getDeclaredMethods().forEach(function (method) {
var methodName = method.toString();
console.log("method name = " + methodName);
try {
// .. hook here
} catch (e) {
console.error(methodName, e);
}
});
Upvotes: 2