Zero Trust Architecture — أمن الشبكات
Zero Trust - انعدام الثقة
الفكرة الأساسية
"لا تثق أبداً، تحقق دائماً"
النموذج التقليدي ❌
- الشبكة الداخلية = موثوقة
- الخارج = غير موثوق
- Firewall على الحدود فقط
مشاكل النموذج التقليدي
- الاختراق من الداخل
- المهاجم يتحرك بحرية بعد الدخول
- الأجهزة الشخصية
- العمل عن بُعد
نموذج Zero Trust ✅
- لا شيء موثوق افتراضياً
- التحقق من كل طلب
- أقل صلاحيات ممكنة
- المراقبة المستمرة
المبادئ الأساسية
1. التحقق الصريح
- تحقق من المستخدم
- تحقق من الجهاز
- تحقق من الموقع
- تحقق من السلوك
2. أقل الصلاحيات
- Just-In-Time access
- Just-Enough access
- صلاحيات مؤقتة
3. افترض الاختراق
- Segmentation دقيق
- تشفير end-to-end
- تحليل مستمر
التطبيق العملي
Identity
- MFA إجباري
- SSO موحد
- إدارة الهوية
Devices
- MDM (Mobile Device Management)
- فحص صحة الجهاز
- شهادات الأجهزة
Network
- Micro-segmentation
- تشفير داخلي
- Software-Defined Perimeter
Applications
- API security
- CASB للـ Cloud
- WAF للويب
Data
- تصنيف البيانات
- DLP
- تشفير
# محاكاة مفاهيم Zero Trust
import hashlib
import time
from datetime import datetime
from enum import Enum
class TrustLevel(Enum):
NONE = 0
LOW = 1
MEDIUM = 2
HIGH = 3
class ZeroTrustDemo:
"""
محاكاة نظام Zero Trust
"""
def __init__(self):
self.access_logs = []
self.risk_thresholds = {
"max_failed_attempts": 3,
"session_timeout_minutes": 30,
"unusual_location_risk": 50,
"new_device_risk": 30,
}
def evaluate_identity(self, user_id, mfa_verified, password_strength):
"""
تقييم الهوية
"""
score = 0
factors = []
# التحقق الأساسي
if user_id:
score += 20
factors.append("✅ User ID valid")
# MFA
if mfa_verified:
score += 40
factors.append("✅ MFA verified")
else:
factors.append("❌ MFA not verified")
# قوة كلمة المرور
if password_strength == "strong":
score += 20
factors.append("✅ Strong password")
elif password_strength == "medium":
score += 10
factors.append("⚠️ Medium password")
else:
factors.append("❌ Weak password")
return {"score": score, "factors": factors}
def evaluate_device(self, device_info):
"""
تقييم الجهاز
"""
score = 0
factors = []
# جهاز معروف
if device_info.get("known"):
score += 25
factors.append("✅ Known device")
else:
factors.append("⚠️ New device")
# التحديثات
if device_info.get("updated"):
score += 25
factors.append("✅ Device updated")
else:
factors.append("❌ Outdated device")
# مكافح فيروسات
if device_info.get("antivirus"):
score += 15
factors.append("✅ Antivirus active")
else:
factors.append("⚠️ No antivirus")
# تشفير القرص
if device_info.get("encrypted"):
score += 15
factors.append("✅ Disk encrypted")
else:
factors.append("⚠️ Not encrypted")
return {"score": score, "factors": factors}
def evaluate_context(self, context):
"""
تقييم السياق
"""
score = 50 # نبدأ من المنتصف
factors = []
risk_increase = 0
# الموقع
if context.get("location") == "office":
score += 20
factors.append("✅ Office location")
elif context.get("location") == "home":
score += 10
factors.append("✅ Home location")
else:
risk_increase += self.risk_thresholds["unusual_location_risk"]
factors.append("⚠️ Unusual location")
# الوقت
hour = context.get("hour", 12)
if 8 <= hour <= 18:
factors.append("✅ Business hours")
else:
risk_increase += 20
factors.append("⚠️ Outside business hours")
# نوع الطلب
if context.get("request_type") == "read":
factors.append("✅ Read operation")
elif context.get("request_type") == "write":
risk_increase += 10
factors.append("⚠️ Write operation")
elif context.get("request_type") == "admin":
risk_increase += 30
factors.append("🔴 Admin operation")
score = max(0, score - risk_increase)
return {"score": score, "factors": factors, "risk": risk_increase}
def make_access_decision(self, identity_score, device_score, context_score,
resource_sensitivity="medium"):
"""
اتخاذ قرار الوصول
"""
total_score = identity_score + device_score + context_score
# عتبات حسب حساسية المورد
thresholds = {
"low": 100,
"medium": 150,
"high": 200,
"critical": 250
}
threshold = thresholds.get(resource_sensitivity, 150)
print(f"\n📊 تقييم Zero Trust")
print("=" * 50)
print(f" Identity Score: {identity_score}/80")
print(f" Device Score: {device_score}/80")
print(f" Context Score: {context_score}/80")
print(f" ─────────────────────────")
print(f" Total Score: {total_score}/240")
print(f" Required: {threshold}")
print(f" Resource: {resource_sensitivity}")
if total_score >= threshold:
decision = "✅ ACCESS GRANTED"
trust_level = TrustLevel.HIGH if total_score > threshold + 50 else TrustLevel.MEDIUM
else:
decision = "❌ ACCESS DENIED"
trust_level = TrustLevel.NONE
# اقتراح خطوات إضافية
print(f"\n 🔒 للحصول على الوصول:")
if identity_score < 60:
print(" - تحقق MFA مطلوب")
if device_score < 50:
print(" - تحديث الجهاز أو استخدام جهاز معتمد")
if context_score < 30:
print(" - استخدم VPN أو اتصل من موقع معروف")
print(f"\n القرار: {decision}")
print(f" Trust Level: {trust_level.name}")
return {
"decision": "granted" if total_score >= threshold else "denied",
"trust_level": trust_level,
"score": total_score,
"threshold": threshold
}
def simulate_access_request(self, user_id, resource):
"""
محاكاة طلب وصول كامل
"""
print(f"\n{'='*60}")
print(f" طلب وصول جديد: {user_id} → {resource}")
print(f"{'='*60}")
# تقييم الهوية
print("\n🔑 تقييم الهوية:")
identity = self.evaluate_identity(
user_id=user_id,
mfa_verified=True,
password_strength="strong"
)
for f in identity['factors']:
print(f" {f}")
# تقييم الجهاز
print("\n💻 تقييم الجهاز:")
device = self.evaluate_device({
"known": True,
"updated": True,
"antivirus": True,
"encrypted": False
})
for f in device['factors']:
print(f" {f}")
# تقييم السياق
print("\n📍 تقييم السياق:")
context = self.evaluate_context({
"location": "home",
"hour": datetime.now().hour,
"request_type": "read"
})
for f in context['factors']:
print(f" {f}")
# القرار النهائي
decision = self.make_access_decision(
identity['score'],
device['score'],
context['score'],
resource_sensitivity="medium"
)
return decision
# تشغيل المحاكاة
zt = ZeroTrustDemo()
# محاكاة طلبات مختلفة
zt.simulate_access_request("ahmed@company.com", "Customer Database")اختبر فهمك