Download utils.py from Anoar2025/Netxx: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/Anoar2025/Netxx/resolve/main/utils.py
- Command line
-
hf download hf://spaces/Anoar2025/Netxx/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/Anoar2025/Netxx/resolve/main/utils.py
1.52 kB
| """ | |
| وظائف مساعدة: تنسيق النتائج للعرض في Gradio | |
| """ | |
| def format_results_as_text(results): | |
| """ | |
| تحويل نتائج الفحص إلى نص منسق للعرض في Gradio Textbox | |
| """ | |
| if not results: | |
| return "لا توجد نتائج للعرض." | |
| lines = [] | |
| lines.append("=" * 80) | |
| lines.append("تقرير NetX Scanner - نتائج الفحص") | |
| lines.append("=" * 80) | |
| # تجميع حسب الـ IP | |
| ips = {} | |
| for r in results: | |
| ip = r.get("IP") | |
| if ip not in ips: | |
| ips[ip] = [] | |
| ips[ip].append(r) | |
| for ip, ports in ips.items(): | |
| lines.append(f"\n📡 الجهاز: {ip}") | |
| lines.append("-" * 40) | |
| for p in ports: | |
| risk = p.get('Risk', 'INFO') | |
| cve = p.get('CVE', '-') | |
| score = p.get('Score', '-') | |
| service = p.get('Service', 'unknown') | |
| port = p.get('Port', '-') | |
| version = p.get('Version', '') | |
| # رمز خطورة | |
| if risk == "CRITICAL": | |
| emoji = "🔴" | |
| elif risk == "HIGH": | |
| emoji = "🟠" | |
| elif risk == "MEDIUM": | |
| emoji = "🟡" | |
| else: | |
| emoji = "🟢" | |
| lines.append(f" {emoji} منفذ {port} ({service} {version})") | |
| if cve: | |
| lines.append(f" ⚠️ الثغرة: {cve} (Score: {score})") | |
| lines.append("\n" + "=" * 80) | |
| return "\n".join(lines) |