-
Notifications
You must be signed in to change notification settings - Fork 20
/
browser_inspect.js
110 lines (88 loc) · 3.46 KB
/
browser_inspect.js
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
// From:
// https://github.com/sigalor/whatsapp-web-multi-device-reveng/blob/main/inspect-app.md
(function()
{
if (!window.mR) {
const moduleRaid = function () {
moduleRaid.mID = Math.random().toString(36).substring(7);
moduleRaid.mObj = {};
fillModuleArray = function() {
(window.webpackChunkbuild || window.webpackChunkwhatsapp_web_client).push([
[moduleRaid.mID], {}, function(e) {
Object.keys(e.m).forEach(function(mod) {
moduleRaid.mObj[mod] = e(mod);
})
}
]);
}
fillModuleArray();
get = function get (id) {
return moduleRaid.mObj[id]
}
findModule = function findModule (query) {
results = [];
modules = Object.keys(moduleRaid.mObj);
modules.forEach(function(mKey) {
mod = moduleRaid.mObj[mKey];
if (typeof mod !== 'undefined') {
if (typeof query === 'string') {
if (typeof mod.default === 'object') {
for (key in mod.default) {
if (key == query) results.push(mod);
}
}
for (key in mod) {
if (key == query) results.push(mod);
}
} else if (typeof query === 'function') {
if (query(mod)) {
results.push(mod);
}
} else {
throw new TypeError('findModule can only find via string and function, ' + (typeof query) + ' was passed');
}
}
})
return results;
}
return {
modules: moduleRaid.mObj,
constructors: moduleRaid.cArr,
findModule: findModule,
get: get
}
}
window.mR = moduleRaid();
}
if (!window.decodeStanza) {
window.decodeStanza = (window.mR.findModule('decodeStanza')[0]).decodeStanza;
window.encodeStanza = (window.mR.findModule('encodeStanza')[0]).encodeStanza;
window.encodeProtobuf = (window.mR.findModule('encodeProtobuf')[0]).encodeProtobuf;
window.decodeProtobuf = (window.mR.findModule('decodeProtobuf')[0]).decodeProtobuf;
}
(window.mR.findModule('decodeStanza')[0]).decodeStanza = async (e, t) => {
const result = await window.decodeStanza(e, t);
console.log("DECODE STANZA", new Uint8Array(e).toString("hex"));
return result;
}
(window.mR.findModule('encodeStanza')[0]).encodeStanza = (...args) => {
const result = window.encodeStanza(...args);
console.log('ENCODE STANZA', args, "->", result.toString("hex"));
return result;
}
(window.mR.findModule('encodeProtobuf')[0]).encodeProtobuf = (...args) => {
const result = window.encodeProtobuf(...args);
console.log('ENCODE PROTOBUF', args, "->", result._buffer.toString("hex"));
return result;
}
(window.mR.findModule('decodeProtobuf')[0]).decodeProtobuf = (...args) => {
const result = window.decodeProtobuf(...args);
console.log('DECODE PROTOBUF', args, "->", result);
return result;
}
var oldSend = window.WebSocket.prototype.send
window.WebSocket.prototype.send = function(e){
console.log("send", e.toString("hex"))
return oldSend.call(this, e)
}
})()