MrA7A commited on
Commit
1a38bc4
·
verified ·
1 Parent(s): 171e021

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +426 -819
app.py CHANGED
@@ -1,763 +1,398 @@
1
- import os
2
- import json
3
- import logging
4
- import asyncio
5
- import aiohttp
6
  from fastapi import FastAPI, HTTPException, BackgroundTasks
7
- from fastapi.responses import HTMLResponse, JSONResponse
8
- from pydantic import BaseModel, Field
9
- from typing import List, Dict, Optional, Any
10
- import torch
11
- from transformers import (
12
- AutoTokenizer,
13
- AutoModelForCausalLM,
14
- pipeline,
15
- StoppingCriteria,
16
- StoppingCriteriaList,
17
- )
18
- import requests
19
- import re
20
  import time
21
- from datetime import datetime
22
  import hashlib
23
- import nest_asyncio
24
- import warnings
25
- warnings.filterwarnings("ignore")
26
-
27
- # تطبيق nest-asyncio للتعامل مع الأحداث غير المتزامنة
28
- nest_asyncio.apply()
29
-
30
- # التهيئة الأساسية
31
- os.environ["HF_HOME"] = "/tmp/hf_cache"
32
- os.environ["TRANSFORMERS_CACHE"] = "/tmp/hf_cache/transformers"
33
- os.makedirs("/tmp/hf_cache", exist_ok=True)
34
-
35
- app = FastAPI(title="نظام الذكاء الاصطناعي المتقدم للتحكم في Windows")
36
 
37
- # إعداد التسجيل
38
- logging.basicConfig(
39
- level=logging.INFO,
40
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
41
- )
42
  logger = logging.getLogger(__name__)
43
 
44
- # نماذج البيانات
45
- class WindowsTask(BaseModel):
46
- task_description: str = Field(..., min_length=5, max_length=2000)
47
- task_type: str = "analysis"
48
- game_name: Optional[str] = None
49
- priority: str = "normal"
50
 
51
- class ClientCommand(BaseModel):
 
 
 
 
 
52
  command_type: str
53
- parameters: Dict[str, Any]
 
 
54
  client_id: Optional[str] = None
55
 
56
- class ClientResponse(BaseModel):
57
  client_id: str
58
- command_id: str
59
- status: str
60
- results: Dict[str, Any]
61
- error: Optional[str] = None
62
-
63
- # نموذج التوقف المخصص
64
- class StopOnTokens(StoppingCriteria):
65
- def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
66
- stop_ids = [50256, 198, 50256, 829, 25779]
67
- for stop_id in stop_ids:
68
- if input_ids[0][-1] == stop_id:
69
- return True
70
- return False
71
-
72
- # النظام الأساسي المتقدم للذكاء الاصطناعي
73
- class WindowsAIAdvisor:
74
- def __init__(self):
75
- self.tokenizer = None
76
- self.model = None
77
- self.pipeline = None
78
- self.is_loaded = False
79
- self.connected_clients = {}
80
- self.load_models()
81
-
82
- def load_models(self):
83
- """تحميل النماذج المتخصصة"""
84
- try:
85
- logger.info("جارٍ تحميل النماذج المتخصصة...")
86
-
87
- # استخدام نموذج أخف وأكثر توافقاً
88
- model_name = "microsoft/DialoGPT-small" # تغيير إلى small بدلاً من medium
89
-
90
- self.tokenizer = AutoTokenizer.from_pretrained(
91
- model_name,
92
- cache_dir="/tmp/hf_cache",
93
- padding_side="left"
94
- )
95
-
96
- if self.tokenizer.pad_token is None:
97
- self.tokenizer.pad_token = self.tokenizer.eos_token
98
-
99
- # تحميل النموذج بـ float32 بدلاً من float16 لتجنب مشاكل Half
100
- self.model = AutoModelForCausalLM.from_pretrained(
101
- model_name,
102
- cache_dir="/tmp/hf_cache",
103
- torch_dtype=torch.float32, # تغيير إلى float32
104
- device_map="auto",
105
- low_cpu_mem_usage=True
106
- )
107
-
108
- # إنشاء pipeline مع إعدادات آمنة
109
- self.pipeline = pipeline(
110
- "text-generation",
111
- model=self.model,
112
- tokenizer=self.tokenizer,
113
- max_new_tokens=512, # تقليل الطول لتجنب المشاكل
114
- temperature=0.7,
115
- do_sample=True,
116
- top_p=0.9,
117
- pad_token_id=self.tokenizer.eos_token_id,
118
- stopping_criteria=StoppingCriteriaList([StopOnTokens()])
119
- )
120
-
121
- self.is_loaded = True
122
- logger.info("تم تحميل النماذج بنجاح!")
123
-
124
- except Exception as e:
125
- logger.error(f"فشل تحميل النماذج: {e}")
126
- # سنستمر بدون النموذج ولكن بوظائف محدودة
127
-
128
- def generate_ai_response(self, prompt: str, context: List[Dict] = None) -> str:
129
- """توليد رد الذكاء الاصطناعي"""
130
- try:
131
- if not self.is_loaded:
132
- return self.get_fallback_response(prompt)
133
-
134
- system_context = """
135
- أنت مساعد ذكي متخصص في تحليل واختراق ألعاب Windows وبناء البوتات المتقدمة.
136
- خبرتك تشمل:
137
- - تحليل الذاكرة وعمليات الألعاب
138
- - هندسة عكسية للتطبيقات
139
- - بناء بوتات ألعاب متطورة
140
- - تحليل الشبكات والحزم
141
- - تعديل الملفات والسجلات
142
- - أتمتة المهام المعقدة
143
-
144
- قم بتقديم إجابات تقنية مفصلة مع خطوات تنفيذ عملية.
145
- """
146
-
147
- full_prompt = f"{system_context}\n\nالمهمة: {prompt}\n\nالإجابة المتخصصة:"
148
-
149
- # استخدام try-except للتعامل مع الأخطاء أثناء التوليد
150
- with torch.no_grad():
151
- response = self.pipeline(
152
- full_prompt,
153
- max_new_tokens=400, # تقليل الطول
154
- temperature=0.7,
155
- do_sample=True,
156
- top_k=50,
157
- repetition_penalty=1.1
158
- )
159
-
160
- generated_text = response[0]['generated_text']
161
- answer = generated_text.replace(full_prompt, "").strip()
162
-
163
- # تنظيف الإجابة
164
- answer = re.sub(r'<\|.*?\|>', '', answer)
165
- answer = re.sub(r'\n+', '\n', answer).strip()
166
-
167
- return answer if answer else self.get_fallback_response(prompt)
168
-
169
- except Exception as e:
170
- logger.error(f"فشل توليد الرد: {e}")
171
- return self.get_fallback_response(prompt)
172
-
173
- def get_fallback_response(self, prompt: str) -> str:
174
- """رد بديل عندما يفشل النموذج"""
175
- fallback_responses = {
176
- 'تحليل': f"""
177
- خطة تحليل متقدمة للمهمة: {prompt}
178
-
179
- الخطوات المقترحة:
180
- 1. استخدام Cheat Engine لفحص ذاكرة اللعبة
181
- 2. البحث عن عناوين القيم المطلوبة (ذهب، خبرة، إلخ)
182
- 3. تحليل الهياكل البيانات في الذاكرة
183
- 4. كتابة سكريبت للقراءة/الكتابة في الذاكرة
184
- 5. اختبار السكريبت وتعديله
185
-
186
- الأدوات المطلوبة:
187
- - Cheat Engine
188
- - Process Hacker
189
- - x64dbg
190
- - Visual Studio للكتابة
191
- """,
192
-
193
- 'بوت': f"""
194
- خطة بناء بوت للمهمة: {prompt}
195
-
196
- الهيكل المقترح للبوت:
197
- 1. وحدة الكشف عن النوافذ والعمليات
198
- 2. وحدة معالجة الصور (OpenCV)
199
- 3. وحدة المحاكاة (pyautogui)
200
- 4. وحدة المنطق الرئيسي
201
- 5. وحدة المراقبة والحماية
202
-
203
- التقنيات المقترحة:
204
- - C++ للأداء العالي
205
- - تقنيات التخفي
206
- - معالجة الصور للكشف
207
- - محاكاة الإدخال
208
- """,
209
-
210
- 'تثبيت': f"""
211
- خطة تثبيت البرامج للمهمة: {prompt}
212
-
213
- البرامج المطلوبة:
214
- - Cheat Engine: لأدوات تحليل الذاكرة
215
- - Visual Studio: لتطوير البرامج
216
- - Python: للبرمجة
217
- - Process Hacker: لمراقبة العمليات
218
-
219
- طريقة التثبيت:
220
- 1. تحميل البرامج من المواقع الرسمية
221
- 2. التثبيت كمسؤول
222
- 3. تهيئة الإعدادات
223
- 4. اختبار العمل
224
- """,
225
-
226
- 'افتراضي': f"""
227
- خطة تنفيذ المهمة: {prompt}
228
-
229
- المراحل الرئيسية:
230
- 1. التحليل والتخطيط
231
- 2. جمع الأدوات والمعلومات
232
- 3. التنفيذ العملي
233
- 4. الاختبار والتعديل
234
- 5. التوثيق
235
-
236
- نصائح تقنية:
237
- - ابدأ بالتحليل قبل التنفيذ
238
- - احتفظ بنسخ احتياطية
239
- - اختبر في بيئة آمنة أولاً
240
- - وثق كل الخطوات
241
- """
242
- }
243
-
244
- # تحديد نوع الرد المناسب
245
- prompt_lower = prompt.lower()
246
- if any(word in prompt_lower for word in ['تحليل', 'analyze', 'فحص']):
247
- return fallback_responses['تحليل']
248
- elif any(word in prompt_lower for word in ['بوت', 'bot', 'أتمتة']):
249
- return fallback_responses['بوت']
250
- elif any(word in prompt_lower for word in ['تثبيت', 'install', 'برنامج']):
251
- return fallback_responses['تثبيت']
252
- else:
253
- return fallback_responses['افتراضي']
254
-
255
- def analyze_task(self, task_description: str) -> Dict:
256
- """تحليل المهمة وإنشاء خطة تنفيذ"""
257
- try:
258
- analysis_prompt = f"""
259
- قم بتحليل المهمة التالية وإنشاء خطة تنفيذ مفصلة للعميل على Windows:
260
- {task_description}
261
-
262
- قدم خطة تنفيذ تشمل:
263
- 1. الأدوات المطلوبة
264
- 2. الخطوات التقنية
265
- 3. الأوامر المطلوبة
266
- 4. المخاطر المحتملة
267
- 5. البدائل
268
-
269
- ركز على الجانب العملي والتنفيذي.
270
- """
271
-
272
- plan = self.generate_ai_response(analysis_prompt)
273
-
274
- return {
275
- "plan": plan,
276
- "steps": self.extract_execution_steps(plan),
277
- "tools": self.extract_required_tools(plan),
278
- "commands": self.generate_client_commands(plan, task_description)
279
- }
280
- except Exception as e:
281
- logger.error(f"فشل تحليل المهمة: {e}")
282
- return {
283
- "plan": self.get_fallback_response(task_description),
284
- "steps": [
285
- "تحليل المتطلبات والمخاطر",
286
- "جمع الأدوات والبرامج المطلوبة",
287
- "تنفيذ الخطوات التقنية",
288
- "اختبار النتائج",
289
- "توثيق العمل"
290
- ],
291
- "tools": ["Cheat Engine", "Process Hacker", "Visual Studio", "Python"],
292
- "commands": []
293
- }
294
 
