Sunbit v2.4.4版本的 MD5 值为:a5021e5e2a58eb1d6741b432fe7533c4
以下内容为反编译后的 m0.java 源代码,内容仅作参考
package com.just.agentweb;
import android.os.SystemClock;
import android.text.TextUtils;
import android.webkit.WebView;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import androidx.core.app.NotificationCompat;
import java.lang.reflect.Method;
import java.util.HashMap;
public class m0 {
private static final String f5591e = "JsCallJava";
private static final String f5592f = "{\"CODE\": %d, \"result\": %s}";
private static final String f5593g = "AgentWeb:";
private static final String f5594h = "obj";
private static final String f5595i = "method";
private static final String f5596j = "types";
private static final String f5597k = "args";
private static final String[] f5598l = {"getClass", "hashCode", "notify", "notifyAll", "equals", "toString", "wait"};
private HashMap<String, Method> f5599a;
private Object b;
private String c;
private String f5600d;
public m0(Object obj, String str) {
try {
if (!TextUtils.isEmpty(str)) {
this.b = obj;
this.c = str;
this.f5599a = new HashMap<>();
Method[] methods = this.b.getClass().getMethods();
StringBuilder sb = new StringBuilder("javascript:(function(b){console.log(\"");
sb.append(this.c);
sb.append(" init begin\");var a={queue:[],callback:function(){var d=Array.prototype.slice.call(arguments,0);var c=d.shift();var e=d.shift();this.queue[c].apply(this,d);if(!e){delete this.queue[c]}}};");
for (Method method : methods) {
String str2 = "method:" + method;
String a2 = a(method);
if (a2 != null) {
this.f5599a.put(a2, method);
sb.append(String.format("a.%s=", method.getName()));
}
}
sb.append("function(){var f=Array.prototype.slice.call(arguments,0);if(f.length<1){throw\"");
sb.append(this.c);
sb.append(" call error, message:miss method name\"}var e=[];for(var h=1;h<f.length;h++){var c=f[h];var j=typeof c;e[e.length]=j;if(j==\"function\"){var d=a.queue.length;a.queue[d]=c;f[h]=d}}var k = new Date().getTime();var l = f.shift();var m=prompt('");
sb.append(f5593g);
sb.append("'+JSON.stringify(");
sb.append(a("'" + this.c + "'", "l", "e", "f"));
sb.append("));console.log(\"invoke \"+l+\", time: \"+(new Date().getTime()-k));var g=JSON.parse(m);if(g.CODE!=200){throw\"");
sb.append(this.c);
sb.append(" call error, CODE:\"+g.CODE+\", message:\"+g.result}return g.result};Object.getOwnPropertyNames(a).forEach(function(d){var c=a[d];if(typeof c===\"function\"&&d!==\"callback\"){a[d]=function(){return c.apply(a,[d].concat(Array.prototype.slice.call(arguments,0)))}}});b.");
sb.append(this.c);
sb.append("=a;console.log(\"");
sb.append(this.c);
sb.append(" init end\")})(window)");
this.f5600d = sb.toString();
sb.setLength(0);
return;
}
throw new Exception("injected name can not be null");
} catch (Exception e2) {
if (v0.a()) {
String str3 = "init js error:" + e2.getMessage();
}
}
}
private String a(Method method) {
String name = method.getName();
Class<?>[] parameterTypes = method.getParameterTypes();
for (String str : f5598l) {
if (str.equals(name)) {
if (v0.a()) {
String str2 = "method(" + name + ") is unsafe, will be pass";
return null;
}
return null;
}
}
for (Class<?> cls : parameterTypes) {
if (cls == String.class) {
name = name + "_S";
} else if (cls == Integer.TYPE || cls == Long.TYPE || cls == Float.TYPE || cls == Double.TYPE) {
name = name + "_N";
} else if (cls == Boolean.TYPE) {
name = name + "_B";
} else if (cls == q.e.i.class) {
name = name + "_O";
} else if (cls == n0.class) {
name = name + "_F";
} else {
name = name + "_P";
}
}
return name;
}
public static boolean b(String str) {
return str.startsWith(f5593g);
}
public String a() {
return this.f5600d;
}
public String a(WebView webView, q.e.i iVar) {
long uptimeMillis = v0.a() ? SystemClock.uptimeMillis() : 0L;
if (iVar != null) {
try {
String string = iVar.getString(f5595i);
q.e.f jSONArray = iVar.getJSONArray(f5596j);
q.e.f jSONArray2 = iVar.getJSONArray(f5597k);
int length = jSONArray.length();
Object[] objArr = new Object[length];
int i2 = 0;
for (int i3 = 0; i3 < length; i3++) {
String optString = jSONArray.optString(i3);
Object obj = null;
if (TypedValues.Custom.S_STRING.equals(optString)) {
string = string + "_S";
if (!jSONArray2.isNull(i3)) {
obj = jSONArray2.getString(i3);
}
objArr[i3] = obj;
} else if ("number".equals(optString)) {
string = string + "_N";
i2 = (i2 * 10) + i3 + 1;
} else if (TypedValues.Custom.S_BOOLEAN.equals(optString)) {
string = string + "_B";
objArr[i3] = Boolean.valueOf(jSONArray2.getBoolean(i3));
} else if ("object".equals(optString)) {
string = string + "_O";
if (!jSONArray2.isNull(i3)) {
obj = jSONArray2.getJSONObject(i3);
}
objArr[i3] = obj;
} else if ("function".equals(optString)) {
string = string + "_F";
objArr[i3] = new n0(webView, this.c, jSONArray2.getInt(i3));
} else {
string = string + "_P";
}
}
Method method = this.f5599a.get(string);
if (method == null) {
return a(iVar, 500, "not found method(" + string + ") with valid parameters", uptimeMillis);
}
if (i2 > 0) {
Class<?>[] parameterTypes = method.getParameterTypes();
while (i2 > 0) {
int i4 = (i2 - ((i2 / 10) * 10)) - 1;
Class<?> cls = parameterTypes[i4];
if (cls == Integer.TYPE) {
objArr[i4] = Integer.valueOf(jSONArray2.getInt(i4));
} else if (cls == Long.TYPE) {
objArr[i4] = Long.valueOf(Long.parseLong(jSONArray2.getString(i4)));
} else {
objArr[i4] = Double.valueOf(jSONArray2.getDouble(i4));
}
i2 /= 10;
}
}
return a(iVar, 200, method.invoke(this.b, objArr), uptimeMillis);
} catch (Exception e2) {
v0.b(f5591e, NotificationCompat.CATEGORY_CALL, e2);
if (e2.getCause() != null) {
return a(iVar, 500, "method execute error:" + e2.getCause().getMessage(), uptimeMillis);
}
return a(iVar, 500, "method execute error:" + e2.getMessage(), uptimeMillis);
}
}
return a(iVar, 500, "call data empty", uptimeMillis);
}
private String a(q.e.i iVar, int i2, Object obj, long j2) {
String valueOf;
if (obj == null) {
valueOf = d.b.f.u.x.w;
} else if (obj instanceof String) {
valueOf = "\"".concat(String.valueOf(((String) obj).replace("\"", "\\\""))).concat("\"");
} else {
valueOf = String.valueOf(obj);
}
String format = String.format(f5592f, Integer.valueOf(i2), valueOf);
if (v0.a()) {
String str = "call time: " + (SystemClock.uptimeMillis() - j2) + ", request: " + iVar + ", result:" + format;
}
return format;
}
private static String a(String str, String str2, String str3, String str4) {
return d.b.f.u.x.D + f5594h + d.b.f.u.x.H + str + "," + f5595i + d.b.f.u.x.H + str2 + "," + f5596j + d.b.f.u.x.H + str3 + "," + f5597k + d.b.f.u.x.H + str4 + d.b.f.u.x.E;
}
public static q.e.i a(String str) {
try {
return new q.e.i(str.substring(9));
} catch (q.e.g e2) {
e2.printStackTrace();
return new q.e.i();
}
}
public static String a(q.e.i iVar) {
return iVar.optString(f5594h);
}
}