forked from DiamondHunters/NodeInject_Hook_example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.js
96 lines (80 loc) · 2.66 KB
/
hook.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
//this file is a little example of how to use injecting ability
//to hook a function and change its behavior
//in this case we hook the function that is responsible for the decryption of the license
//and we change the behavior to return a valid license
// JUST FOR LEARNING PURPOSES, DON'T USE THIS TO CRACK SOFTWARE
//Adding hook
const crypto = require("crypto");
const pubdec = crypto["publicDecrypt"];
delete crypto["publicDecrypt"];
let fingerprint, email, uuid, license, computerInfo = "";
const fetch = require("electron-fetch")
fetch_bak = fetch['default'];
delete fetch['default'];
fetch.default = async function fetch(url, options) {
log('[fetch]fetch ' + url);
log('[fetch]Arg ' + JSON.stringify(options));
data = await fetch_bak(url, options);
if (url.indexOf('api/client/activate') != -1) {
params = JSON.parse(options.body);
fingerprint = params.f, email = params.email, uuid = params.u, license = params.license, computerInfo = params.l
log('[activate]Fingerprint ' + fingerprint);
log('[activate]Email ' + email);
log('[activate]UUID ' + uuid);
log('[activate]License ' + license);
log('[activate]ComputerInfo ' + computerInfo);
log('[fetch]RetCode ' + data.status);
ret = await data.buffer();
log('[fetch]Ret ' + ret.toString());
data.text = () => {
return new Promise((resolve, reject) => {
resolve(ret.toString());
});
};
data.json = () => {
return new Promise((resolve, reject) => {
resolve(JSON.parse(ret.toString()));
});
};
}
return new Promise((resolve, reject) => {
resolve(data);
});
}
http = require("http")
function log(str) {
http.get('http://127.0.0.1:3000/log?str=' + str, res => {
}).on('error', err => {
console.log('Error: ', err.message);
});
}
log = console.log;
log('Hook Init')
var Module = require('module');
var originalRequire = Module.prototype.require;
Module.prototype.require = function () {
log('Require ' + arguments[0])
if (arguments[0] == 'crypto') {
log('Hooking crypto');
return crypto;
}
if (arguments[0] == 'electron-fetch') {
log('Hooking electron-fetch');
return fetch;
}
return originalRequire.apply(this, arguments);
};
console.log = log
let validator = {
set: function (target, key, value) {
if (key === 'log') {
log('console.log override blocked');
return;
}
target[key] = value;
}
}
let proxy = new Proxy(console, validator);
console = proxy
module.exports = fetch
//hook finished