Workshop: Xây dựng Splunk Data Model cho Intrusion Detection
🎯 Mục tiêu buổi workshop
Sau 90 phút, các bạn sẽ:
- Hiểu và xây dựng được Data Model cho Intrusion Detection
- Có thể tự tạo searches, reports và dashboards từ data model
- Áp dụng được cho các data model khác
📋 Agenda (90 phút)
Phần 1: Khởi động (15 phút)
- Giới thiệu về Data Model trong Splunk
- Tại sao cần Data Model cho Security Operations
- Demo: Kết quả cuối cùng của chúng ta
Phần 2: Hands-on Lab (60 phút)
- Bước 1: Chuẩn bị dữ liệu mẫu
- Bước 2: Tạo Data Model từ đầu
- Bước 3: Định nghĩa các Object và Attributes
- Bước 4: Test và validate data model
- Bước 5: Tạo searches và dashboards
Phần 3: Q&A và Best Practices (15 phút)
🛠️ Chuẩn bị trước workshop
1. Lab Environment
# Tạo index cho lab
index=security_lab
2. Sample Data (tạo trước cho học viên)
# Tạo dữ liệu mẫu IDS
| makeresults count=1000
| eval _time=relative_time(now(), "-".(random()%30)."d@h")
| eval src_ip=case(
random()%10<7, "192.168.1.".(random()%255),
1=1, "10.0.0.".(random()%255)
)
| eval dest_ip=case(
random()%10<8, "172.16.0.".(random()%255),
1=1, "8.8.8.8"
)
| eval signature=case(
random()%100<30, "ET POLICY Outgoing Basic Auth Base64 HTTP Password detected unencrypted",
random()%100<30, "ET EXPLOIT Possible CVE-2021-44228 Log4j Exploit Attempt",
random()%100<20, "ET SCAN NMAP -sS window 1024",
random()%100<20, "ET POLICY PE EXE or DLL Windows file download HTTP",
1=1, "ET TROJAN Possible Cobalt Strike Malleable C2 JQuery"
)
| eval severity=case(
match(signature, "EXPLOIT"), "high",
match(signature, "TROJAN"), "critical",
match(signature, "SCAN"), "medium",
1=1, "low"
)
| eval src_port=random()%65535
| eval dest_port=case(
match(signature, "HTTP"), random()%2+80,
match(signature, "C2"), 443,
1=1, random()%1000+1
)
| eval action=case(
severity="critical", "blocked",
severity="high", "allowed",
1=1, "monitored"
)
| table _time src_ip dest_ip src_port dest_port signature severity action
| collect index=security_lab sourcetype=ids_logs
📊 Slide Deck
Slide 1: Data Model là gì?
┌─────────────────────────────────────────┐
│ RAW LOGS → DATA MODEL │
│ • Khó search → • Structured │
│ • Performance kém → • Fast search │
│ • Khó visualize → • Easy reports │
└─────────────────────────────────────────┘
Slide 2: Kiến trúc Data Model
┌─────────────────────────────────────────┐
│ Intrusion_Detection │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Events │ │ Objects │ │
│ │ │ │ │ │
│ │ • src_ip │ │ • Alerts │ │
│ │ • dest_ip │ │ • Sessions │ │
│ │ • signature │ │ • Attacks │ │
│ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────┘
🔧 Hands-on Lab Guide
Bước 1: Truy cập Data Model Editor
- Vào Settings → Data Models
- Click New Data Model
- Đặt tên:
Intrusion_Detection_Lab
- Chọn App: Search & Reporting
Bước 2: Tạo Root Object
{
"objectName": "IDS_Events",
"constraints": "index=security_lab sourcetype=ids_logs",
"attributes": [
{
"fieldName": "_time",
"type": "date"
},
{
"fieldName": "src_ip",
"type": "string"
},
{
"fieldName": "dest_ip",
"type": "string"
},
{
"fieldName": "signature",
"type": "string"
},
{
"fieldName": "severity",
"type": "string"
}
]
}
Bước 3: Tạo Child Objects
3.1 High Severity Alerts
- Parent: IDS_Events
- Constraint:
severity="high" OR severity="critical"
- Attributes bổ sung:
alert_type: calculated field
case(
match(signature, "EXPLOIT"), "exploit_attempt",
match(signature, "TROJAN"), "malware_detected",
1=1, "suspicious_activity"
)
3.2 Network Sessions
- Parent: IDS_Events
- Constraint:
src_ip!="" AND dest_ip!="" AND src_port>0
- Attributes:
session_id: eval src_ip."_".dest_ip."_".src_port
direction: eval if(match(src_ip, "192.168.1.*"), "outbound", "inbound")
Bước 4: Test Data Model
4.1 Pivot Test
| datamodel Intrusion_Detection_Lab IDS_Events search
| stats count by severity
| sort -count
4.2 Validate Data
| datamodel Intrusion_Detection_Lab High_Severity_Alerts search
| table _time src_ip dest_ip signature alert_type
| head 10
🎯 Practical Exercises
Exercise 1: Tạo Dashboard từ Data Model
1.1 Top 10 Source IPs
| datamodel Intrusion_Detection_Lab IDS_Events search
| stats count as alerts by src_ip
| sort -alerts
| head 10
1.2 Severity Trend
| datamodel Intrusion_Detection_Lab IDS_Events search
| timechart span=1h count by severity
1.3 Geographic Mapping (nếu có IP location)
| datamodel Intrusion_Detection_Lab IDS_Events search
| iplocation src_ip
| stats count by lat lon
| geostats count
Exercise 2: Advanced Searches
2.1 Detect Port Scanning
| datamodel Intrusion_Detection_Lab Network_Sessions search
| stats dc(dest_port) as unique_ports by src_ip
| where unique_ports > 50
| sort -unique_ports
2.2 Correlate with Threat Intel
| datamodel Intrusion_Detection_Lab High_Severity_Alerts search
| lookup threat_intel_ip src_ip OUTPUT ioc_type confidence
| where !isnull(ioc_type)
| table _time src_ip signature ioc_type confidence
📋 Checklist hoàn thành
🚀 Next Steps
1. Acceleration
# Enable acceleration cho data model
Settings → Data Models → Intrusion_Detection_Lab → Edit → Acceleration
- Enable: Yes
- Summary Range: 7 days
- Backfill Time: -7d
2. Scheduled Reports
# Daily summary report
| datamodel Intrusion_Detection_Lab IDS_Events search
| stats count as total_alerts, dc(src_ip) as unique_sources by date_mday
| where total_alerts > 100
3. Alert Rules
# Critical alert for exploit attempts
| datamodel Intrusion_Detection_Lab High_Severity_Alerts search alert_type="exploit_attempt"
| stats count by src_ip
| where count > 5
🎓 Resources & References
Documentation
Sample Searches Library
# Template cho học viên copy-paste
# 1. Top signatures
| datamodel Intrusion_Detection_Lab IDS_Events search
| top signature limit=20
# 2. Source IP reputation check
| datamodel Intrusion_Detection_Lab IDS_Events search
| lookup dnslookup clientip as src_ip OUTPUT clienthost as hostname
| eval is_internal=if(match(src_ip, "192.168.*"), "internal", "external")
Troubleshooting Guide
- No data in model: Check constraints và field extractions
- Slow performance: Enable acceleration, optimize constraints
- Missing fields: Verify field aliases và calculated fields
🏁 Kết thúc Workshop
Quick Quiz (5 câu)
- Constraint trong data model dùng để làm gì?
- Khi nào nên dùng child object?
- Làm sao để test data model mà không cần save?
- Tại sao cần acceleration?
- Cách optimize performance cho large datasets?
Feedback Form
- Rate: 1-5 cho mỗi phần
- What worked well?
- What needs improvement?
- Topics for next workshop?