295
- def extract_execution_steps(self, plan: str) -> List[str]:
296
- """استخراج خطوات التنفيذ من الخطة"""
297
- steps = []
298
- lines = plan.split('\n')
299
-
300
- for line in lines:
301
- line = line.strip()
302
- if any(marker in line for marker in ['1.', '2.', '3.', '4.', '5.', '- ', '• ', 'خطوة']):
303
- if len(line) > 10:
304
- clean_step = re.sub(r'^[0-9•\-\.,]+\s*', '', line)
305
- steps.append(clean_step)
306
-
307
- return steps[:10] if steps else [
308
- "إعداد البيئة والتجهيزات",
309
- "تحليل الهدف وتحديد المتطلبات",
310
- "تنفيذ الحل التقني",
311
- "اختبار وتقييم النتائج",
312
- "تحسين وتطوير الحل"
313
- ]
314
-
315
- def extract_required_tools(self, plan: str) -> List[str]:
316
- """استخراج الأدوات المطلوبة"""
317
- tools = []
318
- common_tools = [
319
- 'cheat engine', 'wireshark', 'process hacker', 'process explorer',
320
- 'x64dbg', 'ollydbg', 'ida', 'ghidra', 'dnspy', 'reflector',
321
- 'python', 'visual studio', 'net reflector', 'api monitor'
322
- ]
323
-
324
- plan_lower = plan.lower()
325
- for tool in common_tools:
326
- if tool in plan_lower:
327
- tools.append(tool.title())
328
-
329
- return tools if tools else ["Cheat Engine", "Process Hacker", "Debugger", "Python"]
330
-
331
- def generate_client_commands(self, plan: str, task_description: str) -> List[Dict]:
332
- """توليد أوامر للعميل"""
333
- commands = []
334
-
335
- task_lower = task_description.lower()
336
-
337
- if any(word in task_lower for word in ['تحليل', 'analyze', 'فحص']):
338
- commands.extend(self.generate_analysis_commands(task_description))
339
-
340
- if any(word in task_lower for word in ['بوت', 'bot', 'أتمتة', 'automation']):
341
- commands.extend(self.generate_bot_commands(task_description))
342
-
343
- if any(word in task_lower for word in ['تثبيت', 'install', 'برنامج']):
344
- commands.extend(self.generate_installation_commands(task_description))
345
-
346
- if any(word in task_lower for word in ['اختراق', 'hack', 'exploit']):
347
- commands.extend(self.generate_hacking_commands(task_description))
348
-
349
- return commands
350
-
351
- def generate_analysis_commands(self, task: str) -> List[Dict]:
352
- """توليد أوامر التحليل"""
353
- return [
354
- {
355
- "command_type": "analyze",
356
- "parameters": {
357
- "task": task,
358
- "analysis_type": "process_memory",
359
- "depth": "deep"
360
- },
361
- "description": "تحليل عمليات وذاكرة النظام"
362
- }
363
- ]
364
-
365
- def generate_bot_commands(self, task: str) -> List[Dict]:
366
- """توليد أوامر بناء البوتات"""
367
- return [
368
- {
369
- "command_type": "create_bot",
370
- "parameters": {
371
- "task": task,
372
- "bot_type": self.detect_bot_type(task),
373
- "features": self.extract_bot_features(task)
374
- },
375
- "description": "بناء بوت متخصص"
376
- }
377
- ]
378
-
379
- def generate_installation_commands(self, task: str) -> List[Dict]:
380
- """توليد أوامر التثبيت"""
381
- tools = self.extract_tools_from_task(task)
382
- commands = []
383
-
384
- for tool in tools:
385
- commands.append({
386
- "command_type": "install",
387
- "parameters": {
388
- "tool_name": tool,
389
- "silent_mode": True
390
- },
391
- "description": f"تثبيت {tool}"
392
- })
393
-
394
- return commands
395
-
396
- def generate_hacking_commands(self, task: str) -> List[Dict]:
397
- """توليد أوامر الاختراق"""
398
- return [
399
- {
400
- "command_type": "analyze",
401
- "parameters": {
402
- "task": task,
403
- "analysis_type": "vulnerability_scan",
404
- "depth": "deep"
405
- },
406
- "description": "مسح الثغرات الأمنية"
407
- }
408
- ]
409
-
410
- def detect_bot_type(self, task: str) -> str:
411
- """الكشف عن نوع البوت المطلوب"""
412
- task_lower = task.lower()
413
-
414
- if any(word in task_lower for word in ['مزرعة', 'farming', 'farm']):
415
- return "farming"
416
- elif any(word in task_lower for word in ['قتال', 'combat', 'battle']):
417
- return "combat"
418
- elif any(word in task_lower for word in ['تعدين', 'mining', 'mine']):
419
- return "mining"
420
- elif any(word in task_lower for word in ['تداول', 'trading', 'trade']):
421
- return "trading"
422
- else:
423
- return "general"
424
-
425
- def extract_bot_features(self, task: str) -> List[str]:
426
- """استخراج ميزات البوت المطلوبة"""
427
- features = []
428
- task_lower = task.lower()
429
-
430
- feature_mapping = {
431
- 'تلقائي': 'auto_detect',
432
- 'ذكي': 'smart_detection',
433
- 'سريع': 'fast_execution',
434
- 'آمن': 'safe_mode',
435
- 'مخفي': 'stealth_mode',
436
- 'متقدم': 'advanced_features'
437
- }
438
-
439
- for arabic, english in feature_mapping.items():
440
- if arabic in task_lower or english in task_lower:
441
- features.append(english)
442
-
443
- return features
444
-
445
- def extract_tools_from_task(self, task: str) -> List[str]:
446
- """استخراج الأدوات المطلوبة من المهمة"""
447
- tools = []
448
- task_lower = task.lower()
449
-
450
- tool_mapping = {
451
- 'cheat engine': 'cheat_engine',
452
- 'wireshark': 'wireshark',
453
- 'process hacker': 'process_hacker',
454
- 'x64dbg': 'x64dbg',
455
- 'ollydbg': 'ollydbg',
456
- 'ida': 'ida',
457
- 'ghidra': 'ghidra',
458
- 'python': 'python'
459
- }
460
-
461
- for tool_name, tool_id in tool_mapping.items():
462
- if tool_name in task_lower:
463
- tools.append(tool_id)
464
-
465
- return tools
466
-
467
- def register_client(self, client_id: str, client_info: Dict):
468
- """تسجيل عميل جديد"""
469
- self.connected_clients[client_id] = {
470
- **client_info,
471
- "last_seen": datetime.now(),
472
- "status": "connected"
473
- }
474
- logger.info(f"تم تسجيل العميل: {client_id}")
475
-
476
- # تهيئة النظام
477
- ai_advisor = WindowsAIAdvisor()
478
-
479
- # واجهة HTML بسيطة مدمجة في الكود
480
  HTML_INTERFACE = """
481
  <!DOCTYPE html>
482
  <html lang="ar" dir="rtl">
483
  <head>
484
  <meta charset="UTF-8">
485
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
486
- <title>نظام الذكاء الاصطناعي للتحكم في Windows</title>
487
  <style>
488
- * {
489
- margin: 0; padding: 0; box-sizing: border-box;
490
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
491
- }
492
- body {
493
- background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
494
- color: white;
495
- min-height: 100vh;
496
- padding: 20px;
497
- }
498
- .container {
499
- max-width: 1200px;
500
- margin: 0 auto;
501
- }
502
- .header {
503
- text-align: center;
504
- margin-bottom: 30px;
505
- padding: 30px;
506
- background: rgba(255, 255, 255, 0.1);
507
- border-radius: 15px;
508
- backdrop-filter: blur(10px);
509
- border: 1px solid rgba(255, 255, 255, 0.2);
510
- }
511
- .card {
512
- background: rgba(255, 255, 255, 0.1);
513
- padding: 25px;
514
- margin: 20px 0;
515
- border-radius: 12px;
516
- backdrop-filter: blur(10px);
517
- border: 1px solid rgba(255, 255, 255, 0.2);
518
- }
519
- textarea, input, select, button {
520
- width: 100%;
521
- padding: 15px;
522
- margin: 10px 0;
523
- border-radius: 8px;
524
- border: none;
525
- font-size: 16px;
526
- }
527
- textarea {
528
- min-height: 120px;
529
- resize: vertical;
530
- background: rgba(255, 255, 255, 0.9);
531
- }
532
- select, input {
533
- background: rgba(255, 255, 255, 0.9);
534
- }
535
- button {
536
- background: linear-gradient(135deg, #e94560, #c23616);
537
- color: white;
538
- cursor: pointer;
539
- font-weight: bold;
540
- transition: all 0.3s ease;
541
- }
542
- button:hover {
543
- transform: translateY(-2px);
544
- box-shadow: 0 5px 15px rgba(233, 69, 96, 0.4);
545
- }
546
- .result {
547
- background: rgba(45, 52, 54, 0.8);
548
- padding: 20px;
549
- border-radius: 8px;
550
- margin: 15px 0;
551
- white-space: pre-wrap;
552
- border-left: 4px solid #e94560;
553
- }
554
- .quick-actions {
555
- display: grid;
556
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
557
- gap: 15px;
558
- margin: 20px 0;
559
- }
560
- .quick-btn {
561
- background: rgba(233, 69, 96, 0.2);
562
- padding: 15px;
563
- border-radius: 8px;
564
- text-align: center;
565
- cursor: pointer;
566
- transition: all 0.3s ease;
567
- border: 1px solid rgba(233, 69, 96, 0.3);
568
- }
569
- .quick-btn:hover {
570
- background: rgba(233, 69, 96, 0.4);
571
- transform: translateY(-2px);
572
- }
573
- .status {
574
- padding: 10px;
575
- border-radius: 5px;
576
- margin: 10px 0;
577
- text-align: center;
578
- font-weight: bold;
579
- }
580
- .status.connected { background: rgba(39, 174, 96, 0.3); }
581
- .status.error { background: rgba(231, 76, 60, 0.3); }
582
- .status.loading { background: rgba(241, 196, 15, 0.3); }
583
  </style>
584
  </head>
585
  <body>
586
  <div class="container">
587
  <div class="header">
588
- <h1>🖥️ نظام الذكاء الاصطناعي للتحكم في Windows</h1>
589
- <p>أدخل المهمة المطلوبة وسيتم توليد خطة تنفيذ مفصلة للعميل على Windows</p>
590
- <div id="systemStatus" class="status loading">جار�� التحقق من حالة النظام...</div>
591
  </div>
592
-
593
- <div class="card">
594
- <h3>🎯 إدخال المهمة</h3>
595
- <textarea id="taskInput" rows="5" placeholder="مثال: قم بتحليل لعبة Genshin Impact وابني بوتاً للتعدين التلقائي..."></textarea>
596
- <select id="taskType">
597
- <option value="analysis">تحليل لعبة</option>
598
- <option value="bot_creation">بناء بوت</option>
599
- <option value="hacking">تحليل اختراق</option>
600
- <option value="software_install">تثبيت برامج</option>
601
- </select>
602
- <button onclick="analyzeTask()">🚀 تحليل المهمة وتوليد الخطة</button>
603
-
604
- <div class="quick-actions">
605
- <div class="quick-btn" onclick="loadExample('analysis')">🔍 تحليل الذاكرة</div>
606
- <div class="quick-btn" onclick="loadExample('farming')">👨‍🌾 بوت المزرعة</div>
607
- <div class="quick-btn" onclick="loadExample('combat')">⚔️ بوت القتال</div>
608
- <div class="quick-btn" onclick="loadExample('install')">📦 تثبيت أدوات</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
  </div>
610
  </div>
611
-
612
- <div class="card">
613
- <h3>📊 نتائج التحليل</h3>
614
- <div id="results">
615
- <div class="result">النتائج ستظهر هنا بعد تحليل المهمة...</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
  </div>
617
  </div>
618
 
619
- <div class="card">
620
- <h3>🔧 معلومات النظام</h3>
621
- <div id="systemInfo">
622
- <div class="result">جاري تحميل معلومات النظام...</div>
 
 
 
 
 
 
 
 
 
 
 
623
  </div>
624
  </div>
625
  </div>
626
 
627
  <script>
628
- // تحميل أمثلة سريعة
629
- function loadExample(type) {
630
- const examples = {
631
- 'analysis': 'قم بتحليل ذاكرة لعبة Genshin Impact للعثور على عناوين الذهب والخبرة والمستوى',
632
- 'farming': 'ابني بوت مزرعة تلقائي للعبة Black Desert Online لزراعة المحاصيل وجمع الموارد',
633
- 'combat': 'أنشئ بوت قتال ذكي للعبة World of Warcraft يستهدف الأعداء تلقائياً ويستخدم المهارات',
634
- 'install': 'قائمة البرامج المطلوبة لتطوير بوتات الألعاب: Cheat Engine, Visual Studio, Python, Process Hacker'
635
- };
636
 
637
- document.getElementById('taskInput').value = examples[type] || examples['analysis'];
 
638
  }
639
 
640
- // فحص حالة النظام
641
- async function checkSystemStatus() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
642
  try {
643
- const response = await fetch('/api/system/status');
644
  const data = await response.json();
645
-
646
- const statusElement = document.getElementById('systemStatus');
647
  if (data.success) {
648
- statusElement.className = 'status connected';
649
- statusElement.innerHTML = `✅ النظام يعمل - النموذج: ${data.data.ai_model_loaded ? 'محمّل' : 'وضع استشاري'}`;
650
- } else {
651
- statusElement.className = 'status error';
652
- statusElement.innerHTML = '❌ هناك مشكلة في النظام';
653
  }
654
  } catch (error) {
655
- document.getElementById('systemStatus').className = 'status error';
656
- document.getElementById('systemStatus').innerHTML = '❌ خطأ في الاتصال';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
657
  }
 
 
658
  }
659
 
660
- // تحليل المهمة
661
- async function analyzeTask() {
662
- const task = document.getElementById('taskInput').value;
663
- const taskType = document.getElementById('taskType').value;
664
 
665
- if (!task || task.includes('أدخل المهمة')) {
666
- alert('يرجى إدخال المهمة المطلوبة');
667
  return;
668
  }
669
 
670
- document.getElementById('results').innerHTML = '<div class="status loading">جاري تحليل المهمة وتوليد الخطة...</div>';
671
 
672
  try {
673
- const response = await fetch('/api/analyze-task', {
674
  method: 'POST',
675
- headers: {
676
- 'Content-Type': 'application/json',
677
- 'Accept': 'application/json'
678
- },
679
- body: JSON.stringify({
680
- task_description: task,
681
- task_type: taskType,
682
- priority: 'high'
683
- })
684
  });
685
-
686
  const data = await response.json();
687
- displayResults(data);
688
  } catch (error) {
689
- document.getElementById('results').innerHTML =
690
- '<div class="status error">❌ خطأ في الاتصال: ' + error.message + '</div>';
691
  }
692
  }
693
-
694
- // عرض النتائج
695
- function displayResults(data) {
696
- let html = '';
697
- if (data.success) {
698
- const analysis = data.data.analysis;
699
-
700
- html += `<div class="result">
701
- <h4>🎯 خطة التنفيذ:</h4>
702
- ${analysis.plan.replace(/\n/g, '<br>')}
703
- </div>`;
704
-
705
- html += `<div class="result">
706
- <h4>🛠️ الأدوات المطلوبة:</h4>
707
- ${analysis.tools.map(tool => `• ${tool}`).join('<br>')}
708
- </div>`;
709
-
710
- html += `<div class="result">
711
- <h4>📋 خطوات التنفيذ:</h4>
712
- ${analysis.steps.map((step, index) => `${index + 1}. ${step}`).join('<br>')}
713
- </div>`;
714
-
715
- if (data.data.generated_commands && data.data.generated_commands.length > 0) {
716
- html += `<div class="result">
717
- <h4>⚡ الأوامر المولدة:</h4>
718
- ${data.data.generated_commands.map(cmd =>
719
- `• <strong>${cmd.description}</strong><br> النوع: ${cmd.command_type}`
720
- ).join('<br>')}
721
- </div>`;
722
- }
723
- } else {
724
- html = `<div class="status error">❌ خطأ: ${data.detail || 'حدث خطأ غير معروف'}</div>`;
725
  }
726
- document.getElementById('results').innerHTML = html;
727
  }
728
 
729
- // تحميل معلومات النظام
730
- async function loadSystemInfo() {
 
 
 
 
 
 
 
 
 
 
731
  try {
732
- const response = await fetch('/api/system/status');
 
 
 
 
 
 
 
733
  const data = await response.json();
734
-
735
- if (data.success) {
736
- const info = data.data;
737
- document.getElementById('systemInfo').innerHTML = `
738
- <div class="result">
739
- • حالة النموذج: ${info.ai_model_loaded ? '🟢 محمّل' : '🟡 وضع استشاري'}<br>
740
- • العملاء المتصلين: ${info.connected_clients}<br>
741
- • حالة الخادم: ${info.server_uptime}<br>
742
- • آخر تحديث: ${new Date(info.timestamp).toLocaleString('ar-EG')}
743
- </div>
744
- `;
745
  }
746
  } catch (error) {
747
- document.getElementById('systemInfo').innerHTML =
748
- '<div class="status error">❌ لا يمكن تحميل معلومات النظام</div>';
749
  }
750
  }
751
 
752
- // التهيئة عند تحميل الصفحة
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
753
  document.addEventListener('DOMContentLoaded', function() {
754
- checkSystemStatus();
755
- loadSystemInfo();
756
- // تحديث المعلومات كل 30 ثانية
757
- setInterval(() => {
758
- checkSystemStatus();
759
- loadSystemInfo();
760
- }, 30000);
761
  });
762
  </script>
763
  </body>
@@ -767,148 +402,120 @@ HTML_INTERFACE = """
767
  # نقاط النهاية
