-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtargets.js
62 lines (58 loc) · 2.26 KB
/
targets.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
var ptr_WSAStartup = Module.getExportByName(null, "WSAStartup");
var isDumped = false;
var PROTECTION = 'wr-';
var TARGET_STRING = '"targets":[';
function stringToByteArray(str) {
var byteArray = [];
for (var i = 0; i < str.length; i++) {
var charCode = str.charCodeAt(i);
byteArray.push(charCode);
}
return byteArray;
}
function indexOfBuffer(buf, search) {
let searchBytes = stringToByteArray(search);
let searchLen = searchBytes.length;
let max = buf.byteLength - searchLen;
outer: for (let i = 0; i <= max; i++) {
for (let j = 0; j < searchLen; j++) {
if (buf[i + j] !== searchBytes[j])
continue outer;
}
return i;
}
return -1;
}
Interceptor.attach(ptr_WSAStartup, {
onEnter: function (args) {
if (!isDumped) {
isDumped = true;
setTimeout(function() {
let ranges = Process.enumerateRanges(PROTECTION);
console.log('[BEGIN] Memory ranges located: ' + ranges.length);
ranges.forEach(function (range) {
let buffer = null;
try {
buffer = new Uint8Array(range.base.readByteArray(range.size));
if (indexOfBuffer(buffer, TARGET_STRING) !== -1) {
let destFileName = `dumps/${range.base}_dump`;
let file = new File(destFileName, 'wb');
file.write(buffer);
file.flush();
file.close();
console.log('[DUMP] Memory dumped: ' + destFileName);
}
} catch (e) {
console.log('[ERROR] Failed to dump memory at: ' + range.base + ' Error: ' + e.message);
}
});
console.log('[END] Memory dump process completed');
let ExitProcess = new NativeFunction(Module.getExportByName(null, 'ExitProcess'), 'void', ['uint']);
ExitProcess(0);
}, 15000); // Espera de 15 segundos
}
},
onLeave: function (retval) {
//TODO: Limpieza
}
});