@leeguoo/pwtk-network-debugger 1.2.8 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +143 -26
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -6609,28 +6609,62 @@ function requireCryptoJs() {
|
|
|
6609
6609
|
var cryptoJsExports = requireCryptoJs();
|
|
6610
6610
|
const CryptoJS = /* @__PURE__ */ getDefaultExportFromCjs(cryptoJsExports);
|
|
6611
6611
|
function decrypt(encryptedData, keyStr) {
|
|
6612
|
+
console.log("[PWTK Decrypt] decrypt function called:", {
|
|
6613
|
+
dataLength: encryptedData?.length,
|
|
6614
|
+
dataPreview: encryptedData?.substring(0, 50),
|
|
6615
|
+
keyStr,
|
|
6616
|
+
hasWindowDecrypt: typeof window.decrypt === "function",
|
|
6617
|
+
hasWindowEncrypt: typeof window.encrypt === "function"
|
|
6618
|
+
});
|
|
6612
6619
|
if (!encryptedData || encryptedData.startsWith("{") || encryptedData.startsWith("[")) {
|
|
6620
|
+
console.log("[PWTK Decrypt] Data looks like JSON, parsing directly");
|
|
6613
6621
|
try {
|
|
6614
|
-
|
|
6622
|
+
const parsed = JSON.parse(encryptedData);
|
|
6623
|
+
console.log("[PWTK Decrypt] Successfully parsed as JSON");
|
|
6624
|
+
return parsed;
|
|
6615
6625
|
} catch {
|
|
6626
|
+
console.log("[PWTK Decrypt] Failed to parse as JSON, returning as string");
|
|
6616
6627
|
return encryptedData;
|
|
6617
6628
|
}
|
|
6618
6629
|
}
|
|
6619
6630
|
if (window.decrypt && keyStr) {
|
|
6631
|
+
console.log("[PWTK Decrypt] Trying WebAssembly decrypt");
|
|
6632
|
+
console.log("[PWTK Decrypt] Input to window.decrypt:", {
|
|
6633
|
+
data: encryptedData.substring(0, 100) + "...",
|
|
6634
|
+
key: keyStr
|
|
6635
|
+
});
|
|
6620
6636
|
try {
|
|
6621
6637
|
const decrypted = window.decrypt(encryptedData, keyStr);
|
|
6638
|
+
console.log("[PWTK Decrypt] window.decrypt returned:", {
|
|
6639
|
+
type: typeof decrypted,
|
|
6640
|
+
length: decrypted?.length,
|
|
6641
|
+
preview: decrypted ? decrypted.substring(0, 200) + (decrypted.length > 200 ? "..." : "") : null,
|
|
6642
|
+
sameAsInput: decrypted === encryptedData,
|
|
6643
|
+
hasInvalidChars: decrypted?.includes("�")
|
|
6644
|
+
});
|
|
6622
6645
|
if (decrypted && decrypted !== encryptedData && !decrypted.includes("�")) {
|
|
6623
6646
|
try {
|
|
6624
|
-
|
|
6647
|
+
const parsed = JSON.parse(decrypted);
|
|
6648
|
+
console.log("[PWTK Decrypt] ✅ WebAssembly decryption successful, parsed as JSON:", parsed);
|
|
6649
|
+
return parsed;
|
|
6625
6650
|
} catch {
|
|
6626
6651
|
if (decrypted.length > 0) {
|
|
6652
|
+
console.log("[PWTK Decrypt] ✅ WebAssembly decryption successful, returning as string");
|
|
6627
6653
|
return decrypted;
|
|
6628
6654
|
}
|
|
6629
6655
|
}
|
|
6656
|
+
} else {
|
|
6657
|
+
console.log("[PWTK Decrypt] window.decrypt did not change the data or returned invalid result");
|
|
6630
6658
|
}
|
|
6631
6659
|
} catch (e) {
|
|
6632
|
-
console.log("WebAssembly
|
|
6660
|
+
console.log("[PWTK Decrypt] WebAssembly decrypt error:", e);
|
|
6633
6661
|
}
|
|
6662
|
+
} else {
|
|
6663
|
+
console.log("[PWTK Decrypt] WebAssembly not available:", {
|
|
6664
|
+
hasWindowDecrypt: !!window.decrypt,
|
|
6665
|
+
hasKey: !!keyStr,
|
|
6666
|
+
windowDecryptType: typeof window.decrypt
|
|
6667
|
+
});
|
|
6634
6668
|
}
|
|
6635
6669
|
const keys = [
|
|
6636
6670
|
keyStr,
|
|
@@ -6667,7 +6701,7 @@ function decrypt(encryptedData, keyStr) {
|
|
|
6667
6701
|
}
|
|
6668
6702
|
} catch {
|
|
6669
6703
|
}
|
|
6670
|
-
console.
|
|
6704
|
+
console.log("[PWTK Decrypt] ❌ All decryption methods failed, returning original data");
|
|
6671
6705
|
return encryptedData;
|
|
6672
6706
|
}
|
|
6673
6707
|
class NetworkInterceptor {
|
|
@@ -6725,56 +6759,121 @@ class NetworkInterceptor {
|
|
|
6725
6759
|
});
|
|
6726
6760
|
}
|
|
6727
6761
|
async tryDecrypt(data, headers) {
|
|
6762
|
+
console.log("[PWTK Debug] tryDecrypt called:", {
|
|
6763
|
+
dataType: typeof data,
|
|
6764
|
+
dataLength: typeof data === "string" ? data.length : JSON.stringify(data).length,
|
|
6765
|
+
dataPreview: typeof data === "string" ? data.substring(0, 100) : JSON.stringify(data).substring(0, 100),
|
|
6766
|
+
headers: Object.keys(headers),
|
|
6767
|
+
decryptEnabled: this.decryptConfig.enabled,
|
|
6768
|
+
hasWindowDecrypt: typeof window.decrypt === "function"
|
|
6769
|
+
});
|
|
6728
6770
|
if (!this.decryptConfig.enabled || !data) {
|
|
6771
|
+
console.log("[PWTK Debug] Decrypt disabled or no data");
|
|
6729
6772
|
return null;
|
|
6730
6773
|
}
|
|
6731
6774
|
try {
|
|
6732
6775
|
let key = "";
|
|
6733
6776
|
let slk = "";
|
|
6734
6777
|
if (headers.cid && this.decryptConfig.autoFetchKeys !== false) {
|
|
6778
|
+
console.log("[PWTK Debug] Trying to fetch key with cid:", headers.cid);
|
|
6735
6779
|
try {
|
|
6736
6780
|
const apiUrl = this.decryptConfig.keyApiUrl || "https://gw-card-pay.buyacard.cc/ip/getSK";
|
|
6781
|
+
const fetchHeaders = {
|
|
6782
|
+
cid: headers.cid,
|
|
6783
|
+
client: headers.client || "S_WEB",
|
|
6784
|
+
device: headers.device || "Web",
|
|
6785
|
+
language: headers.language || "CN"
|
|
6786
|
+
};
|
|
6787
|
+
console.log("[PWTK Debug] Fetching key from:", apiUrl, "with headers:", fetchHeaders);
|
|
6737
6788
|
const originalFetch = window.__originalFetch || window.fetch;
|
|
6738
|
-
const response = await originalFetch(apiUrl, {
|
|
6739
|
-
headers: {
|
|
6740
|
-
cid: headers.cid,
|
|
6741
|
-
client: headers.client || "S_WEB",
|
|
6742
|
-
device: headers.device || "Web",
|
|
6743
|
-
language: headers.language || "CN"
|
|
6744
|
-
}
|
|
6745
|
-
});
|
|
6789
|
+
const response = await originalFetch(apiUrl, { headers: fetchHeaders });
|
|
6746
6790
|
const result = await response.json();
|
|
6791
|
+
console.log("[PWTK Debug] getSK API response:", result);
|
|
6747
6792
|
if (result.success && result.data) {
|
|
6748
6793
|
const num = String(result.data);
|
|
6794
|
+
console.log("[PWTK Debug] getSK returned num:", num, "length:", num.length);
|
|
6749
6795
|
if (num.length >= 9) {
|
|
6750
6796
|
key = num.charAt(2) + num.charAt(5) + num.charAt(8);
|
|
6797
|
+
console.log("[PWTK Debug] Extracted key from getSK:", key);
|
|
6798
|
+
} else {
|
|
6799
|
+
console.log("[PWTK Debug] getSK num too short:", num);
|
|
6751
6800
|
}
|
|
6801
|
+
} else {
|
|
6802
|
+
console.log("[PWTK Debug] getSK failed:", result);
|
|
6752
6803
|
}
|
|
6753
6804
|
} catch (e) {
|
|
6754
|
-
console.warn("
|
|
6805
|
+
console.warn("[PWTK Debug] getSK API error:", e);
|
|
6755
6806
|
}
|
|
6807
|
+
} else {
|
|
6808
|
+
console.log("[PWTK Debug] No cid or autoFetchKeys disabled");
|
|
6756
6809
|
}
|
|
6757
6810
|
if (!key && this.decryptConfig.keyExtractor) {
|
|
6758
6811
|
key = this.decryptConfig.keyExtractor(headers);
|
|
6812
|
+
console.log("[PWTK Debug] Key from custom extractor:", key);
|
|
6759
6813
|
} else if (!key) {
|
|
6760
6814
|
key = headers.decryptKey || headers.keys || headers.cid || "";
|
|
6815
|
+
console.log("[PWTK Debug] Key from headers:", key, "from:", headers.decryptKey ? "decryptKey" : headers.keys ? "keys" : headers.cid ? "cid" : "none");
|
|
6761
6816
|
}
|
|
6762
6817
|
if (this.decryptConfig.slkExtractor) {
|
|
6763
6818
|
slk = this.decryptConfig.slkExtractor(headers);
|
|
6819
|
+
console.log("[PWTK Debug] SLK from custom extractor:", slk);
|
|
6764
6820
|
} else {
|
|
6765
6821
|
slk = headers.decryptSlk || headers.slk || "";
|
|
6822
|
+
console.log("[PWTK Debug] SLK from headers:", slk, "from:", headers.decryptSlk ? "decryptSlk" : headers.slk ? "slk" : "none");
|
|
6766
6823
|
}
|
|
6767
6824
|
const fullKey = key + slk;
|
|
6825
|
+
console.log("[PWTK Debug] Full decrypt key:", fullKey ? `"${fullKey}" (length: ${fullKey.length})` : "empty");
|
|
6768
6826
|
if (fullKey) {
|
|
6769
|
-
|
|
6827
|
+
let dataToDecrypt = data;
|
|
6828
|
+
let isWrappedData = false;
|
|
6829
|
+
if (typeof data === "object" && data !== null && data.data && typeof data.data === "string") {
|
|
6830
|
+
console.log('[PWTK Debug] Data is wrapped in {"data": "..."} format, extracting inner data');
|
|
6831
|
+
dataToDecrypt = data.data;
|
|
6832
|
+
isWrappedData = true;
|
|
6833
|
+
} else if (typeof data === "string") {
|
|
6834
|
+
try {
|
|
6835
|
+
const parsed = JSON.parse(data);
|
|
6836
|
+
if (parsed.data && typeof parsed.data === "string") {
|
|
6837
|
+
console.log("[PWTK Debug] Data is JSON string with data field, extracting");
|
|
6838
|
+
dataToDecrypt = parsed.data;
|
|
6839
|
+
isWrappedData = true;
|
|
6840
|
+
}
|
|
6841
|
+
} catch {
|
|
6842
|
+
}
|
|
6843
|
+
}
|
|
6844
|
+
const dataStr = typeof dataToDecrypt === "string" ? dataToDecrypt : JSON.stringify(dataToDecrypt);
|
|
6845
|
+
console.log("[PWTK Debug] Calling decrypt with:", {
|
|
6846
|
+
dataLength: dataStr.length,
|
|
6847
|
+
dataPreview: dataStr.substring(0, 50),
|
|
6848
|
+
key: fullKey,
|
|
6849
|
+
isWrapped: isWrappedData
|
|
6850
|
+
});
|
|
6770
6851
|
const decrypted = decrypt(dataStr, fullKey);
|
|
6771
|
-
|
|
6772
|
-
|
|
6852
|
+
console.log("[PWTK Debug] Decrypt result:", {
|
|
6853
|
+
success: decrypted && decrypted !== dataStr,
|
|
6854
|
+
decryptedType: typeof decrypted,
|
|
6855
|
+
decryptedLength: decrypted ? typeof decrypted === "string" ? decrypted.length : JSON.stringify(decrypted).length : 0,
|
|
6856
|
+
preview: decrypted ? typeof decrypted === "string" ? decrypted.substring(0, 100) : JSON.stringify(decrypted).substring(0, 100) : null
|
|
6857
|
+
});
|
|
6858
|
+
if (decrypted && decrypted !== dataStr) {
|
|
6859
|
+
if (isWrappedData) {
|
|
6860
|
+
const result = { data: decrypted };
|
|
6861
|
+
console.log("[PWTK Debug] ✅ Decryption successful! Returning wrapped result");
|
|
6862
|
+
return result;
|
|
6863
|
+
} else {
|
|
6864
|
+
console.log("[PWTK Debug] ✅ Decryption successful!");
|
|
6865
|
+
return decrypted;
|
|
6866
|
+
}
|
|
6867
|
+
} else {
|
|
6868
|
+
console.log("[PWTK Debug] ❌ Decryption failed or returned same data");
|
|
6773
6869
|
}
|
|
6870
|
+
} else {
|
|
6871
|
+
console.log("[PWTK Debug] No key available, skipping decryption");
|
|
6774
6872
|
}
|
|
6775
6873
|
} catch (error) {
|
|
6776
|
-
console.
|
|
6874
|
+
console.error("[PWTK Debug] tryDecrypt error:", error);
|
|
6777
6875
|
}
|
|
6876
|
+
console.log("[PWTK Debug] tryDecrypt returning null");
|
|
6778
6877
|
return null;
|
|
6779
6878
|
}
|
|
6780
6879
|
interceptXHR() {
|
|
@@ -6986,8 +7085,14 @@ class WasmLoader {
|
|
|
6986
7085
|
this.loading = false;
|
|
6987
7086
|
}
|
|
6988
7087
|
async loadWasm(wasmUrl, jsUrl) {
|
|
7088
|
+
console.log("[PWTK WASM] loadWasm called");
|
|
7089
|
+
console.log("[PWTK WASM] Current state:", {
|
|
7090
|
+
hasWindowDecrypt: typeof window.decrypt === "function",
|
|
7091
|
+
hasWindowEncrypt: typeof window.encrypt === "function",
|
|
7092
|
+
hasWindowGo: typeof window.Go !== "undefined"
|
|
7093
|
+
});
|
|
6989
7094
|
if (typeof window.decrypt === "function") {
|
|
6990
|
-
console.log("
|
|
7095
|
+
console.log("[PWTK WASM] window.decrypt already exists, skipping WASM load");
|
|
6991
7096
|
this.loaded = true;
|
|
6992
7097
|
return true;
|
|
6993
7098
|
}
|
|
@@ -7026,7 +7131,7 @@ class WasmLoader {
|
|
|
7026
7131
|
await this.loadScript(jsPath);
|
|
7027
7132
|
if (typeof window.Go !== "undefined") {
|
|
7028
7133
|
jsLoaded = true;
|
|
7029
|
-
console.log("
|
|
7134
|
+
console.log("[PWTK WASM] wasm_exec.js loaded successfully from:", jsPath);
|
|
7030
7135
|
break;
|
|
7031
7136
|
}
|
|
7032
7137
|
} catch (e) {
|
|
@@ -7075,19 +7180,28 @@ class WasmLoader {
|
|
|
7075
7180
|
}
|
|
7076
7181
|
go.run(wasmModule.instance);
|
|
7077
7182
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
7183
|
+
console.log("[PWTK WASM] After WASM load, checking functions:", {
|
|
7184
|
+
hasDecrypt: typeof window.decrypt === "function",
|
|
7185
|
+
hasEncrypt: typeof window.encrypt === "function",
|
|
7186
|
+
windowKeys: Object.keys(window).filter((k) => k.includes("crypt"))
|
|
7187
|
+
});
|
|
7078
7188
|
if (typeof window.decrypt === "function") {
|
|
7079
7189
|
this.loaded = true;
|
|
7080
|
-
console.log("
|
|
7190
|
+
console.log("[PWTK WASM] ✅ WebAssembly loaded successfully, decrypt function available");
|
|
7081
7191
|
return true;
|
|
7082
7192
|
} else {
|
|
7083
|
-
console.warn("
|
|
7193
|
+
console.warn("[PWTK WASM] ❌ WebAssembly loaded but decrypt function not available");
|
|
7084
7194
|
return false;
|
|
7085
7195
|
}
|
|
7086
7196
|
} catch (error) {
|
|
7087
|
-
console.
|
|
7197
|
+
console.error("[PWTK WASM] WebAssembly loading failed:", error);
|
|
7088
7198
|
return false;
|
|
7089
7199
|
} finally {
|
|
7090
7200
|
this.loading = false;
|
|
7201
|
+
console.log("[PWTK WASM] Load complete, final state:", {
|
|
7202
|
+
loaded: this.loaded,
|
|
7203
|
+
hasDecrypt: typeof window.decrypt === "function"
|
|
7204
|
+
});
|
|
7091
7205
|
}
|
|
7092
7206
|
}
|
|
7093
7207
|
loadScript(src) {
|
|
@@ -7873,7 +7987,7 @@ class DebugPanel {
|
|
|
7873
7987
|
<div class="about-panel" data-panel="about" style="display: none;">
|
|
7874
7988
|
<div style="padding: 20px; color: #fff; text-align: center;">
|
|
7875
7989
|
<h2 style="margin: 0 0 20px 0;">🔓 PWTK 解密小工具</h2>
|
|
7876
|
-
<p style="margin: 10px 0;">Version: 1.2.
|
|
7990
|
+
<p style="margin: 10px 0;">Version: 1.2.11</p>
|
|
7877
7991
|
<p style="margin: 10px 0;">👨💻 Created by <strong>Leo (@leeguoo)</strong></p>
|
|
7878
7992
|
<p style="margin: 10px 0;">📧 技术支持:请联系 Leo</p>
|
|
7879
7993
|
<p style="margin: 10px 0;">🌐 分享服务:curl.bwg.leeguoo.com</p>
|
|
@@ -8456,13 +8570,16 @@ class NetworkDebugger {
|
|
|
8456
8570
|
};
|
|
8457
8571
|
try {
|
|
8458
8572
|
if (this.config.wasm?.enabled !== false) {
|
|
8573
|
+
console.log("[PWTK Init] Starting WASM initialization");
|
|
8459
8574
|
this.wasmLoader = new WasmLoader();
|
|
8460
8575
|
const wasmLoaded = await this.wasmLoader.loadWasm(this.config.wasm?.wasmUrl, this.config.wasm?.jsUrl);
|
|
8461
8576
|
if (wasmLoaded) {
|
|
8462
|
-
console.log("
|
|
8577
|
+
console.log("[PWTK Init] ✅ WASM decrypt function ready");
|
|
8463
8578
|
} else {
|
|
8464
|
-
console.log("
|
|
8579
|
+
console.log("[PWTK Init] ⚠️ WASM load failed or decrypt function unavailable, will rely on page-provided decryption");
|
|
8465
8580
|
}
|
|
8581
|
+
} else {
|
|
8582
|
+
console.log("[PWTK Init] WASM disabled in config");
|
|
8466
8583
|
}
|
|
8467
8584
|
this.interceptor = new NetworkInterceptor();
|
|
8468
8585
|
if (this.config.decrypt?.enabled) {
|
|
@@ -8479,7 +8596,7 @@ class NetworkDebugger {
|
|
|
8479
8596
|
this.initialized = true;
|
|
8480
8597
|
console.log(`
|
|
8481
8598
|
╔════════════════════════════════════════╗
|
|
8482
|
-
║ 🔓 PWTK 解密小工具 v1.2.
|
|
8599
|
+
║ 🔓 PWTK 解密小工具 v1.2.11 ║
|
|
8483
8600
|
║ Created by Leo (@leeguoo) ║
|
|
8484
8601
|
║ 技术支持: 请联系 Leo ║
|
|
8485
8602
|
║ 分享服务: curl.bwg.leeguoo.com ║
|