768
  @app.get("/")
769
  async def read_root():
770
- """الصفحة الرئيسية"""
771
  return HTMLResponse(content=HTML_INTERFACE)
772
 
773
- @app.post("/api/analyze-task")
774
- async def analyze_windows_task(task: WindowsTask):
775
- """تحليل المهمة وإنشاء خطة تنفيذ"""
776
- try:
777
- analysis = ai_advisor.analyze_task(task.task_description)
778
-
779
- return {
780
- "success": True,
781
- "data": {
782
- "task_id": f"task_{int(time.time())}",
783
- "analysis": analysis,
784
- "generated_commands": analysis["commands"],
785
- "execution_plan": analysis["plan"]
786
- }
787
- }
788
- except Exception as e:
789
- logger.error(f"Error in analyze-task: {e}")
790
- raise HTTPException(status_code=500, detail=str(e))
791
-
792
- @app.post("/api/generate-bot")
793
- async def generate_bot_script(task: WindowsTask):
794
- """توليد سكريبت بوت متخصص"""
795
- try:
796
- bot_code = ai_advisor.generate_ai_response(f"أنشئ كود بوت للغرض: {task.task_description}")
797
-
798
- return {
799
- "success": True,
800
- "data": {
801
- "bot_script": bot_code,
802
- "language": "cpp",
803
- "features": ai_advisor.extract_bot_features(task.task_description),
804
- "compilation_instructions": generate_compilation_instructions(bot_code)
805
- }
806
- }
807
- except Exception as e:
808
- logger.error(f"Error in generate-bot: {e}")
809
- raise HTTPException(status_code=500, detail=str(e))
810
-
811
- @app.post("/api/generate-exploit")
812
- async def generate_exploit_code(task: WindowsTask):
813
- """توليد كود استغلال متخصص"""
814
- try:
815
- exploit_code = ai_advisor.generate_ai_response(f"أنشئ كود استغلال للغرض: {task.task_description}")
816
-
817
- return {
818
- "success": True,
819
- "data": {
820
- "exploit_code": exploit_code,
821
- "techniques_used": extract_exploit_techniques(exploit_code),
822
- "risk_level": "high",
823
- "instructions": "يتطلب خبرة متقدمة في التنفيذ"
824
- }
825
- }
826
- except Exception as e:
827
- logger.error(f"Error in generate-exploit: {e}")
828
- raise HTTPException(status_code=500, detail=str(e))
829
-
830
- @app.post("/api/client/register")
831
- async def register_client(client_info: Dict):
832
- """تسجيل عميل جديد"""
833
- try:
834
- client_id = client_info.get("client_id", f"client_{int(time.time())}")
835
- ai_advisor.register_client(client_id, client_info)
836
-
837
- return {
838
- "success": True,
839
- "data": {
840
- "client_id": client_id,
841
- "status": "registered",
842
- "server_time": datetime.now().isoformat()
843
- }
844
- }
845
- except Exception as e:
846
- logger.error(f"Error in client register: {e}")
847
- raise HTTPException(status_code=500, detail=str(e))
848
 
