1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
function Android_WebView_inspector() {
var WebView = Java.use('android.webkit.WebView'); WebView.$init.overload('android.content.Context').implementation = function (a) { console.log("WebView.$init is called!1"); var retval = this.$init(a); this.setWebContentsDebuggingEnabled(true); return retval; } WebView.$init.overload('android.content.Context', 'android.util.AttributeSet').implementation = function (a, b) { console.log("WebView.$init is called!2"); var retval = this.$init(a, b); this.setWebContentsDebuggingEnabled(true); return retval; } WebView.$init.overload('android.content.Context', 'android.util.AttributeSet', 'int').implementation = function (a, b, c) { console.log("WebView.$init is called!3"); var retval = this.$init(a, b, c); this.setWebContentsDebuggingEnabled(true); return retval; } WebView.setWebContentsDebuggingEnabled.implementation = function () { this.setWebContentsDebuggingEnabled(true); console.log("setWebContentsDebuggingEnabled is called!");
} }
console.log("脚本加载成功"); function main() { Java.perform(function () { var WebView = Java.use('android.webkit.WebView'); WebView.$init.overload('android.content.Context').implementation = function (a) { var result = this.$init(a); this.setWebContentsDebuggingEnabled(true); return result; } WebView.$init.overload('android.content.Context', 'android.util.AttributeSet').implementation = function (a, b) { var result = this.$init(a, b); this.setWebContentsDebuggingEnabled(true); return result; } WebView.$init.overload('android.content.Context', 'android.util.AttributeSet', 'int').implementation = function (a, b, c) { var result = this.$init(a, b, c); this.setWebContentsDebuggingEnabled(true); return result; } WebView.$init.overload('android.content.Context', 'android.util.AttributeSet', 'int', 'int').implementation = function (a, b, c, d) { var result = this.$init(a, b, c, d); this.setWebContentsDebuggingEnabled(true); return result; } WebView.$init.overload('android.content.Context', 'android.util.AttributeSet', 'int', 'boolean').implementation = function (a, b, c, d) { var result = this.$init(a, b, c, d); this.setWebContentsDebuggingEnabled(true); return result; } WebView.$init.overload('android.content.Context', 'android.util.AttributeSet', 'int', 'java.util.Map', 'boolean').implementation = function (a, b, c, d, e) { var result = this.$init(a, b, c, d, e); this.setWebContentsDebuggingEnabled(true); return result; } WebView.$init.overload('android.content.Context', 'android.util.AttributeSet', 'int', 'int', 'java.util.Map', 'boolean').implementation = function (a, b, c, d, e, f) { var result = this.$init(a, b, c, d, e, f); this.setWebContentsDebuggingEnabled(true); return result; } }); } setImmediate(main);
function main2() { Java.perform(function () {
var WebView = Java.use('android.webkit.WebView'); WebView.setWebContentsDebuggingEnabled.overload("boolean").implementation = function (s) { console.log("强制开启webview调试"); this.setWebContentsDebuggingEnabled(true) } WebView.loadUrl.overload('java.lang.String').implementation = function (url) { console.log("WebView loading URL: " + url); if (url.startsWith("javascript:") && url.includes("window.requestConfig")) { var base64EncodedString = url.match(/"([^"]+)"/)[1]; var decodedBase64 = Java.use('android.util.Base64').decode(base64EncodedString, 0); var decodedString = Java.use('java.lang.String').$new(decodedBase64, "UTF-8"); decodedString = decodedString.replace(Java.use('java.lang.String').$new("\\u0026"), Java.use('java.lang.String').$new("&")); decodedString = decodedString.replace(Java.use('java.lang.String').$new("\\u003d"), Java.use('java.lang.String').$new("=")); console.log("解码 Base64: " + decodedString) } var stackTrace = Java.use('android.util.Log').getStackTraceString(Java.use('java.lang.Exception').$new()); console.log("调用链: " + stackTrace); return this.loadUrl(url); };
function decodeUnicode(str) { return str.replace(/\\u[\dA-Fa-f]{4}/g, function (match) { return String.fromCharCode(parseInt(match.replace("\\u", ""), 16)); }); }
var WebViewClient = Java.use('android.webkit.WebViewClient'); WebViewClient.onPageFinished.overload('android.webkit.WebView', 'java.lang.String').implementation = function (view, url) { console.log("WebView finished loading URL: " + url); return this.onPageFinished(view, url); };
var WebResourceRequest = Java.use('android.webkit.WebResourceRequest'); var WebViewClient2 = Java.use('android.webkit.WebViewClient');
WebViewClient2.shouldInterceptRequest.overload('android.webkit.WebView', 'android.webkit.WebResourceRequest').implementation = function (view, request) { var requestUrl = request.getUrl().toString(); console.log("Intercepting WebResourceRequest: " + requestUrl);
return this.shouldInterceptRequest(view, request); }; }); }
|