-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransformed.js
executable file
·119 lines (111 loc) · 4.61 KB
/
transformed.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
111
112
113
114
115
116
117
118
119
var importObject = {
env: {
i: function (arg1, arg2) {
arg1 -= arg2;
var a = arguments.length;
var b = arguments[2];
var c = b.__proto__.slice([...b]);
print('[+] imported function executed.');
},
}
};
var wasmCode = new Uint8Array([0x0, 0x61, 0x73, 0x6d, 0x1, 0x0, 0x0, 0x0, 0x1, 0x7, 0x1, 0x60, 0x2, 0x7f, 0x7f, 0x1, 0x7f, 0x3, 0x2, 0x1, 0x0, 0x4, 0x4, 0x1, 0x70, 0x0, 0x4, 0x6, 0x2e, 0x5, 0x7f, 0x0, 0x41, 0x2a, 0xb, 0x7d, 0x0, 0x43, 0x0, 0x0, 0x0, 0x3f, 0xb, 0x7c, 0x0, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe0, 0x3f, 0xb, 0x7d, 0x0, 0x43, 0x0, 0x0, 0xc0, 0x7f, 0xb, 0x7c, 0x0, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xb, 0x7, 0x40, 0x7, 0x5, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x1, 0x0, 0x3, 0x73, 0x75, 0x6d, 0x0, 0x0, 0x6, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x3, 0x0, 0x7, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x31, 0x3, 0x1, 0x7, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x32, 0x3, 0x2, 0x7, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x33, 0x3, 0x3, 0x7, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x34, 0x3, 0x4, 0x9, 0x7, 0x1, 0x0, 0x41, 0x0, 0xb, 0x1, 0x0, 0xa, 0x9, 0x1, 0x7, 0x0, 0x20, 0x1, 0x20, 0x0, 0x6a, 0xb]);
//var wasmCode = new Uint8Array([0x0,0x61,0x73,0x6d,0x1,0x0,0x0,0x0,0x1,0x8,0x2,0x60,0x1,0x7f,0x0,0x60,0x0,0x0,0x2,0x19,0x1,0x7,0x69,0x6d,0x70,0x6f,0x72,0x74,0x73,0xd,0x69,0x6d,0x70,0x6f,0x72,0x74,0x65,0x64,0x5f,0x66,0x75,0x6e,0x63,0x0,0x0,0x3,0x2,0x1,0x1,0x7,0x11,0x1,0xd,0x65,0x78,0x70,0x6f,0x72,0x74,0x65,0x64,0x5f,0x66,0x75,0x6e,0x63,0x0,0x1,0xa,0x8,0x1,0x6,0x0,0x41,0x12,0x10,0x0,0xb]);
//////////////////////////////////////////////////////////////INIT
try {
var wasmModule = new WebAssembly.Module(wasmCode);
var wasmInstance = new WebAssembly.Instance(wasmModule, importObject);
print('[+] wasmCode validate.');
print(WebAssembly.validate(wasmCode));
}
catch (e) { print(e); }
////////////////////////////////////////////////////////////EXPORTS
try {
var wasmInstanceExported = wasmInstance.exports;
print('[+] wasmInstanceExported.');
try {
var wasmInstanceExportedTable = wasmInstance.exports.table;
for (var i = 0; i < 100; i++) {
print(wasmInstanceExportedTable.get(i));
var f = wasmInstanceExportedTable.get(i);
try {
var res = f(i);
res = f(5.40900887767170327461014974881E-315);
res = f({});
}
catch (e) { print(e); }
}
}
catch (e) { print(e); }
try {
print(wasmInstanceExported.main(0));
}
catch (e) { print(e); }
try {
for (var i in wasmInstanceExported) {
try {
print(eval('wasmInstanceExported.' + i + ';'));
}
catch (e) { print(e); }
try {
print(eval('wasmInstanceExported.' + i + '(0);'));
}
catch (e) { print(e); }
}
}
catch (e) { print(e); }
var wasmModuleExports = WebAssembly.Module.exports(wasmModule);
var varExports = [];
print('[+] wasmModuleExported.')
for (var i of wasmModuleExports) {
print(i + ' : ' + i.kind + ' : ' + i.name);
varExports.push(i.name);
}
for (var i of varExports) {
try {
print(eval('wasmInstanceExported.' + i + ';'));
}
catch (e) { print(e); }
try {
print(eval('wasmInstanceExported.' + i + '(0);'));
}
catch (e) { print(e); }
}
}
catch (e) { print(e) };
//////////////////////////////////////////////////////////////IMPORTS
try {
var wasmModuleImports = WebAssembly.Module.imports(wasmModule);
var varImports = [];
print('[+] wasmModuleImported.');
for (var i of wasmModuleImports) {
print(i + ' : ' + i.kind + ' : ' + i.name + ' : ' + i.module);
varImports.push(i.name);
}
for(var scalar of varImports){
print(scalar);
}
}
catch (e) { print(e) };
///////////////////////////////////////////////////////////////CUSTOM
try {
var sections = WebAssembly.Module.customSections(wasmModule, 'custom');
for(var i in sections){
print(sections[i]);
}
sections = WebAssembly.Module.customSections(wasmModule, 'name');
for(var i in sections){
print(sections[i]);
}
sections = WebAssembly.Module.customSections(wasmModule, 'unknown');
for(var i in sections){
print(sections[i]);
}
sections = WebAssembly.Module.customSections(wasmModule, '');
for(var i in sections){
print(sections[i]);
}
}
catch (e) { print(e); }
//////////////////////////////////////////////////////////////END
print('[+] End.');