849
- @app.get("/api/system/status")
850
- async def get_system_status():
851
- """الحصول على حالة النظام"""
852
- return {
853
- "success": True,
854
- "data": {
855
- "ai_model_loaded": ai_advisor.is_loaded,
856
- "connected_clients": len(ai_advisor.connected_clients),
857
- "server_uptime": "running",
858
- "timestamp": datetime.now().isoformat()
859
- }
 
 
860
  }
 
 
861
 
862
- @app.get("/health")
863
- async def health_check():
864
- """فحص صحة النظام"""
865
- return {
866
- "status": "healthy",
867
- "model_loaded": ai_advisor.is_loaded,
 
 
 
 
 
868
  "timestamp": datetime.now().isoformat()
869
  }
 
 
870
 
871
- def generate_compilation_instructions(code: str) -> str:
872
- """توليد تعليمات التجميع"""
873
- return """
874
- تعليمات التجميع للكود المولد:
 
875
 
876
- للغات C++:
877
- 1. استخدم Visual Studio 2022
878
- 2. عطل تحذيرات الأمان مؤقتاً
879
- 3. جمّع كـ Release x64
880
- 4. شغّل كمسؤول
 
 
 
 
 
 
 
881
 
882
- للغات C#:
883
- 1. استخدم .NET 6.0 أو أحدث
884
- 2. جمّع باستخدام: dotnet build
885
- 3. أو باستخدام: csc /out:program.exe source.cs
 
 
 
 
 
 
 
886
 
887
- نصائح عامة:
888
- - اختبر في بيئة معزولة أولاً
889
- - احتفظ بنسخ احتياطية
890
- - اقرأ التعليقات في الكود
891
- """
892
-
893
- def extract_exploit_techniques(code: str) -> List[str]:
894
- """استخراج تقنيات الاستغلال المستخدمة"""
895
- techniques = []
896
- code_lower = code.lower()
 
