157 أسطر
7.3 KiB
YAML
157 أسطر
7.3 KiB
YAML
# Alert Rules لاكتشاف هجمات Brute Force
|
|
# للتطبيقات المنشورة على غيمة (ghaymah.systems)
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# Prometheus Alert Rules
|
|
# ═══════════════════════════════════════════════════════════════
|
|
groups:
|
|
- name: ghaymah_brute_force_detection
|
|
interval: 30s
|
|
rules:
|
|
# ─────────────────────────────────────────────────────────
|
|
# 1. اكتشاف محاولات تسجيل دخول فاشلة متكررة
|
|
# ─────────────────────────────────────────────────────────
|
|
- alert: BruteForceDetected
|
|
expr: |
|
|
sum(rate(http_requests_total{
|
|
path="/api/login",
|
|
status=~"401|403"
|
|
}[5m])) by (source_ip) > 10
|
|
for: 2m
|
|
labels:
|
|
severity: critical
|
|
team: security
|
|
platform: ghaymah
|
|
annotations:
|
|
summary: "🚨 هجوم Brute Force محتمل"
|
|
description: |
|
|
IP {{ $labels.source_ip }} أرسل أكثر من 10 محاولات فاشلة
|
|
في آخر 5 دقائق على /api/login
|
|
value: "{{ $value }} محاولة/دقيقة"
|
|
runbook_url: "https://wiki.internal/runbooks/brute-force"
|
|
action: |
|
|
1. حظر IP فوراً
|
|
2. مراجعة الـ logs
|
|
3. التحقق من الحسابات المستهدفة
|
|
|
|
# ─────────────────────────────────────────────────────────
|
|
# 2. اكتشاف نجاح تسجيل دخول بعد محاولات فاشلة
|
|
# ─────────────────────────────────────────────────────────
|
|
- alert: SuspiciousLoginAfterFailures
|
|
expr: |
|
|
(
|
|
sum(increase(http_requests_total{
|
|
path="/api/login",
|
|
status="200"
|
|
}[1m])) by (source_ip) > 0
|
|
)
|
|
and
|
|
(
|
|
sum(increase(http_requests_total{
|
|
path="/api/login",
|
|
status="401"
|
|
}[10m])) by (source_ip) > 5
|
|
)
|
|
for: 0m
|
|
labels:
|
|
severity: critical
|
|
team: security
|
|
annotations:
|
|
summary: "⚠️ تسجيل دخول مشبوه بعد محاولات فاشلة"
|
|
description: |
|
|
IP {{ $labels.source_ip }} نجح في تسجيل الدخول
|
|
بعد عدة محاولات فاشلة - قد يكون هجوم ناجح!
|
|
action: |
|
|
1. مراجعة الحساب المستخدم فوراً
|
|
2. التحقق من النشاط بعد الدخول
|
|
3. النظر في إلغاء الـ session
|
|
|
|
# ─────────────────────────────────────────────────────────
|
|
# 3. اكتشاف طلبات كثيرة من IP واحد
|
|
# ─────────────────────────────────────────────────────────
|
|
- alert: HighRequestRateFromSingleIP
|
|
expr: |
|
|
sum(rate(http_requests_total[1m])) by (source_ip) > 100
|
|
for: 1m
|
|
labels:
|
|
severity: warning
|
|
team: security
|
|
annotations:
|
|
summary: "📊 معدل طلبات عالي من IP واحد"
|
|
description: |
|
|
IP {{ $labels.source_ip }} يرسل {{ $value }} طلب/دقيقة
|
|
قد يكون هجوم DDoS أو scraping
|
|
action: "مراقبة وحظر إذا استمر"
|
|
|
|
# ─────────────────────────────────────────────────────────
|
|
# 4. اكتشاف محاولات الوصول لـ endpoints حساسة
|
|
# ─────────────────────────────────────────────────────────
|
|
- alert: SensitiveEndpointAccess
|
|
expr: |
|
|
sum(rate(http_requests_total{
|
|
path=~"/api/admin.*|/api/users/export|/api/config"
|
|
}[5m])) by (source_ip, path) > 5
|
|
for: 1m
|
|
labels:
|
|
severity: warning
|
|
team: security
|
|
annotations:
|
|
summary: "🔐 محاولات وصول لـ endpoints حساسة"
|
|
description: |
|
|
IP {{ $labels.source_ip }} يحاول الوصول لـ {{ $labels.path }}
|
|
action: "التحقق من صلاحيات المستخدم"
|
|
|
|
# ─────────────────────────────────────────────────────────
|
|
# 5. اكتشاف User-Agent مشبوه
|
|
# ─────────────────────────────────────────────────────────
|
|
- alert: SuspiciousUserAgent
|
|
expr: |
|
|
sum(rate(http_requests_total{
|
|
user_agent=~".*curl.*|.*python.*|.*wget.*|.*nikto.*|.*sqlmap.*"
|
|
}[5m])) by (source_ip, user_agent) > 10
|
|
for: 2m
|
|
labels:
|
|
severity: warning
|
|
team: security
|
|
annotations:
|
|
summary: "🤖 User-Agent مشبوه"
|
|
description: |
|
|
IP {{ $labels.source_ip }} يستخدم {{ $labels.user_agent }}
|
|
قد يكون أداة هجوم آلية
|
|
|
|
---
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# Alertmanager Configuration
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# alertmanager.yml
|
|
global:
|
|
resolve_timeout: 5m
|
|
|
|
route:
|
|
group_by: ['alertname', 'severity']
|
|
group_wait: 10s
|
|
group_interval: 10s
|
|
repeat_interval: 1h
|
|
receiver: 'security-team'
|
|
routes:
|
|
- match:
|
|
severity: critical
|
|
receiver: 'security-critical'
|
|
continue: true
|
|
|
|
receivers:
|
|
- name: 'security-team'
|
|
email_configs:
|
|
- to: 'security@company.com'
|
|
subject: '[Ghaymah Alert] {{ .GroupLabels.alertname }}'
|
|
|
|
- name: 'security-critical'
|
|
email_configs:
|
|
- to: 'security-oncall@company.com'
|
|
webhook_configs:
|
|
- url: 'https://hooks.slack.com/services/xxx/yyy/zzz'
|
|
send_resolved: true
|
|
# إرسال SMS للحالات الحرجة
|
|
# pagerduty_configs:
|
|
# - service_key: 'your-pagerduty-key'
|