897
 
898
- technical_indicators = [
899
- ("memory", "writing", "كتابة الذاكرة"),
900
- ("injection", "حقن الكود"),
901
- ("hook", "الربط"),
902
- ("patch", " التصحيح"),
903
- ("bypass", "تجاوز الحماية")
904
- ]
905
 
906
- for indicator, description in technical_indicators:
907
- if indicator in code_lower:
908
- techniques.append(description)
 
 
 
 
 
 
 
 
 
 
 
 
 
909
 
910
- return techniques if techniques else [قنيات متقدمة لمعالجة الذاكرة"]
911
 
912
  if __name__ == "__main__":
913
  import uvicorn
914
- uvicorn.run(app, host="0.0.0.0", port=7860, log_level="info")
 
 
 
 
 
 
1
  from fastapi import FastAPI, HTTPException, BackgroundTasks
2
+ from fastapi.responses import HTMLResponse
3
+ from pydantic import BaseModel
4
+ from typing import Dict, List, Optional
5
+ import json
 
 
 
 
 
 
 
 
 
6
  import time
 
7
  import hashlib
8
+ from datetime import datetime
9
+ import logging
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ logging.basicConfig(level=logging.INFO)
 
 
 
 
12
  logger = logging.getLogger(__name__)
13
 
14
+ app = FastAPI(title="Windows AI Controller Server")
 
 
 
 
 
15
 
16
+ # تخزين البيانات
17
+ pending_commands = {}
18
+ client_connections = {}
19
+ task_results = {}
20
+
21
+ class WindowsCommand(BaseModel):
22
  command_type: str
23
+ target_game: Optional[str] = None
24
+ action: str
25
+ parameters: Dict = {}
26
  client_id: Optional[str] = None
27
 
28
+ class ClientConnection(BaseModel):
29
  client_id: str
30
+ machine_name: str
31
+ ip_address: str
32
+ last_seen: str
33
+ status: str = "online"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ # واجهة HTML الرئيسية
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  HTML_INTERFACE = """
37
  <!DOCTYPE html>
38
  <html lang="ar" dir="rtl">
39
  <head>
40
  <meta charset="UTF-8">
41
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
42
+ <title>Windows AI Controller - الخادم المركزي</title>
43
  <style>
44
+ * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
45
+ body { background: #0f0f23; color: #00ff00; padding: 20px; }
46
+ .container { max-width: 1400px; margin: 0 auto; }
47
+ .header { text-align: center; margin-bottom: 30px; padding: 30px; background: #1a1a2e; border-radius: 15px; border: 1px solid #00ff00; }
48
+ .panel { background: #16213e; padding: 25px; margin: 20px 0; border-radius: 12px; border: 1px solid #00ff00; }
49
+ .tabs { display: flex; margin-bottom: 20px; background: #1a1a2e; border-radius: 10px; padding: 5px; }
50
+ .tab { padding: 15px 25px; cursor: pointer; border-radius: 8px; margin: 0 5px; transition: all 0.3s; }
51
+ .tab.active { background: #00ff00; color: #0f0f23; }
52
+ .tab-content { display: none; }
53
+ .tab-content.active { display: block; }
54
+ input, select, textarea, button { width: 100%; padding: 12px; margin: 8px 0; border-radius: 8px; border: 1px solid #00ff00; background: #0f0f23; color: #00ff00; }
55
+ button { background: #00ff00; color: #0f0f23; font-weight: bold; cursor: pointer; border: none; }
56
+ button:hover { background: #00cc00; }
57
+ .client-item { background: #1a1a2e; padding: 15px; margin: 10px 0; border-radius: 8px; border-left: 4px solid #00ff00; }
58
+ .status-online { color: #00ff00; }
59
+ .status-offline { color: #ff4444; }
60
+ .command-log { background: #0f0f23; padding: 15px; border-radius: 8px; max-height: 300px; overflow-y: auto; font-family: 'Courier New', monospace; }
61
+ .game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; margin: 15px 0; }
62
+ .game-item { background: #1a1a2e; padding: 15px; border-radius: 8px; text-align: center; cursor: pointer; border: 1px solid #333; }
63
+ .game-item:hover { border-color: #00ff00; }
64
+ .result-box { background: #1a1a2e; padding: 15px; border-radius: 8px; margin: 10px 0; white-space: pre-wrap; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  </style>
66
  </head>
67
  <body>
68
  <div class="container">
69
  <div class="header">
70
+ <h1>🖥️ Windows AI Controller - الخادم المركزي</h1>
71
+ <p>تحكم كامل في جهاز Windows عن بعد عبر الذكاء الاصطناعي</p>
72
+ <div id="serverStatus" class="status-online">🟢 الخادم يعمل - جاهز للاتصال</div>
73
  </div>
74
+
75
+ <div class="tabs">
76
+ <div class="tab active" onclick="showTab('connection')">🔗 إدارة الاتصال</div>
77
+ <div class="tab" onclick="showTab('games')">🎮 إدارة الألعاب</div>
78
+ <div class="tab" onclick="showTab('analysis')">🔍 التحليل والتهكير</div>
79
+ <div class="tab" onclick="showTab('automation')">🤖 الأتمتة المتقدمة</div>
80
+ <div class="tab" onclick="showTab('results')">📊 النتائج والسجلات</div>
81
+ </div>
82
+
83
+ <!-- تبويب إدارة الاتصال -->
84
+ <div id="connection" class="tab-content active">
85
+ <div class="panel">
86
+ <h3>🔗 إعداد الاتصال بالعميل على Windows</h3>
87
+ <div class="result-box">
88
+ <strong>رابط الاتصال الخاص بك:</strong><br>
89
+ <input type="text" id="serverUrl" readonly style="background: #2a2a4a; color: #00ff00; font-family: monospace;">
90
+ <button onclick="copyServerUrl()">📋 نسخ رابط الاتصال</button>
91
+ </div>
92
+
93
+ <div class="result-box">
94
+ <strong>إضافة رابط العميل:</strong>
95
+ <input type="text" id="clientUrl" placeholder="أدخل الرابط الذي حصلت عليه من تطبيق Windows...">
96
+ <button onclick="addClientConnection()">➕ إضافة اتصال</button>
97
+ </div>
98
+ </div>
99
+
100
+ <div class="panel">
101
+ <h3>👥 العملاء المتصلين</h3>
102
+ <div id="clientsList">
103
+ <div class="client-item">
104
+ <div>🖥️ جهاز Windows الرئيسي</div>
105
+ <div class="status-online">🟢 متصل</div>
106
+ <div>IP: 192.168.1.100 | آخر نشاط: الآن</div>
107
+ </div>
108
+ </div>
109
+ <button onclick="refreshClients()">🔄 تحديث قائمة العملاء</button>
110
  </div>
111
  </div>
112
+
113
+ <!-- تبويب إدارة الألعاب -->
114
+ <div id="games" class="tab-content">
115
+ <div class="panel">
116
+ <h3>🎮 الألعاب المثبتة على النظام</h3>
117
+ <button onclick="scanGames()">🔍 مسح الألعاب المثبتة</button>
118
+ <div id="gamesList" class="game-list">
119
+ <!-- سيتم ملؤها ديناميكياً -->
120
+ </div>
121
+ </div>
122
+
123
+ <div class="panel">
124
+ <h3>🎯 اختيار لعبة للتحليل</h3>
125
+ <select id="gameSelect">
126
+ <option value="">-- اختر لعبة --</option>
127
+ </select>
128
+ <button onclick="selectGame()">✅ اختيار هذه اللعبة</button>
129
+ </div>
130
+ </div>
131
+
132
+ <!-- تبويب التحليل والتهكير -->
133
+ <div id="analysis" class="tab-content">
134
+ <div class="panel">
135
+ <h3>🔍 تحليل الذاكرة</h3>
136
+ <select id="analysisGame">
137
+ <option value="">-- اختر لعبة للتحليل --</option>
138
+ </select>
139
+ <select id="analysisType">
140
+ <option value="memory_scan">مسح الذاكرة</option>
141
+ <option value="pointer_scan">بحث عن المؤشرات</option>
142
+ <option value="value_scan">بحث عن القيم</option>
143
+ <option value="code_injection">حقن الكود</option>
144
+ </select>
145
+ <button onclick="startAnalysis()">🚀 بدء التحليل</button>
146
+ </div>
147
+
148
+ <div class="panel">
149
+ <h3>⚡ أدوات متقدمة</h3>
150
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
151
+ <button onclick="executeCommand('speed_hack')">⚡ تعديل السرعة</button>
152
+ <button onclick="executeCommand('god_mode')">🛡️ وضع الإله</button>
153
+ <button onclick="executeCommand('unlimited_money')">💰 مال غير محدود</button>
154
+ <button onclick="executeCommand('no_cooldown')">⏰ إلغاء التبريد</button>
155
+ </div>
156
+ </div>
157
+ </div>
158
+
159
+ <!-- تبويب الأتمتة -->
160
+ <div id="automation" class="tab-content">
161
+ <div class="panel">
162
+ <h3>🤖 إنشاء بوت مخصص</h3>
163
+ <textarea id="botDescription" rows="4" placeholder="صف البوت الذي تريد إنشاءه..."></textarea>
164
+ <select id="botType">
165
+ <option value="farming">بوت المزرعة</option>
166
+ <option value="combat">بوت القتال</option>
167
+ <option value="mining">بوت التعدين</option>
168
+ <option value="fishing">بوت الصيد</option>
169
+ </select>
170
+ <button onclick="generateBot()">🤖 إنشاء البوت</button>
171
+ </div>
172
+
173
+ <div class="panel">
174
+ <h3>🛠️ أدوات التطوير</h3>
175
+ <button onclick="openCheatEngine()">🧠 فتح Cheat Engine</button>
176
+ <button onclick="openProcessHacker()">🔍 فتح Process Hacker</button>
177
+ <button onclick="scanProcesses()">📊 مسح العمليات النشطة</button>
178
  </div>
179
  </div>
180
 
181
+ <!-- تبويب النتائج -->
182
+ <div id="results" class="tab-content">
183
+ <div class="panel">
184
+ <h3>📊 سجل التنفيذ</h3>
185
+ <div id="commandLog" class="command-log">
186
+ ● النظام جاهز للاستخدام<br>
187
+ ● انتظر الاتصال من عميل Windows...
188
+ </div>
189
+ </div>
190
+
191
+ <div class="panel">
192
+ <h3>📁 النتائج والملفات</h3>
193
+ <div id="resultsList">
194
+ <!-- سيتم ملؤها ديناميكياً -->
195
+ </div>
196
  </div>
197
  </div>
198
  </div>
199
 
200
  <script>
201
+ let selectedGame = '';
202
+ let connectedClients = [];
203
+
204
+ // عرض التبويب المحدد
205
+ function showTab(tabName) {
206
+ document.querySelectorAll('.tab').forEach(tab => tab.classList.remove('active'));
207
+ document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
 
208
 
209
+ event.target.classList.add('active');
210
+ document.getElementById(tabName).classList.add('active');
211
  }
212
 
213
+ // نسخ رابط الخادم
214
+ function copyServerUrl() {
215
+ const url = window.location.href;
216
+ navigator.clipboard.writeText(url).then(() => {
217
+ addToLog('✅ تم نسخ رابط الخادم: ' + url);
218
+ });
219
+ }
220
+
221
+ // إضافة اتصال عميل
222
+ function addClientConnection() {
223
+ const clientUrl = document.getElementById('clientUrl').value;
224
+ if (!clientUrl) {
225
+ alert('يرجى إدخال رابط العميل');
226
+ return;
227
+ }
228
+ addToLog('🔗 جاري الاتصال بالعميل: ' + clientUrl);
229
+ // هنا سيتم إضافة منطق الاتصال الفعلي
230
+ }
231
+
232
+ // مسح الألعاب
233
+ async function scanGames() {
234
+ addToLog('🔍 جاري مسح الألعاب المثبتة...');
235
  try {
236
+ const response = await fetch('/api/scan-games');
237
  const data = await response.json();
 
 
238
  if (data.success) {
239
+ displayGames(data.games);
240
+ addToLog('تم العثور على ' + data.games.length + ' لعبة');
 
 
 
241
  }
242
  } catch (error) {
243
+ addToLog(' خطأ في مسح الألعاب: ' + error.message);
244
+ }
245
+ }
246
+
247
+ // عرض الألعاب
248
+ function displayGames(games) {
249
+ const gamesList = document.getElementById('gamesList');
250
+ const gameSelect = document.getElementById('gameSelect');
251
+ const analysisGame = document.getElementById('analysisGame');
252
+
253
+ gamesList.innerHTML = '';
254
+ gameSelect.innerHTML = '<option value="">-- اختر لعبة --</option>';
255
+ analysisGame.innerHTML = '<option value="">-- اختر لعبة للتحليل --</option>';
256
+
257
+ games.forEach(game => {
258
+ // لعرض في القائمة
259
+ const gameItem = document.createElement('div');
260
+ gameItem.className = 'game-item';
261
+ gameItem.innerHTML = `🎮 ${game.name}`;
262
+ gameItem.onclick = () => selectGame(game.name);
263
+ gamesList.appendChild(gameItem);
264
+
265
+ // للإختيار من dropdown
266
+ const option1 = document.createElement('option');
267
+ option1.value = game.name;
268
+ option1.textContent = game.name;
269
+ gameSelect.appendChild(option1);
270
+
271
+ const option2 = document.createElement('option');
272
+ option2.value = game.name;
273
+ option2.textContent = game.name;
274
+ analysisGame.appendChild(option2);
275
+ });
276
+ }
277
+
278
+ // اختيار لعبة
279
+ function selectGame(gameName = null) {
280
+ if (!gameName) {
281
+ gameName = document.getElementById('gameSelect').value;
282
  }
283
+ selectedGame = gameName;
284
+ addToLog('🎯 تم اختيار اللعبة: ' + gameName);
285
  }
286
 
287
+ // بدء التحليل
288
+ async function startAnalysis() {
289
+ const game = document.getElementById('analysisGame').value;
290
+ const type = document.getElementById('analysisType').value;
291
 
292
+ if (!game) {
293
+ alert('يرجى اختيار لعبة أولاً');
294
  return;
295
  }
296
 
297
+ addToLog(`🔍 بدء تحليل ${game} - النوع: ${type}`);
298
 
299
  try {
300
+ const response = await fetch('/api/start-analysis', {
301
  method: 'POST',
302
+ headers: {'Content-Type': 'application/json'},
303
+ body: JSON.stringify({game: game, analysis_type: type})
 
 
 
 
 
 
 
304
  });
 
305
  const data = await response.json();
306
+ addToLog('✅ ' + data.message);
307
  } catch (error) {
308
+ addToLog('❌ خطأ في التحليل: ' + error.message);
 
309
  }
310
  }
311
+
312
+ // تنفيذ أمر
313
+ async function executeCommand(command) {
314
+ if (!selectedGame) {
315
+ alert('يرجى اختيار لعبة أولاً');
316
+ return;
317
+ }
318
+
319
+ addToLog(`⚡ تنفيذ أمر: ${command} على ${selectedGame}`);
320
+
321
+ try {
322
+ const response = await fetch('/api/execute-command', {
323
+ method: 'POST',
324
+ headers: {'Content-Type': 'application/json'},
325
+ body: JSON.stringify({
326
+ command: command,
327
+ game: selectedGame
328
+ })
329
+ });
330
+ const data = await response.json();
331
+ addToLog('✅ ' + data.message);
332
+ } catch (error) {
333
+ addToLog('❌ خطأ في التنفيذ: ' + error.message);
 
 
 
 
 
 
 
 
 
334
  }
 
335
  }
336
 
337
+ // إنشاء بوت
338
+ async function generateBot() {
339
+ const description = document.getElementById('botDescription').value;
340
+ const type = document.getElementById('botType').value;
341
+
342
+ if (!description) {
343
+ alert('يرجى وصف البوت المطلوب');
344
+ return;
345
+ }
346
+
347
+ addToLog(`🤖 جاري إنشاء بوت ${type}...`);
348
+
349
  try {
350
+ const response = await fetch('/api/generate-bot', {
351
+ method: 'POST',
352
+ headers: {'Content-Type': 'application/json'},
353
+ body: JSON.stringify({
354
+ description: description,
355
+ bot_type: type
356
+ })
357
+ });
358
  const data = await response.json();
359
+ addToLog('✅ ' + data.message);
360
+ if (data.code) {
361
+ addToLog('📝 كود البوت:\n' + data.code);
 
 
 
 
 
 
 
 
362
  }
363
  } catch (error) {
364
+ addToLog('❌ خطأ في إنشاء البوت: ' + error.message);
 
365
  }
366
  }
367
 
368
+ // أدوات مساعدة
369
+ function openCheatEngine() {
370
+ addToLog('🧠 جاري فتح Cheat Engine...');
371
+ executeCommand('open_cheat_engine');
372
+ }
373
+
374
+ function openProcessHacker() {
375
+ addToLog('🔍 جاري فتح Process Hacker...');
376
+ executeCommand('open_process_hacker');
377
+ }
378
+
379
+ function scanProcesses() {
380
+ addToLog('📊 جاري مسح العمليات النشطة...');
381
+ executeCommand('scan_processes');
382
+ }
383
+
384
+ // إضافة للسجل
385
+ function addToLog(message) {
386
+ const log = document.getElementById('commandLog');
387
+ const timestamp = new Date().toLocaleTimeString();
388
+ log.innerHTML = `[${timestamp}] ${message}<br>${log.innerHTML}`;
389
+ }
390
+
391
+ // التهيئة
392
  document.addEventListener('DOMContentLoaded', function() {
393
+ document.getElementById('serverUrl').value = window.location.href;
394
+ addToLog('🚀 النظام جاهز للاستخدام');
395
+ addToLog('🔗 انتظر الاتصال من عميل Windows...');
 
 
 
 
396
  });
397
  </script>
398
  </body>
 
402
  # نقاط النهاية
403
  @app.get("/")
404
  async def read_root():
 
405
  return HTMLResponse(content=HTML_INTERFACE)
406
 
407
+ @app.post("/api/scan-games")
408
+ async def scan_games():
409
+ """مسح الألعاب المثبتة"""
410
+ # هذه مجرد بيانات تجريبية - في الواقع العميل سيرسل القائمة الحقيقية
411
+ sample_games = [
412
+ {"name": "Genshin Impact", "process": "GenshinImpact.exe"},
413
+ {"name": "VALORANT", "process": "VALORANT.exe"},
414
+ {"name": "Minecraft", "process": "javaw.exe"},
415
+ {"name": "Cyberpunk 2077", "process": "Cyberpunk2077.exe"},
416
+ {"name": "Call of Duty", "process": "ModernWarfare.exe"}
417
+ ]
418
+ return {"success": True, "games": sample_games}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
 
420
+ @app.post("/api/start-analysis")
421
+ async def start_analysis(data: dict):
422
+ """بدء تحليل اللعبة"""
423
+ game = data.get("game")
424
+ analysis_type = data.get("analysis_type")
425
+
426
+ # إضافة الأمر للعميل
427
+ command_id = f"cmd_{int(time.time())}"
428
+ pending_commands[command_id] = {
429
+ "type": "analysis",
430
+ "game": game,
431
+ "analysis_type": analysis_type,
432
+ "timestamp": datetime.now().isoformat()
433
  }
434
+
435
+ return {"success": True, "message": f"تم بدء تحليل {game}"}
436
 
437
+ @app.post("/api/execute-command")
438
+ async def execute_command(data: dict):
439
+ """تنفيذ أمر على العميل"""
440
+ command = data.get("command")
441
+ game = data.get("game")
442
+
443
+ command_id = f"cmd_{int(time.time())}"
444
+ pending_commands[command_id] = {
445
+ "type": "command",
446
+ "command": command,
447
+ "game": game,
448
  "timestamp": datetime.now().isoformat()
449
  }
450
+
451
+ return {"success": True, "message": f"تم إرسال أمر {command} للتنفيذ"}
452
 
453
+ @app.post("/api/generate-bot")
454
+ async def generate_bot(data: dict):
455
+ """إنشاء بوت مخصص"""
456
+ description = data.get("description")
457
+ bot_type = data.get("bot_type")
458
 
459
+ # توليد كود بوت بسيط (في الواقع سيتم توليده بالذكاء الاصطناعي)
460
+ bot_code = f"""
461
+ // بوت {bot_type} - {description}
462
+ #include <iostream>
463
+ #include <windows.h>
464
+
465
+ class GameBot {{
466
+ public:
467
+ void start() {{
468
+ std::cout << "بدء بوت {bot_type}..." << std::endl;
469
+ // منطق البوت هنا
470
+ }}
471
 
472
+ void {bot_type}() {{
473
+ // تنفيذ {bot_type}
474
+ }}
475
+ }};
476
+
477
+ int main() {{
478
+ GameBot bot;
479
+ bot.start();
480
+ return 0;
481
+ }}
482
+ """
483
 
484
+ return {
485
+ "success": True,
486
+ "message": f"تم إنشاء بوت {bot_type}",
487
+ "code": bot_code
488
+ }
489
+
490
+ @app.get("/api/get-commands")
491
+ async def get_commands(client_id: str):
492
+ """الحصول على الأوامر المعلقة للعميل"""
493
+ commands = []
494
+ to_remove = []
495
 
496
+ for cmd_id, cmd in pending_commands.items():
497
+ commands.append({"id": cmd_id, **cmd})
498
+ to_remove.append(cmd_id)
 
 
 
 
499
 
500
+ # إزالة الأوامر التي تم إرسالها
501
+ for cmd_id in to_remove:
502
+ pending_commands.pop(cmd_id, None)
503
+
504
+ return {"success": True, "commands": commands}
505
+
506
+ @app.post("/api/submit-result")
507
+ async def submit_result(data: dict):
508
+ """استقبال النتائج من العميل"""
509
+ client_id = data.get("client_id")
510
+ result = data.get("result")
511
+
512
+ task_results[client_id] = {
513
+ "result": result,
514
+ "timestamp": datetime.now().isoformat()
515
+ }
516
 
517
+ return {"success": True, "message": "تم استلام النتيجة"}
518
 
519
  if __name__ == "__main__":
520
  import uvicorn
521
+ uvicorn.run(app, host="0.0.0.0", port=7860)