Ver3.0 ๐ก๏ธ ๋ณด์ ๋ก๊ทธ ๊ด๋ฆฌ์ ์นจํด ๋์ ์๋ํ: ๊ฐ๋ฐ์๋ฅผ ์ํ ์๋ฒฝ ๊ฐ์ด๋ ๐

๐ก๏ธ ๋ณด์ ๋ก๊ทธ ๊ด๋ฆฌ์ ์นจํด ๋์ ์๋ํ: ๊ฐ๋ฐ์๋ฅผ ์ํ ์๋ฒฝ ๊ฐ์ด๋ ๐
์์คํ ์ ์งํค๋ ๋๋ํ ์๋ํ ์ ๋ต
์ผ, ์์งํ ๋งํด์ ๋ณด์ ๋ก๊ทธ ๊ด๋ฆฌํ๋ค๊ณ ํ๋ฃจ ์ข ์ผ ๋ชจ๋ํฐ๋ง ์ณ๋ค๋ณด๊ณ ์์ ์๋ ์์์? ๐ ํนํ ์์ฆ์ฒ๋ผ ํดํน ์๋๊ฐ ์ด๋น ์๋ฐฑ ๊ฑด์ฉ ์ผ์ด๋๋ ์ธ์์์๋ ๋๋์ฑ ๊ทธ๋. ๊ทธ๋์ ์ค๋์ ๋ณด์ ๋ก๊ทธ ๊ด๋ฆฌ์ ์นจํด ๋์์ ์๋ํํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์น๊ตฌ์ฒ๋ผ ํธํ๊ฒ ์ด์ผ๊ธฐํด๋ณผ๊ฒ!
์ด ๊ธ์ ์ฝ๊ณ ๋๋ฉด ๋๋ ์์คํ ๋ณด์์ ํ์ธต ์ ๊ทธ๋ ์ด๋ํ ์ ์์ ๊ฑฐ์ผ. ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ ๋ณด์ ๊ด๋ จ ์ฌ๋ฅ์ ๊ณต์ ํ๊ฑฐ๋ ๋ฐฐ์ธ ๋๋ ์ด๋ฐ ์ง์์ด ์ ๋ง ์ ์ฉํ๊ฑฐ๋ ! ๐ฏ
๐ ๋ณด์ ๋ก๊ทธ๊ฐ ๋ญ๊ธธ๋ ์ด๋ ๊ฒ ์ค์ํ ๊น?
๋ณด์ ๋ก๊ทธ๋ ์ฝ๊ฒ ๋งํด์ ์์คํ ์์ ์ผ์ด๋๋ ๋ชจ๋ ๋ณด์ ๊ด๋ จ ์ฌ๊ฑด์ ๊ธฐ๋ก์ด์ผ. ๋๊ฐ ์ธ์ ๋ก๊ทธ์ธํ๋์ง, ์ด๋ค ํ์ผ์ ์ ๊ทผํ๋์ง, ์ด์ํ ํธ๋ํฝ์ด ๋ฐ์ํ๋์ง ๋ฑ๋ฑ ๋ชจ๋ ๊ฒ ๊ธฐ๋ก๋์ง.
์๊ฐํด๋ด. ์ง์ ๋๋์ด ๋ค์๋๋ฐ CCTV๊ฐ ์๋ค๋ฉด? ๋๊ฐ ์ธ์ ๋ค์ด์๋์ง ์ ์๊ฐ ์์์. ๋ณด์ ๋ก๊ทธ๊ฐ ๋ฐ๋ก ๊ทธ CCTV ์ญํ ์ ํ๋ ๊ฑฐ์ผ! ๐น
๐ ๋ณด์ ๋ก๊ทธ์ ์ฃผ์ ์ ํ๋ค
1. ์์คํ ๋ก๊ทธ (System Logs) ๐ป
์ด์์ฒด์ ๋ ๋ฒจ์์ ๋ฐ์ํ๋ ๋ชจ๋ ์ด๋ฒคํธ๋ฅผ ๊ธฐ๋กํด. Windows์ ๊ฒฝ์ฐ Event Viewer, Linux๋ /var/log ๋๋ ํ ๋ฆฌ์ ์ ์ฅ๋์ง.
2. ์ ํ๋ฆฌ์ผ์ด์ ๋ก๊ทธ (Application Logs) ๐ฎ
์น ์๋ฒ, ๋ฐ์ดํฐ๋ฒ ์ด์ค, ๊ฐ์ข ์ ํ๋ฆฌ์ผ์ด์ ์์ ๋ฐ์ํ๋ ์ด๋ฒคํธ๋ค์ด์ผ. Apache์ access.log๋ error.log๊ฐ ๋ํ์ ์ด์ง.
3. ๋ณด์ ์ฅ๋น ๋ก๊ทธ (Security Device Logs) ๐
๋ฐฉํ๋ฒฝ, IDS/IPS, WAF ๊ฐ์ ๋ณด์ ์ฅ๋น๋ค์ด ์์ฑํ๋ ๋ก๊ทธ์ผ. ๊ณต๊ฒฉ ์๋๋ฅผ ์ค์๊ฐ์ผ๋ก ๊ฐ์งํ๊ณ ๊ธฐ๋กํด.
4. ๋คํธ์ํฌ ๋ก๊ทธ (Network Logs) ๐
๋คํธ์ํฌ ํธ๋ํฝ, ํจํท ์ ๋ณด, ์ฐ๊ฒฐ ์ํ ๋ฑ์ ๊ธฐ๋กํ๋ ๋ก๊ทธ์ผ. ์ด์ํ ํธ๋ํฝ ํจํด์ ์ฐพ๋ ๋ฐ ํ์์ ์ด์ง.
โ๏ธ ๋ก๊ทธ ๊ด๋ฆฌ ์๋ํ์ ํต์ฌ ์๋ฆฌ
์, ์ด์ ๋ณธ๊ฒฉ์ ์ผ๋ก ์๋ํ ์ด์ผ๊ธฐ๋ฅผ ํด๋ณผ๊น? ๋ก๊ทธ ๊ด๋ฆฌ ์๋ํ๋ ํฌ๊ฒ ์์ง(Collection) โ ์ ๊ทํ(Normalization) โ ๋ถ์(Analysis) โ ๋์(Response) 4๋จ๊ณ๋ก ๋๋ ์ ์์ด.
๐ฅ 1๋จ๊ณ: ๋ก๊ทธ ์์ง ์๋ํ
์ฒซ ๋ฒ์งธ ๋จ๊ณ๋ ์ฌ๊ธฐ์ ๊ธฐ ํฉ์ด์ง ๋ก๊ทธ๋ค์ ํ๊ณณ์ผ๋ก ๋ชจ์ผ๋ ๊ฑฐ์ผ. ์๋์ผ๋ก ํ๋ํ๋ ๋ณต์ฌ ๋ถ์ฌ๋ฃ๊ธฐ ํ ์๋ ์์์? ๐ค
๐ง ์ฃผ์ ๋ก๊ทธ ์์ง ๋๊ตฌ๋ค
Fluentd ๐
์คํ์์ค ๋ฐ์ดํฐ ์์ง๊ธฐ๋ก, ๋ค์ํ ์์ค์์ ๋ก๊ทธ๋ฅผ ์์งํด์ ์ฌ๋ฌ ๋ชฉ์ ์ง๋ก ์ ์กํ ์ ์์ด. Ruby๋ก ์์ฑ๋๊ณ ํ๋ฌ๊ทธ์ธ ์ํ๊ณ๊ฐ ์์ฒญ ํ๋ถํ์ง.
# Fluentd ์ค์ ์์
<source>
@type tail
path /var/log/apache2/access.log
pos_file /var/log/td-agent/apache2.pos
tag apache.access
format apache2
</source>
<match apache.access>
@type elasticsearch
host localhost
port 9200
index_name apache-logs
</match>
Logstash ๐ฆ
Elastic Stack์ ์ผ๋ถ๋ก, ๊ฐ๋ ฅํ ํ์ฑ ๊ธฐ๋ฅ์ ๊ฐ์ง๊ณ ์์ด. Grok ํจํด์ ์ฌ์ฉํด์ ๋น์ ํ ๋ก๊ทธ๋ฅผ ๊ตฌ์กฐํ๋ ๋ฐ์ดํฐ๋ก ๋ณํํ ์ ์์ง.
# Logstash ์ค์ ์์
input {
file {
path => "/var/log/nginx/access.log"
start_position => "beginning"
}
}
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
date {
match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "nginx-logs-%{+YYYY.MM.dd}"
}
}
Filebeat ๐ต
๊ฒฝ๋ ๋ก๊ทธ ์์ง๊ธฐ๋ก, ์์คํ ๋ฆฌ์์ค๋ฅผ ์ ๊ฒ ์ฌ์ฉํ๋ฉด์๋ ํจ์จ์ ์ผ๋ก ๋ก๊ทธ๋ฅผ ์ ์กํด. Logstash๋ณด๋ค ๊ฐ๋ณ๊ณ ๋น ๋ฅด์ง.
๐ก ์ค์ ํ: ๋ก๊ทธ ์์ง๊ธฐ๋ฅผ ์ ํํ ๋๋ ์์คํ ํ๊ฒฝ๊ณผ ๋ก๊ทธ ๋ณผ๋ฅจ์ ๊ณ ๋ คํด์ผ ํด. ์๊ท๋ชจ ์์คํ ์ด๋ผ๋ฉด Filebeat๋ก ์ถฉ๋ถํ๊ณ , ๋ณต์กํ ํ์ฑ์ด ํ์ํ๋ฉด Logstash๋ฅผ ์ฐ๋ ๊ฒ ์ข์. Fluentd๋ Kubernetes ํ๊ฒฝ์์ ํนํ ๊ฐ๋ ฅํ์ง! ๐
๐ 2๋จ๊ณ: ๋ก๊ทธ ์ ๊ทํ
๊ฐ ์์คํ ๋ง๋ค ๋ก๊ทธ ํ์์ด ๋ค ๋ค๋ฅด์์? Apache๋ Apache๋๋ก, Nginx๋ Nginx๋๋ก, Windows๋ ๋ ๋ค๋ฅด๊ฒ... ์ด๊ฑธ ํต์ผ๋ ํ์์ผ๋ก ๋ฐ๊ฟ์ฃผ๋ ๊ฒ ์ ๊ทํ์ผ.
์๋ฅผ ๋ค์ด๋ณผ๊ฒ:
์๋ณธ Apache ๋ก๊ทธ:
192.168.1.100 - - [15/Jan/2024:10:30:45 +0900] "GET /admin HTTP/1.1" 403 512
์ ๊ทํ๋ JSON ํ์:
{
"timestamp": "2024-01-15T10:30:45+09:00",
"source_ip": "192.168.1.100",
"method": "GET",
"uri": "/admin",
"status_code": 403,
"bytes": 512,
"log_type": "web_access",
"severity": "warning"
}
์ด๋ ๊ฒ ์ ๊ทํํ๋ฉด ๋์ค์ ๋ถ์ํ ๋ ํจ์ฌ ํธํด์ ธ. ๋ชจ๋ ๋ก๊ทธ๋ฅผ ๊ฐ์ ๋ฐฉ์์ผ๋ก ์ฟผ๋ฆฌํ ์ ์๊ฑฐ๋ ! ๐ฏ
๐ฌ 3๋จ๊ณ: ๋ก๊ทธ ๋ถ์ ์๋ํ
์ด์ ์ง์ง ํต์ฌ์ด์ผ! ์์งํ๊ณ ์ ๋ฆฌํ ๋ก๊ทธ์์ ์๋ฏธ ์๋ ํจํด๊ณผ ์ด์ ์งํ๋ฅผ ์๋์ผ๋ก ์ฐพ์๋ด๋ ๋จ๊ณ์ง.
๐ค ๋ถ์ ๊ธฐ๋ฒ๋ค
1. ๊ท์น ๊ธฐ๋ฐ ๋ถ์ (Rule-based Analysis) ๐
๋ฏธ๋ฆฌ ์ ์๋ ๊ท์น์ ๋ฐ๋ผ ๋ก๊ทธ๋ฅผ ๋ถ์ํ๋ ๋ฐฉ์์ด์ผ. ์๋ฅผ ๋ค์ด "5๋ถ ๋ด์ ๊ฐ์ IP์์ ๋ก๊ทธ์ธ ์คํจ๊ฐ 10๋ฒ ์ด์ ๋ฐ์ํ๋ฉด ๊ฒฝ๊ณ "๊ฐ์ ๊ฑฐ์ง.
# Elasticsearch Watcher ์์
PUT _watcher/watch/failed_login_attempts
{
"trigger": {
"schedule": { "interval": "5m" }
},
"input": {
"search": {
"request": {
"indices": ["security-logs-*"],
"body": {
"query": {
"bool": {
"must": [
{ "match": { "event_type": "login_failed" }},
{ "range": { "@timestamp": { "gte": "now-5m" }}}
]
}
},
"aggs": {
"by_ip": {
"terms": { "field": "source_ip", "min_doc_count": 10 }
}
}
}
}
}
},
"condition": {
"compare": { "ctx.payload.aggregations.by_ip.buckets.length": { "gt": 0 }}
},
"actions": {
"send_alert": {
"email": {
"to": "security@company.com",
"subject": "Brute Force Attack Detected",
"body": "Multiple failed login attempts detected from {{ctx.payload.aggregations.by_ip.buckets.0.key}}"
}
}
}
}
2. ํต๊ณ ๊ธฐ๋ฐ ๋ถ์ (Statistical Analysis) ๐
์ ์์ ์ธ ํจํด์ ํต๊ณ์ ๊ธฐ์ค์ ์ ๋ง๋ค๊ณ , ๊ทธ๊ฒ์์ ๋ฒ์ด๋๋ ์ด์์น๋ฅผ ํ์งํ๋ ๋ฐฉ์์ด์ผ.
# Python์ผ๋ก ๊ฐ๋จํ ์ด์์น ํ์ง
import pandas as pd
import numpy as np
from scipy import stats
def detect_anomalies(data, threshold=3):
"""
Z-score๋ฅผ ์ด์ฉํ ์ด์์น ํ์ง
"""
z_scores = np.abs(stats.zscore(data))
anomalies = np.where(z_scores > threshold)[0]
return anomalies
# ์๊ฐ๋น ์์ฒญ ์ ๋ถ์
hourly_requests = df.groupby(df['timestamp'].dt.hour).size()
anomaly_hours = detect_anomalies(hourly_requests)
print(f"์ด์ ํธ๋ํฝ ๊ฐ์ง ์๊ฐ๋: {anomaly_hours}")
3. ๋จธ์ ๋ฌ๋ ๊ธฐ๋ฐ ๋ถ์ (ML-based Analysis) ๐ง
์ต๊ทผ์๋ ๋จธ์ ๋ฌ๋์ ํ์ฉํด์ ๋ ์ ๊ตํ ํจํด ์ธ์์ ํ๊ณ ์์ด. ํนํ ๋น์ง๋ ํ์ต์ผ๋ก ์๋ ค์ง์ง ์์ ๊ณต๊ฒฉ๋ ํ์งํ ์ ์์ง!
# Scikit-learn์ ์ด์ฉํ ์ด์ ํ์ง
from sklearn.ensemble import IsolationForest
import pandas as pd
# ๋ก๊ทธ ๋ฐ์ดํฐ ๋ก๋ ๋ฐ ํน์ง ์ถ์ถ
df = pd.read_csv('security_logs.csv')
features = df[['request_count', 'error_rate', 'response_time', 'unique_ips']]
# Isolation Forest ๋ชจ๋ธ ํ์ต
model = IsolationForest(contamination=0.1, random_state=42)
predictions = model.fit_predict(features)
# ์ด์์น ํ์ง (-1์ด ์ด์์น)
anomalies = df[predictions == -1]
print(f"ํ์ง๋ ์ด์ ๋ก๊ทธ: {len(anomalies)}๊ฑด")
print(anomalies[['timestamp', 'source_ip', 'event_type']])
โ ๏ธ ์ฃผ์์ฌํญ: ๋จธ์ ๋ฌ๋ ๋ชจ๋ธ์ ํ์ต ๋ฐ์ดํฐ์ ํ์ง์ด ์ ๋ง ์ค์ํด. ์๋ชป๋ ๋ฐ์ดํฐ๋ก ํ์ตํ๋ฉด ์คํ(False Positive)์ด๋ ๋ฏธํ(False Negative)์ด ๋ง์ด ๋ฐ์ํ ์ ์์ด. ์ ๊ธฐ์ ์ผ๋ก ๋ชจ๋ธ์ ์ฌํ์ตํ๊ณ ํ๋ํ๋ ๊ฒ ํ์์ผ!
โก 4๋จ๊ณ: ์นจํด ๋์ ์๋ํ
์ด์ ์งํ๋ฅผ ๋ฐ๊ฒฌํ๋ค๋ฉด ์ด์ ๋์ํด์ผ์ง! ์ฌ๋์ด ์ผ์ผ์ด ๋์ํ๊ธฐ์ ์๊ฐ์ด ๋๋ฌด ์ค๋ ๊ฑธ๋ ค. ์๋ํ๋ ๋์ ์์คํ ์ด ํ์ํ ์ด์ ์ผ. ๐จ
๐ก๏ธ ์๋ ๋์ ์๋๋ฆฌ์ค๋ค
์๋๋ฆฌ์ค 1: ๋ฌด์ฐจ๋ณ ๋์ ๊ณต๊ฒฉ(Brute Force) ์ฐจ๋จ
๋ก๊ทธ์ธ ์คํจ๊ฐ ๋ฐ๋ณต๋๋ IP๋ฅผ ์๋์ผ๋ก ์ฐจ๋จํ๋ ์คํฌ๋ฆฝํธ์ผ:
#!/bin/bash
# auto_block_bruteforce.sh
LOG_FILE="/var/log/auth.log"
THRESHOLD=5
TIME_WINDOW=300 # 5๋ถ
# ์ต๊ทผ 5๋ถ๊ฐ ๋ก๊ทธ์ธ ์คํจ ํ์ ํ์ธ
failed_ips=$(grep "Failed password" $LOG_FILE | \
awk -v time_window=$TIME_WINDOW '
BEGIN { now = systime() }
{
timestamp = mktime(substr($0, 1, 15))
if (now - timestamp <= time_window) {
for(i=1; i<=NF; i++) {
if($i ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
ip[$i]++
}
}
}
}
END {
for(i in ip) {
if(ip[i] >= '$THRESHOLD') print i
}
}
')
# ์ฐจ๋จ ๊ท์น ์ถ๊ฐ
for ip in $failed_ips; do
# ์ด๋ฏธ ์ฐจ๋จ๋์ด ์๋์ง ํ์ธ
if ! iptables -L INPUT -n | grep -q $ip; then
echo "$(date): Blocking IP $ip due to brute force attempt"
iptables -A INPUT -s $ip -j DROP
# ๋ก๊ทธ ๊ธฐ๋ก
logger "Auto-blocked IP $ip for brute force attack"
# ์๋ฆผ ์ ์ก
curl -X POST https://hooks.slack.com/services/YOUR/WEBHOOK/URL \
-H 'Content-Type: application/json' \
-d "{\"text\":\"๐จ IP $ip blocked for brute force attack\"}"
fi
done
์ด ์คํฌ๋ฆฝํธ๋ฅผ cron์ผ๋ก 5๋ถ๋ง๋ค ์คํํ๋ฉด ์๋์ผ๋ก ๊ณต๊ฒฉ์๋ฅผ ์ฐจ๋จํ ์ ์์ด!
์๋๋ฆฌ์ค 2: SQL Injection ์๋ ํ์ง ๋ฐ ์ฐจ๋จ
์น ์ ํ๋ฆฌ์ผ์ด์ ๋ฐฉํ๋ฒฝ(WAF) ๊ท์น์ ๋์ ์ผ๋ก ์ ๋ฐ์ดํธํ๋ Python ์คํฌ๋ฆฝํธ:
import re
import requests
from datetime import datetime, timedelta
class SQLInjectionDetector:
def __init__(self):
self.sql_patterns = [
r"(\%27)|(\')|(\-\-)|(\%23)|(#)",
r"((\%3D)|(=))[^\n]*((\%27)|(\')|(\-\-)|(\%3B)|(;))",
r"\w*((\%27)|(\'))((\%6F)|o|(\%4F))((\%72)|r|(\%52))",
r"((\%27)|(\'))union",
r"exec(\s|\+)+(s|x)p\w+",
]
self.blocked_ips = set()
def analyze_log_entry(self, log_entry):
"""๋ก๊ทธ ์ํธ๋ฆฌ์์ SQL Injection ํจํด ๊ฒ์ฌ"""
uri = log_entry.get('uri', '')
for pattern in self.sql_patterns:
if re.search(pattern, uri, re.IGNORECASE):
return True
return False
def block_ip(self, ip_address):
"""IP ์ฃผ์๋ฅผ WAF์ ์ฐจ๋จ ๊ท์น ์ถ๊ฐ"""
if ip_address in self.blocked_ips:
return
# CloudFlare API ์์
api_url = "https://api.cloudflare.com/client/v4/zones/ZONE_ID/firewall/access_rules/rules"
headers = {
"X-Auth-Email": "your@email.com",
"X-Auth-Key": "your_api_key",
"Content-Type": "application/json"
}
data = {
"mode": "block",
"configuration": {
"target": "ip",
"value": ip_address
},
"notes": f"Auto-blocked for SQL injection attempt at {datetime.now()}"
}
response = requests.post(api_url, headers=headers, json=data)
if response.status_code == 200:
self.blocked_ips.add(ip_address)
print(f"โ
Successfully blocked {ip_address}")
self.send_alert(ip_address, "SQL Injection")
else:
print(f"โ Failed to block {ip_address}: {response.text}")
def send_alert(self, ip_address, attack_type):
"""๋ณด์ํ์ ์๋ฆผ ์ ์ก"""
webhook_url = "https://hooks.slack.com/services/YOUR/WEBHOOK"
message = {
"text": f"๐จ *Security Alert*\n"
f"Attack Type: {attack_type}\n"
f"Source IP: {ip_address}\n"
f"Action: Automatically blocked\n"
f"Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
}
requests.post(webhook_url, json=message)
# ์ค์๊ฐ ๋ก๊ทธ ๋ชจ๋ํฐ๋ง
detector = SQLInjectionDetector()
def process_logs():
# Elasticsearch์์ ์ต๊ทผ ๋ก๊ทธ ๊ฐ์ ธ์ค๊ธฐ
from elasticsearch import Elasticsearch
es = Elasticsearch(['localhost:9200'])
query = {
"query": {
"range": {
"@timestamp": {
"gte": "now-1m"
}
}
}
}
results = es.search(index="web-logs-*", body=query)
for hit in results['hits']['hits']:
log_entry = hit['_source']
if detector.analyze_log_entry(log_entry):
source_ip = log_entry.get('source_ip')
print(f"โ ๏ธ SQL Injection attempt detected from {source_ip}")
detector.block_ip(source_ip)
# 1๋ถ๋ง๋ค ์คํ
if __name__ == "__main__":
import time
while True:
process_logs()
time.sleep(60)
์๋๋ฆฌ์ค 3: ๋์ฌ์จ์ด ํ์ ํ์ง ๋ฐ ๊ฒฉ๋ฆฌ
ํ์ผ ์์คํ ๋ชจ๋ํฐ๋ง์ ํตํด ๋๋์ ํ์ผ ์ํธํ ์๋๋ฅผ ํ์งํ๊ณ ํด๋น ํ๋ก์ธ์ค๋ฅผ ์๋์ผ๋ก ์ข ๋ฃํ๋ ์์คํ :
import os
import psutil
import time
from collections import defaultdict
from datetime import datetime, timedelta
class RansomwareDetector:
def __init__(self):
self.file_operations = defaultdict(list)
self.alert_threshold = 50 # 1๋ถ์ 50๊ฐ ์ด์ ํ์ผ ์์
self.time_window = 60 # 60์ด
self.suspicious_extensions = [
'.encrypted', '.locked', '.crypto', '.crypt',
'.cerber', '.locky', '.zepto'
]
def monitor_file_operations(self, pid, operation, filepath):
"""ํ๋ก์ธ์ค์ ํ์ผ ์์
๋ชจ๋ํฐ๋ง"""
current_time = datetime.now()
# ์์ฌ์ค๋ฌ์ด ํ์ฅ์ ์ฒดํฌ
_, ext = os.path.splitext(filepath)
if ext.lower() in self.suspicious_extensions:
self.quarantine_process(pid, "Suspicious file extension")
return
# ํ์ผ ์์
๊ธฐ๋ก
self.file_operations[pid].append({
'time': current_time,
'operation': operation,
'filepath': filepath
})
# ์ค๋๋ ๊ธฐ๋ก ์ ๊ฑฐ
cutoff_time = current_time - timedelta(seconds=self.time_window)
self.file_operations[pid] = [
op for op in self.file_operations[pid]
if op['time'] > cutoff_time
]
# ์๊ณ๊ฐ ์ฒดํฌ
if len(self.file_operations[pid]) > self.alert_threshold:
self.quarantine_process(pid, "Excessive file modifications")
def quarantine_process(self, pid, reason):
"""์์ฌ์ค๋ฌ์ด ํ๋ก์ธ์ค ๊ฒฉ๋ฆฌ"""
try:
process = psutil.Process(pid)
process_info = {
'name': process.name(),
'exe': process.exe(),
'cmdline': ' '.join(process.cmdline()),
'connections': process.connections()
}
print(f"๐จ RANSOMWARE ALERT!")
print(f"PID: {pid}")
print(f"Process: {process_info['name']}")
print(f"Reason: {reason}")
print(f"File operations: {len(self.file_operations[pid])}")
# ํ๋ก์ธ์ค ์ข
๋ฃ
process.terminate()
process.wait(timeout=3)
# ๊ฐ์ ์ข
๋ฃ๊ฐ ํ์ํ ๊ฒฝ์ฐ
if process.is_running():
process.kill()
# ๋คํธ์ํฌ ์ฐ๊ฒฐ ์ฐจ๋จ
for conn in process_info['connections']:
if conn.status == 'ESTABLISHED':
remote_ip = conn.raddr.ip
os.system(f"iptables -A OUTPUT -d {remote_ip} -j DROP")
# ์์ธ ๋ก๊ทธ ๊ธฐ๋ก
self.log_incident(pid, process_info, reason)
# ๊ธด๊ธ ์๋ฆผ
self.send_emergency_alert(pid, process_info, reason)
print(f"โ
Process {pid} has been quarantined")
except psutil.NoSuchProcess:
print(f"Process {pid} already terminated")
except Exception as e:
print(f"Error quarantining process: {e}")
def log_incident(self, pid, process_info, reason):
"""์นจํด ์ฌ๊ณ ์์ธ ๋ก๊ทธ ๊ธฐ๋ก"""
log_entry = {
'timestamp': datetime.now().isoformat(),
'incident_type': 'ransomware_attempt',
'pid': pid,
'process_name': process_info['name'],
'executable': process_info['exe'],
'command_line': process_info['cmdline'],
'reason': reason,
'file_operations': self.file_operations[pid]
}
# JSON ํ์์ผ๋ก ์ ์ฅ
import json
with open('/var/log/security/ransomware_incidents.log', 'a') as f:
f.write(json.dumps(log_entry) + '\n')
def send_emergency_alert(self, pid, process_info, reason):
"""๊ธด๊ธ ์๋ฆผ ๋ฐ์ก"""
import requests
message = f"""
๐จ **CRITICAL SECURITY ALERT - RANSOMWARE DETECTED** ๐จ
**Time:** {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
**Severity:** CRITICAL
**Incident Type:** Ransomware Activity
**Process Details:**
- PID: {pid}
- Name: {process_info['name']}
- Executable: {process_info['exe']}
- Command: {process_info['cmdline']}
**Detection Reason:** {reason}
**File Operations:** {len(self.file_operations[pid])} files affected
**Action Taken:** Process terminated and quarantined
**Status:** Threat neutralized
**Next Steps:**
1. Investigate affected files
2. Check for data exfiltration
3. Scan system for additional malware
4. Review backup integrity
"""
# Slack ์๋ฆผ
requests.post(
"https://hooks.slack.com/services/YOUR/WEBHOOK",
json={"text": message}
)
# ์ด๋ฉ์ผ ์๋ฆผ
# SMS ์๋ฆผ
# PagerDuty ๋ฑ ์ถ๊ฐ ์๋ฆผ ์ฑ๋
# ์ค์๊ฐ ๋ชจ๋ํฐ๋ง ์์
detector = RansomwareDetector()
print("๐ก๏ธ Ransomware detection system activated")
๐๏ธ SIEM ์์คํ ๊ตฌ์ถํ๊ธฐ
SIEM(Security Information and Event Management)์ ๋ณด์ ๋ก๊ทธ ๊ด๋ฆฌ์ ์นจํด ๋์ ์๋ํ์ ํต์ฌ ํ๋ซํผ์ด์ผ. ์ฌ๋ฌ ์์ค์์ ๋ก๊ทธ๋ฅผ ์์งํ๊ณ , ์๊ด ๋ถ์ํ๊ณ , ์ค์๊ฐ์ผ๋ก ์ํ์ ํ์งํ๋ ํตํฉ ์์คํ ์ด์ง.
๐ฏ ์คํ์์ค SIEM ์๋ฃจ์ ๋ค
1. ELK Stack (Elasticsearch, Logstash, Kibana) ๐
๊ฐ์ฅ ์ธ๊ธฐ ์๋ ์คํ์์ค ๋ก๊ทธ ๋ถ์ ํ๋ซํผ์ด์ผ. ํ์ฅ์ฑ์ด ๋ฐ์ด๋๊ณ ์ปค๋ฎค๋ํฐ๊ฐ ํ๋ฐํ์ง.
ELK Stack ์ค์น ๋ฐ ์ค์
# Docker Compose๋ก ELK Stack ๊ตฌ์ถ
version: '3.7'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
container_name: elasticsearch
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
- xpack.security.enabled=true
- ELASTIC_PASSWORD=your_password
ports:
- "9200:9200"
volumes:
- esdata:/usr/share/elasticsearch/data
networks:
- elk
logstash:
image: docker.elastic.co/logstash/logstash:8.11.0
container_name: logstash
volumes:
- ./logstash/pipeline:/usr/share/logstash/pipeline
- ./logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml
ports:
- "5044:5044"
- "9600:9600"
environment:
- "LS_JAVA_OPTS=-Xms1g -Xmx1g"
networks:
- elk
depends_on:
- elasticsearch
kibana:
image: docker.elastic.co/kibana/kibana:8.11.0
container_name: kibana
ports:
- "5601:5601"
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- ELASTICSEARCH_USERNAME=elastic
- ELASTICSEARCH_PASSWORD=your_password
networks:
- elk
depends_on:
- elasticsearch
volumes:
esdata:
driver: local
networks:
elk:
driver: bridge
Kibana์์ ๋ณด์ ๋์๋ณด๋ ๊ตฌ์ฑ:
# Kibana Dev Tools์์ ์คํ
# ๋ณด์ ์ด๋ฒคํธ ์ธ๋ฑ์ค ํจํด ์์ฑ
PUT _index_template/security-logs
{
"index_patterns": ["security-logs-*"],
"template": {
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"@timestamp": { "type": "date" },
"event_type": { "type": "keyword" },
"severity": { "type": "keyword" },
"source_ip": { "type": "ip" },
"destination_ip": { "type": "ip" },
"user": { "type": "keyword" },
"action": { "type": "keyword" },
"result": { "type": "keyword" },
"message": { "type": "text" }
}
}
}
}
# ๋ณด์ ์๋ฆผ ๊ท์น ์์ฑ
PUT _watcher/watch/high_severity_events
{
"trigger": {
"schedule": { "interval": "1m" }
},
"input": {
"search": {
"request": {
"indices": ["security-logs-*"],
"body": {
"query": {
"bool": {
"must": [
{ "term": { "severity": "critical" }},
{ "range": { "@timestamp": { "gte": "now-1m" }}}
]
}
}
}
}
}
},
"condition": {
"compare": { "ctx.payload.hits.total.value": { "gt": 0 }}
},
"actions": {
"log_alert": {
"logging": {
"text": "Critical security event detected: {{ctx.payload.hits.total.value}} events"
}
},
"webhook_alert": {
"webhook": {
"method": "POST",
"url": "https://your-webhook-url.com/alert",
"body": "{{#toJson}}ctx.payload{{/toJson}}"
}
}
}
}
2. Wazuh ๐ก๏ธ
ํธ์คํธ ๊ธฐ๋ฐ ์นจ์ ํ์ง ์์คํ (HIDS)์ผ๋ก, ํ์ผ ๋ฌด๊ฒฐ์ฑ ๋ชจ๋ํฐ๋ง, ๋ก๊ทธ ๋ถ์, ์ทจ์ฝ์ ํ์ง ๋ฑ ๋ค์ํ ๊ธฐ๋ฅ์ ์ ๊ณตํด.
# Wazuh Agent ์ค์น (Ubuntu/Debian)
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | apt-key add -
echo "deb https://packages.wazuh.com/4.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list
apt-get update
apt-get install wazuh-agent
# Wazuh Manager ์๋ฒ ์ค์
echo "WAZUH_MANAGER='your-manager-ip'" >> /var/ossec/etc/ossec.conf
# ์์ด์ ํธ ์์
systemctl start wazuh-agent
systemctl enable wazuh-agent
์ปค์คํ ๊ท์น ์์ฑ:
<!-- /var/ossec/etc/rules/local_rules.xml -->
<group name="custom_security,">
<!-- SSH ๋ฌด์ฐจ๋ณ ๋์
๊ณต๊ฒฉ ํ์ง -->
<rule id="100001" level="10">
<if_matched_sid>5710</if_matched_sid>
<same_source_ip />
<description>Multiple SSH authentication failures from same source</description>
<group>authentication_failures,pci_dss_10.2.4,pci_dss_10.2.5,</group>
</rule>
<!-- ์น ์ค์บ๋ ํ์ง -->
<rule id="100002" level="8">
<if_sid>31100</if_sid>
<url>/admin|/phpmyadmin|/wp-admin</url>
<description>Web scanning attempt detected</description>
<group>web_scan,</group>
</rule>
<!-- ๊ถํ ์์น ์๋ -->
<rule id="100003" level="12">
<if_sid>5401</if_sid>
<match>sudo|su</match>
<user>^(?!root|admin)</user>
<description>Privilege escalation attempt by non-privileged user</description>
<group>privilege_escalation,</group>
</rule>
</group>
3. OSSEC ๐
Wazuh์ ๊ธฐ๋ฐ์ด ๋ ์คํ์์ค HIDS์ผ. ๊ฐ๋ณ๊ณ ํจ์จ์ ์ด๋ฉฐ ๋ค์ํ ํ๋ซํผ์ ์ง์ํ์ง.
# OSSEC ์๋ฒ ์ค์น
wget https://github.com/ossec/ossec-hids/archive/3.7.0.tar.gz
tar -xzf 3.7.0.tar.gz
cd ossec-hids-3.7.0
./install.sh
# ์ค์น ์ค ์ ํ ์ฌํญ
# - Installation type: server
# - Email notification: yes
# - Integrity check: yes
# - Rootkit detection: yes
# - Active response: yes
# ์ค์ ํ์ผ ํธ์ง
vi /var/ossec/etc/ossec.conf
Active Response ์ค์ (์๋ ๋์):
<ossec_config>
<active-response>
<!-- SSH ๊ณต๊ฒฉ์ ์๋ ์ฐจ๋จ -->
<command>firewall-drop</command>
<location>local</location>
<level>10</level>
<timeout>600</timeout>
</active-response>
<active-response>
<!-- ์น ๊ณต๊ฒฉ ์ฐจ๋จ -->
<command>firewall-drop</command>
<location>local</location>
<rules_id>31151,31152,31153</rules_id>
<timeout>3600</timeout>
</active-response>
</ossec_config>
๐ก ์ค์ ํ: SIEM ์์คํ ์ ์ฒ์ ๊ตฌ์ถํ ๋๋ ELK Stack์ผ๋ก ์์ํ๋ ๊ฑธ ์ถ์ฒํด. ํ์ต ๊ณก์ ์ด ์๋งํ๊ณ ์๋ฃ๋ ๋ง๊ฑฐ๋ . ๊ทธ๋ค์ Wazuh๋ฅผ ์ถ๊ฐํ๋ฉด ํธ์คํธ ๋ ๋ฒจ ๋ณด์๊น์ง ์ปค๋ฒํ ์ ์์ด. ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ SIEM ๊ตฌ์ถ ๊ฒฝํ์ด ์๋ ์ ๋ฌธ๊ฐ๋ฅผ ์ฐพ์ ๋ฉํ ๋ง์ ๋ฐ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ผ! ๐
๐ค AI/ML ๊ธฐ๋ฐ ์ํ ํ์ง
์ต๊ทผ์๋ ์ธ๊ณต์ง๋ฅ๊ณผ ๋จธ์ ๋ฌ๋์ ํ์ฉํ ์ํ ํ์ง๊ฐ ๋์ธ์ผ. ๊ธฐ์กด ๊ท์น ๊ธฐ๋ฐ ์์คํ ์ผ๋ก๋ ํ์งํ๊ธฐ ์ด๋ ค์ด ์ ๋ก๋ฐ์ด ๊ณต๊ฒฉ์ด๋ APT(Advanced Persistent Threat)๋ ์ฐพ์๋ผ ์ ์๊ฑฐ๋ !
๐ง ๋จธ์ ๋ฌ๋ ๋ชจ๋ธ ๊ตฌ์ถ
1. ์ด์ ํ์ง ๋ชจ๋ธ (Anomaly Detection)
์ ์ ํ์ ํจํด์ ํ์ตํ๊ณ , ๊ทธ๊ฒ์์ ๋ฒ์ด๋๋ ์ด์ ํ์๋ฅผ ํ์งํ๋ ๋ชจ๋ธ์ด์ผ:
import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import IsolationForest
from sklearn.model_selection import train_test_split
import joblib
class SecurityAnomalyDetector:
def __init__(self):
self.scaler = StandardScaler()
self.model = IsolationForest(
contamination=0.1, # 10%๋ฅผ ์ด์์น๋ก ๊ฐ์
random_state=42,
n_estimators=100
)
def prepare_features(self, df):
"""๋ก๊ทธ ๋ฐ์ดํฐ์์ ํน์ง ์ถ์ถ"""
features = pd.DataFrame()
# ์๊ฐ ๊ธฐ๋ฐ ํน์ง
df['hour'] = pd.to_datetime(df['timestamp']).dt.hour
df['day_of_week'] = pd.to_datetime(df['timestamp']).dt.dayofweek
# ํต๊ณ์ ํน์ง
features['requests_per_minute'] = df.groupby(
pd.Grouper(key='timestamp', freq='1min')
).size()
features['unique_ips'] = df.groupby(
pd.Grouper(key='timestamp', freq='1min')
)['source_ip'].nunique()
features['error_rate'] = df.groupby(
pd.Grouper(key='timestamp', freq='1min')
)['status_code'].apply(lambda x: (x >= 400).sum() / len(x))
features['avg_response_time'] = df.groupby(
pd.Grouper(key='timestamp', freq='1min')
)['response_time'].mean()
features['failed_auth_count'] = df.groupby(
pd.Grouper(key='timestamp', freq='1min')
)['auth_result'].apply(lambda x: (x == 'failed').sum())
# ์ํธ๋กํผ ๊ณ์ฐ (๋ฌด์์์ฑ ์ธก์ )
features['uri_entropy'] = df.groupby(
pd.Grouper(key='timestamp', freq='1min')
)['uri'].apply(self.calculate_entropy)
return features.fillna(0)
def calculate_entropy(self, series):
"""์ํธ๋กํผ ๊ณ์ฐ"""
from scipy.stats import entropy
value_counts = series.value_counts()
return entropy(value_counts)
def train(self, training_data):
"""๋ชจ๋ธ ํ์ต"""
features = self.prepare_features(training_data)
# ์ ๊ทํ
features_scaled = self.scaler.fit_transform(features)
# ๋ชจ๋ธ ํ์ต
self.model.fit(features_scaled)
print("โ
Model training completed")
# ๋ชจ๋ธ ์ ์ฅ
joblib.dump(self.model, 'anomaly_detector.pkl')
joblib.dump(self.scaler, 'scaler.pkl')
def predict(self, new_data):
"""์ด์ ํ์ง"""
features = self.prepare_features(new_data)
features_scaled = self.scaler.transform(features)
# ์์ธก (-1: ์ด์, 1: ์ ์)
predictions = self.model.predict(features_scaled)
# ์ด์ ์ ์ ๊ณ์ฐ
anomaly_scores = self.model.score_samples(features_scaled)
# ๊ฒฐ๊ณผ ์ ๋ฆฌ
results = pd.DataFrame({
'timestamp': features.index,
'is_anomaly': predictions == -1,
'anomaly_score': anomaly_scores
})
return results[results['is_anomaly']]
# ์ฌ์ฉ ์์
detector = SecurityAnomalyDetector()
# ํ์ต ๋ฐ์ดํฐ ๋ก๋ (์ ์ ํธ๋ํฝ)
training_logs = pd.read_csv('normal_traffic_logs.csv')
detector.train(training_logs)
# ์ค์๊ฐ ํ์ง
new_logs = pd.read_csv('realtime_logs.csv')
anomalies = detector.predict(new_logs)
print(f"๐จ Detected {len(anomalies)} anomalies")
print(anomalies)
2. ๋ฅ๋ฌ๋ ๊ธฐ๋ฐ ์นจ์ ํ์ง (Deep Learning IDS)
LSTM(Long Short-Term Memory) ๋คํธ์ํฌ๋ฅผ ์ฌ์ฉํ ์๊ณ์ด ํจํด ๋ถ์:
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import numpy as np
import pandas as pd
class DeepLearningIDS:
def __init__(self, sequence_length=10):
self.sequence_length = sequence_length
self.model = None
self.build_model()
def build_model(self):
"""LSTM ๊ธฐ๋ฐ ๋ชจ๋ธ ๊ตฌ์ถ"""
self.model = keras.Sequential([
layers.LSTM(128, return_sequences=True,
input_shape=(self.sequence_length, 10)),
layers.Dropout(0.3),
layers.LSTM(64, return_sequences=False),
layers.Dropout(0.3),
layers.Dense(32, activation='relu'),
layers.Dense(1, activation='sigmoid')
])
self.model.compile(
optimizer='adam',
loss='binary_crossentropy',
metrics=['accuracy', 'precision', 'recall']
)
def create_sequences(self, data, labels):
"""์๊ณ์ด ์ํ์ค ์์ฑ"""
X, y = [], []
for i in range(len(data) - self.sequence_length):
X.append(data[i:i + self.sequence_length])
y.append(labels[i + self.sequence_length])
return np.array(X), np.array(y)
def train(self, training_data, labels, epochs=50, batch_size=32):
"""๋ชจ๋ธ ํ์ต"""
X_train, y_train = self.create_sequences(training_data, labels)
# ์กฐ๊ธฐ ์ข
๋ฃ ์ฝ๋ฐฑ
early_stopping = keras.callbacks.EarlyStopping(
monitor='val_loss',
patience=5,
restore_best_weights=True
)
# ํ์ต
history = self.model.fit(
X_train, y_train,
epochs=epochs,
batch_size=batch_size,
validation_split=0.2,
callbacks=[early_stopping],
verbose=1
)
# ๋ชจ๋ธ ์ ์ฅ
self.model.save('deep_ids_model.h5')
return history
def predict(self, new_data):
"""์นจ์
ํ์ง"""
sequences = []
for i in range(len(new_data) - self.sequence_length):
sequences.append(new_data[i:i + self.sequence_length])
X = np.array(sequences)
predictions = self.model.predict(X)
# ์๊ณ๊ฐ ๊ธฐ๋ฐ ๋ถ๋ฅ (0.5 ์ด์์ด๋ฉด ๊ณต๊ฒฉ)
is_attack = predictions > 0.5
return predictions, is_attack
def evaluate(self, test_data, test_labels):
"""๋ชจ๋ธ ํ๊ฐ"""
X_test, y_test = self.create_sequences(test_data, test_labels)
results = self.model.evaluate(X_test, y_test)
print(f"Test Loss: {results[0]:.4f}")
print(f"Test Accuracy: {results[1]:.4f}")
print(f"Test Precision: {results[2]:.4f}")
print(f"Test Recall: {results[3]:.4f}")
return results
# ์ฌ์ฉ ์์
ids = DeepLearningIDS(sequence_length=10)
# ๋ฐ์ดํฐ ์ค๋น
# features: [requests_per_sec, error_rate, unique_ips, ...]
# labels: 0 (์ ์) or 1 (๊ณต๊ฒฉ)
training_features = np.random.rand(10000, 10) # ์ค์ ๋ก๋ ์ค์ ๋ฐ์ดํฐ ์ฌ์ฉ
training_labels = np.random.randint(0, 2, 10000)
# ํ์ต
history = ids.train(training_features, training_labels, epochs=30)
# ์ค์๊ฐ ํ์ง
new_features = np.random.rand(100, 10)
predictions, is_attack = ids.predict(new_features)
attack_indices = np.where(is_attack)[0]
print(f"๐จ Detected attacks at indices: {attack_indices}")
3. ํ์ ๊ธฐ๋ฐ ๋ถ์ (Behavioral Analysis)
์ฌ์ฉ์๋ ์ํฐํฐ์ ์ ์ ํ์ ํจํด์ ํ์ตํ๊ณ ์ดํ์ ํ์งํ๋ UEBA(User and Entity Behavior Analytics):
import pandas as pd
import numpy as np
from sklearn.cluster import DBSCAN
from sklearn.preprocessing import StandardScaler
class BehaviorAnalyzer:
def __init__(self):
self.user_profiles = {}
self.scaler = StandardScaler()
def build_user_profile(self, user_id, historical_data):
"""์ฌ์ฉ์ ํ์ ํ๋กํ ์์ฑ"""
user_data = historical_data[historical_data['user_id'] == user_id]
profile = {
'typical_login_hours': user_data['login_hour'].mode()[0],
'avg_session_duration': user_data['session_duration'].mean(),
'std_session_duration': user_data['session_duration'].std(),
'typical_locations': user_data['location'].value_counts().head(3).index.tolist(),
'avg_files_accessed': user_data['files_accessed'].mean(),
'typical_applications': user_data['application'].value_counts().head(5).index.tolist(),
'avg_data_transfer': user_data['data_transfer_mb'].mean(),
'std_data_transfer': user_data['data_transfer_mb'].std()
}
self.user_profiles[user_id] = profile
return profile
def calculate_anomaly_score(self, user_id, current_activity):
"""ํ์ฌ ํ๋์ ์ด์ ์ ์ ๊ณ์ฐ"""
if user_id not in self.user_profiles:
return 0.5 # ํ๋กํ ์์
profile = self.user_profiles[user_id]
anomaly_score = 0
# ๋ก๊ทธ์ธ ์๊ฐ ์ด์
hour_diff = abs(current_activity['login_hour'] - profile['typical_login_hours'])
if hour_diff > 6:
anomaly_score += 0.2
# ์ธ์
์๊ฐ ์ด์
session_z_score = abs(
(current_activity['session_duration'] - profile['avg_session_duration']) /
(profile['std_session_duration'] + 1e-6)
)
if session_z_score > 3:
anomaly_score += 0.2
# ์์น ์ด์
if current_activity['location'] not in profile['typical_locations']:
anomaly_score += 0.2
# ํ์ผ ์ ๊ทผ ์ด์
if current_activity['files_accessed'] > profile['avg_files_accessed'] * 3:
anomaly_score += 0.2
# ๋ฐ์ดํฐ ์ ์ก ์ด์
data_z_score = abs(
(current_activity['data_transfer_mb'] - profile['avg_data_transfer']) /
(profile['std_data_transfer'] + 1e-6)
)
if data_z_score > 3:
anomaly_score += 0.2
return min(anomaly_score, 1.0)
def detect_insider_threat(self, user_id, activity_sequence):
"""๋ด๋ถ์ ์ํ ํ์ง"""
threat_indicators = []
# ์ฐ์์ ์ธ ์ด์ ํ์
anomaly_scores = [
self.calculate_anomaly_score(user_id, activity)
for activity in activity_sequence
]
if np.mean(anomaly_scores) > 0.6:
threat_indicators.append("Consistently abnormal behavior")
# ๋ฏผ๊ฐํ ๋ฐ์ดํฐ ์ ๊ทผ ํจํด
sensitive_access = sum(
1 for activity in activity_sequence
if activity.get('accessed_sensitive_data', False)
)
if sensitive_access > len(activity_sequence) * 0.5:
threat_indicators.append("Excessive sensitive data access")
# ๋น์ ์ ์๊ฐ๋ ํ๋
off_hours_activity = sum(
1 for activity in activity_sequence
if activity['login_hour'] < 6 or activity['login_hour'] > 22
)
if off_hours_activity > len(activity_sequence) * 0.3:
threat_indicators.append("Unusual off-hours activity")
# ๋๋ ๋ฐ์ดํฐ ๋ค์ด๋ก๋
total_download = sum(
activity.get('data_transfer_mb', 0)
for activity in activity_sequence
)
if total_download > 10000: # 10GB ์ด์
threat_indicators.append("Massive data exfiltration attempt")
threat_level = len(threat_indicators) / 4.0 # 0-1 ์ค์ผ์ผ
return {
'user_id': user_id,
'threat_level': threat_level,
'indicators': threat_indicators,
'anomaly_scores': anomaly_scores,
'recommendation': self.get_recommendation(threat_level)
}
def get_recommendation(self, threat_level):
"""์ํ ์์ค์ ๋ฐ๋ฅธ ๊ถ์ฅ ์กฐ์น"""
if threat_level >= 0.75:
return "CRITICAL: Immediately suspend account and investigate"
elif threat_level >= 0.5:
return "HIGH: Require additional authentication and monitor closely"
elif threat_level >= 0.25:
return "MEDIUM: Flag for review and increase monitoring"
else:
return "LOW: Continue normal monitoring"
# ์ฌ์ฉ ์์
analyzer = BehaviorAnalyzer()
# ์ฌ์ฉ์ ํ๋กํ ๊ตฌ์ถ
historical_data = pd.read_csv('user_activity_history.csv')
for user_id in historical_data['user_id'].unique():
analyzer.build_user_profile(user_id, historical_data)
# ์ค์๊ฐ ๋ถ์
current_activities = [
{
'login_hour': 23,
'session_duration': 180,
'location': 'Unknown',
'files_accessed': 50,
'data_transfer_mb': 5000,
'accessed_sensitive_data': True
},
# ... more activities
]
threat_assessment = analyzer.detect_insider_threat('user123', current_activities)
print(f"๐จ Threat Assessment:")
print(f"Level: {threat_assessment['threat_level']:.2f}")
print(f"Indicators: {threat_assessment['indicators']}")
print(f"Recommendation: {threat_assessment['recommendation']}")
๐ ํตํฉ ๋ณด์ ์๋ํ ํ๋ซํผ ๊ตฌ์ถ
์ด์ ์ง๊ธ๊น์ง ๋ฐฐ์ด ๋ชจ๋ ๊ฑธ ํ๋๋ก ํตํฉํด๋ณผ ์๊ฐ์ด์ผ! SOAR(Security Orchestration, Automation and Response) ํ๋ซํผ์ ๊ตฌ์ถํด๋ณด์.
๐ญ SOAR ์ํคํ ์ฒ
SOAR๋ ์ฌ๋ฌ ๋ณด์ ๋๊ตฌ๋ค์ ์ฐ๊ฒฐํ๊ณ , ์๋ํ๋ ์ํฌํ๋ก์ฐ๋ฅผ ์คํํ๋ฉฐ, ์นจํด ๋์์ ์กฐ์จํ๋ ํ๋ซํผ์ด์ผ.
import asyncio
import aiohttp
import json
from datetime import datetime
from typing import Dict, List, Any
class SOARPlatform:
def __init__(self):
self.integrations = {}
self.playbooks = {}
self.incident_queue = asyncio.Queue()
self.active_incidents = {}
def register_integration(self, name: str, integration):
"""๋ณด์ ๋๊ตฌ ํตํฉ ๋ฑ๋ก"""
self.integrations[name] = integration
print(f"โ
Registered integration: {name}")
def create_playbook(self, name: str, steps: List[Dict]):
"""์๋ํ ํ๋ ์ด๋ถ ์์ฑ"""
self.playbooks[name] = {
'name': name,
'steps': steps,
'created_at': datetime.now()
}
print(f"โ
Created playbook: {name}")
async def execute_playbook(self, playbook_name: str, context: Dict):
"""ํ๋ ์ด๋ถ ์คํ"""
if playbook_name not in self.playbooks:
print(f"โ Playbook not found: {playbook_name}")
return
playbook = self.playbooks[playbook_name]
print(f"๐ฌ Executing playbook: {playbook_name}")
results = []
for step in playbook['steps']:
action = step['action']
params = step.get('params', {})
# ์ปจํ
์คํธ ๋ณ์ ์นํ
params = self.substitute_variables(params, context)
print(f" โถ Step: {action}")
try:
result = await self.execute_action(action, params)
results.append({
'action': action,
'status': 'success',
'result': result
})
# ๊ฒฐ๊ณผ๋ฅผ ์ปจํ
์คํธ์ ์ถ๊ฐ
context[f'{action}_result'] = result
except Exception as e:
print(f" โ Error in step {action}: {e}")
results.append({
'action': action,
'status': 'failed',
'error': str(e)
})
# ์คํจ ์ ์ค๋จํ ์ง ๊ฒฐ์
if step.get('critical', False):
break
return results
def substitute_variables(self, params: Dict, context: Dict) -> Dict:
"""๋ณ์ ์นํ"""
result = {}
for key, value in params.items():
if isinstance(value, str) and value.startswith('{{') and value.endswith('}}'):
var_name = value[2:-2].strip()
result[key] = context.get(var_name, value)
else:
result[key] = value
return result
async def execute_action(self, action: str, params: Dict) -> Any:
"""์ก์
์คํ"""
if action == 'block_ip':
return await self.block_ip(params['ip_address'])
elif action == 'isolate_host':
return await self.isolate_host(params['hostname'])
elif action == 'send_alert':
return await self.send_alert(params['message'], params['severity'])
elif action == 'create_ticket':
return await self.create_ticket(params['title'], params['description'])
elif action == 'collect_evidence':
return await self.collect_evidence(params['target'])
elif action == 'run_scan':
return await self.run_scan(params['target'], params['scan_type'])
else:
raise ValueError(f"Unknown action: {action}")
async def block_ip(self, ip_address: str) -> Dict:
"""IP ์ฐจ๋จ"""
# ๋ฐฉํ๋ฒฝ API ํธ์ถ
firewall = self.integrations.get('firewall')
if firewall:
result = await firewall.block_ip(ip_address)
print(f" โ Blocked IP: {ip_address}")
return result
return {'status': 'no_firewall_integration'}
async def isolate_host(self, hostname: str) -> Dict:
"""ํธ์คํธ ๊ฒฉ๋ฆฌ"""
# EDR API ํธ์ถ
edr = self.integrations.get('edr')
if edr:
result = await edr.isolate_host(hostname)
print(f" โ Isolated host: {hostname}")
return result
return {'status': 'no_edr_integration'}
async def send_alert(self, message: str, severity: str) -> Dict:
"""์๋ฆผ ์ ์ก"""
# Slack, Email, SMS ๋ฑ
notification = self.integrations.get('notification')
if notification:
result = await notification.send(message, severity)
print(f" โ Alert sent: {severity}")
return result
return {'status': 'no_notification_integration'}
async def create_ticket(self, title: str, description: str) -> Dict:
"""ํฐ์ผ ์์ฑ"""
# JIRA, ServiceNow ๋ฑ
ticketing = self.integrations.get('ticketing')
if ticketing:
result = await ticketing.create_ticket(title, description)
print(f" โ Ticket created: {title}")
return result
return {'status': 'no_ticketing_integration'}
async def collect_evidence(self, target: str) -> Dict:
"""์ฆ๊ฑฐ ์์ง"""
# ํฌ๋ ์ ๋๊ตฌ
forensics = self.integrations.get('forensics')
if forensics:
result = await forensics.collect(target)
print(f" โ Evidence collected from: {target}")
return result
return {'status': 'no_forensics_integration'}
async def run_scan(self, target: str, scan_type: str) -> Dict:
"""๋ณด์ ์ค์บ ์คํ"""
scanner = self.integrations.get('scanner')
if scanner:
result = await scanner.scan(target, scan_type)
print(f" โ Scan completed: {scan_type} on {target}")
return result
return {'status': 'no_scanner_integration'}
async def handle_incident(self, incident: Dict):
"""์นจํด ์ฌ๊ณ ์ฒ๋ฆฌ"""
incident_id = incident['id']
incident_type = incident['type']
print(f"\n๐จ Handling incident: {incident_id} ({incident_type})")
# ์ ์ ํ ํ๋ ์ด๋ถ ์ ํ
playbook_name = self.select_playbook(incident_type)
if playbook_name:
# ํ๋ ์ด๋ถ ์คํ
context = {
'incident_id': incident_id,
'incident_type': incident_type,
**incident.get('data', {})
}
results = await self.execute_playbook(playbook_name, context)
# ๊ฒฐ๊ณผ ์ ์ฅ
self.active_incidents[incident_id] = {
'incident': incident,
'playbook': playbook_name,
'results': results,
'status': 'completed',
'completed_at': datetime.now()
}
print(f"โ
Incident {incident_id} handled successfully")
else:
print(f"โ ๏ธ No playbook found for incident type: {incident_type}")
def select_playbook(self, incident_type: str) -> str:
"""์ฌ๊ณ ์ ํ์ ๋ฐ๋ฅธ ํ๋ ์ด๋ถ ์ ํ"""
playbook_mapping = {
'brute_force': 'respond_to_brute_force',
'malware': 'respond_to_malware',
'data_exfiltration': 'respond_to_data_exfiltration',
'sql_injection': 'respond_to_sql_injection',
'ddos': 'respond_to_ddos'
}
return playbook_mapping.get(incident_type)
async def start(self):
"""SOAR ํ๋ซํผ ์์"""
print("๐ SOAR Platform started")
while True:
incident = await self.incident_queue.get()
await self.handle_incident(incident)
# ์ฌ์ฉ ์์
async def main():
soar = SOARPlatform()
# ํตํฉ ๋ฑ๋ก (์ค์ ๋ก๋ ๊ฐ ํตํฉ ํด๋์ค ๊ตฌํ ํ์)
# soar.register_integration('firewall', FirewallIntegration())
# soar.register_integration('edr', EDRIntegration())
# soar.register_integration('notification', NotificationIntegration())
# ๋ฌด์ฐจ๋ณ ๋์
๊ณต๊ฒฉ ๋์ ํ๋ ์ด๋ถ
soar.create_playbook('respond_to_brute_force', [
{
'action': 'block_ip',
'params': {'ip_address': '{{source_ip}}'},
'critical': True
},
{
'action': 'send_alert',
'params': {
'message': 'Brute force attack blocked from {{source_ip}}',
'severity': 'high'
}
},
{
'action': 'create_ticket',
'params': {
'title': 'Brute Force Attack Detected',
'description': 'Source IP: {{source_ip}}, Target: {{target}}'
}
},
{
'action': 'collect_evidence',
'params': {'target': '{{source_ip}}'}
}
])
# ๋ฉ์จ์ด ๋์ ํ๋ ์ด๋ถ
soar.create_playbook('respond_to_malware', [
{
'action': 'isolate_host',
'params': {'hostname': '{{infected_host}}'},
'critical': True
},
{
'action': 'send_alert',
'params': {
'message': '๐จ CRITICAL: Malware detected on {{infected_host}}',
'severity': 'critical'
}
},
{
'action': 'collect_evidence',
'params': {'target': '{{infected_host}}'}
},
{
'action': 'run_scan',
'params': {
'target': '{{infected_host}}',
'scan_type': 'full_malware_scan'
}
},
{
'action': 'create_ticket',
'params': {
'title': 'Malware Incident',
'description': 'Host {{infected_host}} infected with {{malware_name}}'
}
}
])
# ์ฌ๊ณ ๋ฐ์ ์๋ฎฌ๋ ์ด์
await soar.incident_queue.put({
'id': 'INC-2024-001',
'type': 'brute_force',
'data': {
'source_ip': '192.168.1.100',
'target': 'ssh_server',
'attempts': 50
}
})
await soar.incident_queue.put({
'id': 'INC-2024-002',
'type': 'malware',
'data': {
'infected_host': 'workstation-42',
'malware_name': 'Trojan.Generic',
'detection_time': datetime.now().isoformat()
}
})
# SOAR ํ๋ซํผ ์คํ
await soar.start()
# asyncio.run(main())
๐ ๋ณด์ ๋ฉํธ๋ฆญ๊ณผ ๋ฆฌํฌํ
์๋ํ ์์คํ ์ ๊ตฌ์ถํ๋ค๋ฉด ์ด์ ํจ๊ณผ๋ฅผ ์ธก์ ํ๊ณ ์ง์์ ์ผ๋ก ๊ฐ์ ํด์ผ ํด. ๋ณด์ ๋ฉํธ๋ฆญ์ ์ถ์ ํ๊ณ ์ ๊ธฐ์ ์ผ๋ก ๋ฆฌํฌํธ๋ฅผ ์์ฑํ๋ ๊ฒ ์ค์ํ์ง!
๐ ํต์ฌ ๋ณด์ ๋ฉํธ๋ฆญ
| ๋ฉํธ๋ฆญ | ์ค๋ช | ๋ชฉํ |
|---|---|---|
| MTTD (Mean Time To Detect) |
์นจํด ๋ฐ์๋ถํฐ ํ์ง๊น์ง ํ๊ท ์๊ฐ | < 5๋ถ |
| MTTR (Mean Time To Respond) |
ํ์ง๋ถํฐ ๋์ ์๋ฃ๊น์ง ํ๊ท ์๊ฐ | < 15๋ถ |
| False Positive Rate | ์คํ๋ฅ (์ ์์ ๊ณต๊ฒฉ์ผ๋ก ์๋ชป ํ๋จ) | < 5% |
| False Negative Rate | ๋ฏธํ๋ฅ (๊ณต๊ฒฉ์ ์ ์์ผ๋ก ์๋ชป ํ๋จ) | < 1% |
| Incident Volume | ์ผ์ผ ๋ณด์ ์ฌ๊ณ ๋ฐ์ ๊ฑด์ | ์ถ์ธ ๊ฐ์ |
| Automation Rate | ์๋์ผ๋ก ์ฒ๋ฆฌ๋ ์ฌ๊ณ ๋น์จ | > 80% |
| Coverage Rate | ๋ชจ๋ํฐ๋ง ์ปค๋ฒ๋ฆฌ์ง ๋น์จ | > 95% |
๐ ์๋ ๋ฆฌํฌํธ ์์ฑ
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
class SecurityReporter:
def __init__(self, db_connection):
self.db = db_connection
def generate_daily_report(self, date=None):
"""์ผ์ผ ๋ณด์ ๋ฆฌํฌํธ ์์ฑ"""
if date is None:
date = datetime.now().date()
report = {
'date': date,
'summary': self.get_summary(date),
'incidents': self.get_incidents(date),
'top_threats': self.get_top_threats(date),
'metrics': self.calculate_metrics(date),
'trends': self.analyze_trends(date)
}
return report
def get_summary(self, date):
"""์์ฝ ์ ๋ณด"""
query = f"""
SELECT
COUNT(*) as total_events,
SUM(CASE WHEN severity = 'critical' THEN 1 ELSE 0 END) as critical_events,
SUM(CASE WHEN severity = 'high' THEN 1 ELSE 0 END) as high_events,
SUM(CASE WHEN auto_resolved = true THEN 1 ELSE 0 END) as auto_resolved,
COUNT(DISTINCT source_ip) as unique_attackers
FROM security_events
WHERE DATE(timestamp) = '{date}'
"""
result = pd.read_sql(query, self.db)
return result.to_dict('records')[0]
def get_incidents(self, date):
"""์ฌ๊ณ ๋ชฉ๋ก"""
query = f"""
SELECT
incident_id,
incident_type,
severity,
source_ip,
target,
status,
response_time_seconds
FROM incidents
WHERE DATE(created_at) = '{date}'
ORDER BY severity DESC, created_at DESC
LIMIT 10
"""
return pd.read_sql(query, self.db)
def get_top_threats(self, date):
"""์ฃผ์ ์ํ"""
query = f"""
SELECT
threat_type,
COUNT(*) as count,
COUNT(DISTINCT source_ip) as unique_sources
FROM security_events
WHERE DATE(timestamp) = '{date}'
GROUP BY threat_type
ORDER BY count DESC
LIMIT 5
"""
return pd.read_sql(query, self.db)
def calculate_metrics(self, date):
"""๋ฉํธ๋ฆญ ๊ณ์ฐ"""
# MTTD ๊ณ์ฐ
mttd_query = f"""
SELECT AVG(detection_time_seconds) as mttd
FROM incidents
WHERE DATE(created_at) = '{date}'
"""
# MTTR ๊ณ์ฐ
mttr_query = f"""
SELECT AVG(response_time_seconds) as mttr
FROM incidents
WHERE DATE(created_at) = '{date}' AND status = 'resolved'
"""
mttd = pd.read_sql(mttd_query, self.db)['mttd'][0] or 0
mttr = pd.read_sql(mttr_query, self.db)['mttr'][0] or 0
return {
'mttd_seconds': mttd,
'mttd_minutes': mttd / 60,
'mttr_seconds': mttr,
'mttr_minutes': mttr / 60
}
def analyze_trends(self, date, days=7):
"""ํธ๋ ๋ ๋ถ์"""
start_date = date - timedelta(days=days)
query = f"""
SELECT
DATE(timestamp) as date,
COUNT(*) as event_count,
SUM(CASE WHEN severity IN ('critical', 'high') THEN 1 ELSE 0 END) as high_severity_count
FROM security_events
WHERE DATE(timestamp) BETWEEN '{start_date}' AND '{date}'
GROUP BY DATE(timestamp)
ORDER BY date
"""
return pd.read_sql(query, self.db)
def create_visualizations(self, report):
"""์๊ฐํ ์์ฑ"""
fig, axes = plt.subplots(2, 2, figsize=(15, 10))
# 1. ์ํ ์ ํ๋ณ ๋ถํฌ
top_threats = report['top_threats']
axes[0, 0].bar(top_threats['threat_type'], top_threats['count'])
axes[0, 0].set_title('Top Threats')
axes[0, 0].set_xlabel('Threat Type')
axes[0, 0].set_ylabel('Count')
axes[0, 0].tick_params(axis='x', rotation=45)
# 2. ์ฌ๊ฐ๋ ๋ถํฌ
summary = report['summary']
severity_data = {
'Critical': summary['critical_events'],
'High': summary['high_events'],
'Others': summary['total_events'] - summary['critical_events'] - summary['high_events']
}
axes[0, 1].pie(severity_data.values(), labels=severity_data.keys(), autopct='%1.1f%%')
axes[0, 1].set_title('Severity Distribution')
# 3. ํธ๋ ๋
trends = report['trends']
axes[1, 0].plot(trends['date'], trends['event_count'], marker='o', label='Total Events')
axes[1, 0].plot(trends['date'], trends['high_severity_count'], marker='s', label='High Severity')
axes[1, 0].set_title('7-Day Trend')
axes[1, 0].set_xlabel('Date')
axes[1, 0].set_ylabel('Count')
axes[1, 0].legend()
axes[1, 0].tick_params(axis='x', rotation=45)
# 4. ๋ฉํธ๋ฆญ
metrics = report['metrics']
metric_names = ['MTTD\n(minutes)', 'MTTR\n(minutes)']
metric_values = [metrics['mttd_minutes'], metrics['mttr_minutes']]
axes[1, 1].bar(metric_names, metric_values, color=['#3498db', '#e74c3c'])
axes[1, 1].set_title('Response Metrics')
axes[1, 1].set_ylabel('Minutes')
plt.tight_layout()
plt.savefig('security_report.png', dpi=300, bbox_inches='tight')
plt.close()
def send_email_report(self, report, recipients):
"""์ด๋ฉ์ผ๋ก ๋ฆฌํฌํธ ์ ์ก"""
# HTML ๋ฆฌํฌํธ ์์ฑ
html_content = self.generate_html_report(report)
# ์ด๋ฉ์ผ ๊ตฌ์ฑ
msg = MIMEMultipart('related')
msg['Subject'] = f"Security Daily Report - {report['date']}"
msg['From'] = 'security@company.com'
msg['To'] = ', '.join(recipients)
# HTML ๋ณธ๋ฌธ
html_part = MIMEText(html_content, 'html')
msg.attach(html_part)
# ์ด๋ฏธ์ง ์ฒจ๋ถ
with open('security_report.png', 'rb') as f:
img = MIMEImage(f.read())
img.add_header('Content-ID', '<report_chart>')
msg.attach(img)
# ์ ์ก
with smtplib.SMTP('smtp.company.com', 587) as server:
server.starttls()
server.login('security@company.com', 'password')
server.send_message(msg)
print(f"โ
Report sent to {len(recipients)} recipients")
def generate_html_report(self, report):
"""HTML ๋ฆฌํฌํธ ์์ฑ"""
summary = report['summary']
metrics = report['metrics']
html = f"""
<html>
<head>
<style>.tx-container{max-width:100%;
margin:0 auto;
font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;
line-height:1.8;
color:#2d3436;}
.tx-header{background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);
padding:40px 25px;
border-radius:16px;
text-align:center;
margin-bottom:35px;
box-shadow:0 8px 20px rgba(102,126,234,0.25);}
.tx-section{margin:30px 0;
padding:20px;
background:#f8f9fa;
border-radius:12px;
border-left:4px solid #667eea;}
.tx-highlight{background:linear-gradient(120deg,#ffeaa7 0%,#fdcb6e 100%);
padding:2px 8px;
border-radius:4px;
font-weight:600;}
.tx-box{background:#ffffff;
padding:20px;
margin:20px 0;
border-radius:10px;
box-shadow:0 3px 10px rgba(0,0,0,0.08);
border-top:3px solid #a29bfe;}
.tx-tip{background:#e8f5e9;
padding:15px;
border-radius:8px;
margin:15px 0;
border-left:4px solid #66bb6a;}
.tx-warning{background:#fff3e0;
padding:15px;
border-radius:8px;
margin:15px 0;
border-left:4px solid #ffa726;}
.tx-table{width:100%;
border-collapse:collapse;
margin:20px 0;
background:#fff;
border-radius:8px;
overflow:hidden;
box-shadow:0 2px 8px rgba(0,0,0,0.1);}
.tx-table th{background:#667eea;
color:#fff;
padding:12px;
text-align:left;
font-weight:600;}
.tx-table td{padding:12px;
border-bottom:1px solid #e9ecef;}
.tx-table tr:hover{background:#f1f3f5;}
.tx-point{color:#667eea;
font-weight:700;}
h2{color:#2d3436;
padding:15px 20px;
background:linear-gradient(120deg,#a29bfe 0%,#6c5ce7 100%);
border-radius:10px;
margin:30px 0 20px 0;
box-shadow:0 4px 12px rgba(108,92,231,0.2);}
h3{color:#2d3436;
padding:12px 18px;
background:linear-gradient(120deg,#fab1a0 0%,#fd79a8 100%);
border-radius:8px;
margin:25px 0 15px 0;}
h4{color:#2d3436;
padding:10px 15px;
background:linear-gradient(120deg,#81ecec 0%,#74b9ff 100%);
border-radius:6px;
margin:20px 0 10px 0;}</style>
</head>
<body>
<h1>๐ก๏ธ Security Daily Report</h1>
<p><strong>Date:</strong> {report['date']}</p>
<div class="summary">
<h2>๐ Summary</h2>
<div class="metric">
<div class="metric-value">{summary['total_events']}</div>
<div class="metric-label">Total Events</div>
</div>
<div class="metric">
<div class="metric-value" style="color: #e74c3c;">{summary['critical_events']}</div>
<div class="metric-label">Critical</div>
</div>
<div class="metric">
<div class="metric-value" style="color: #f39c12;">{summary['high_events']}</div>
<div class="metric-label">High</div>
</div>
<div class="metric">
<div class="metric-value" style="color: #27ae60;">{summary['auto_resolved']}</div>
<div class="metric-label">Auto Resolved</div>
</div>
</div>
<h2>โฑ๏ธ Response Metrics</h2>
<div class="metric">
<div class="metric-value">{metrics['mttd_minutes']:.1f}</div>
<div class="metric-label">MTTD (minutes)</div>
</div>
<div class="metric">
<div class="metric-value">{metrics['mttr_minutes']:.1f}</div>
<div class="metric-label">MTTR (minutes)</div>
</div>
<h2>๐ฏ Top Threats</h2>
<table>
<tr>
<th>Threat Type</th>
<th>Count</th>
<th>Unique Sources</th>
</tr>
"""
for _, row in report['top_threats'].iterrows():
html += f"""
<tr>
<td>{row['threat_type']}</td>
<td>{row['count']}</td>
<td>{row['unique_sources']}</td>
</tr>
"""
html += """
</table>
<h2>๐ Visualizations</h2>
<img src="cid:report_chart" style="max-width: 100%;">
<p style="margin-top: 30px; color: #7f8c8d; font-size: 12px;">
This is an automated report generated by the Security Automation Platform.
</p>
</body>
</html>
"""
return html
# ์ฌ์ฉ ์์
# reporter = SecurityReporter(db_connection)
# report = reporter.generate_daily_report()
# reporter.create_visualizations(report)
# reporter.send_email_report(report, ['security-team@company.com'])
๐ ์ค์ ๊ตฌํ ๊ฐ์ด๋
์, ์ด์ ์ค์ ๋ก ์์คํ ์ ๊ตฌ์ถํ ๋ ๋จ๊ณ๋ณ๋ก ์ด๋ป๊ฒ ์งํํด์ผ ํ๋์ง ์ ๋ฆฌํด๋ณผ๊ฒ!
๐ Phase 1: ๊ธฐ์ด ์ธํ๋ผ ๊ตฌ์ถ (1-2์ฃผ)
1๋จ๊ณ: ๋ก๊ทธ ์์ง ํ๊ฒฝ ๊ตฌ์ถ
- โ Filebeat/Fluentd ์ค์น ๋ฐ ์ค์
- โ ์ค์ ๋ก๊ทธ ์ ์ฅ์ ๊ตฌ์ถ (Elasticsearch)
- โ ๋ก๊ทธ ์ ๊ทํ ํ์ดํ๋ผ์ธ ๊ตฌ์ฑ
- โ ๊ธฐ๋ณธ ์ธ๋ฑ์ฑ ๋ฐ ๋ณด์กด ์ ์ฑ ์ค์
2๋จ๊ณ: ์๊ฐํ ๋์๋ณด๋ ๊ตฌ์ถ
- โ Kibana ์ค์น ๋ฐ ์ค์
- โ ๊ธฐ๋ณธ ๋ณด์ ๋์๋ณด๋ ์์ฑ
- โ ์ฃผ์ ๋ฉํธ๋ฆญ ์๊ฐํ
- โ ์ค์๊ฐ ๋ชจ๋ํฐ๋ง ๋ทฐ ๊ตฌ์ฑ
โก Phase 2: ํ์ง ๊ท์น ๊ตฌํ (2-3์ฃผ)
3๋จ๊ณ: ๊ธฐ๋ณธ ํ์ง ๊ท์น ์์ฑ
- โ ๋ฌด์ฐจ๋ณ ๋์ ๊ณต๊ฒฉ ํ์ง
- โ SQL Injection ์๋ ํ์ง
- โ ๋น์ ์ ํธ๋ํฝ ํจํด ํ์ง
- โ ๊ถํ ์์น ์๋ ํ์ง
4๋จ๊ณ: ์๋ฆผ ์์คํ ๊ตฌ์ถ
- โ Slack/Email ํตํฉ
- โ ์ฌ๊ฐ๋๋ณ ์๋ฆผ ๋ผ์ฐํ
- โ ์๋ฆผ ํ ํ๋ฆฟ ์์ฑ
- โ ์์ค์ปฌ๋ ์ด์ ์ ์ฑ ์๋ฆฝ
๐ค Phase 3: ์๋ํ ๊ตฌํ (3-4์ฃผ)
5๋จ๊ณ: ๊ธฐ๋ณธ ์๋ ๋์ ๊ตฌํ
- โ IP ์ฐจ๋จ ์๋ํ
- โ ๊ณ์ ์ ๊ธ ์๋ํ
- โ ๋ก๊ทธ ์์ง ์๋ํ
- โ ์ฆ๊ฑฐ ๋ณด์กด ์๋ํ
6๋จ๊ณ: ํ๋ ์ด๋ถ ๊ฐ๋ฐ
- โ ์ฃผ์ ๊ณต๊ฒฉ ์๋๋ฆฌ์ค๋ณ ํ๋ ์ด๋ถ
- โ ํ๋ ์ด๋ถ ํ ์คํธ ๋ฐ ๊ฒ์ฆ
- โ ๋ฌธ์ํ ๋ฐ ๊ต์ก
- โ ์ ๊ธฐ ์ ๋ฐ์ดํธ ํ๋ก์ธ์ค ์๋ฆฝ
๐ง Phase 4: ๊ณ ๊ธ ๊ธฐ๋ฅ ๊ตฌํ (4-6์ฃผ)
7๋จ๊ณ: ๋จธ์ ๋ฌ๋ ๋ชจ๋ธ ๋์
- โ ์ด์ ํ์ง ๋ชจ๋ธ ํ์ต
- โ ํ์ ๋ถ์ ์์คํ ๊ตฌ์ถ
- โ ๋ชจ๋ธ ์ฑ๋ฅ ๋ชจ๋ํฐ๋ง
- โ ์ง์์ ์ธ ๋ชจ๋ธ ๊ฐ์
8๋จ๊ณ: SOAR ํ๋ซํผ ํตํฉ
- โ ๋ค์ํ ๋ณด์ ๋๊ตฌ ํตํฉ
- โ ์ํฌํ๋ก์ฐ ์๋ํ
- โ ์ผ์ด์ค ๊ด๋ฆฌ ์์คํ
- โ ๋ฆฌํฌํ ์๋ํ
๐ก ์ค์ ํ: ์ฒ์๋ถํฐ ์๋ฒฝํ ์์คํ ์ ๋ง๋ค๋ ค๊ณ ํ์ง ๋ง! ์์ ๊ฒ๋ถํฐ ์์ํด์ ์ ์ง์ ์ผ๋ก ํ์ฅํ๋ ๊ฒ ํจ์ฌ ํจ๊ณผ์ ์ด์ผ. ํนํ ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ ๊ฒฝํ ๋ง์ ๋ณด์ ์ ๋ฌธ๊ฐ์ ์กฐ์ธ์ ๊ตฌํ๋ฉด ์ํ์ฐฉ์ค๋ฅผ ๋ง์ด ์ค์ผ ์ ์์ด. ๐ฏ
๐ง ์ค๋ฌด ์ฒดํฌ๋ฆฌ์คํธ
โ ์ผ์ผ ์ ๊ฒ ์ฌํญ
- โก ๋ก๊ทธ ์์ง ์ํ ํ์ธ (๋ชจ๋ ์์ค์์ ์ ์ ์์ง ์ค์ธ๊ฐ?)
- โก ๋์๋ณด๋ ์ด์ ์งํ ํ์ธ
- โก ์๋ ๋์ ์์คํ ๋์ ํ์ธ
- โก ์๋ฆผ ์์คํ ์ ์ ์๋ ํ์ธ
- โก ๋์คํฌ ์ฉ๋ ๋ฐ ์์คํ ๋ฆฌ์์ค ํ์ธ
- โก ๋ฏธํด๊ฒฐ ์ฌ๊ณ ๊ฒํ
โ ์ฃผ๊ฐ ์ ๊ฒ ์ฌํญ
- โก ํ์ง ๊ท์น ํจ๊ณผ์ฑ ๋ถ์ (์คํ/๋ฏธํ ๋น์จ)
- โก ํ๋ ์ด๋ถ ์คํ ๊ฒฐ๊ณผ ๊ฒํ
- โก ๋ณด์ ๋ฉํธ๋ฆญ ํธ๋ ๋ ๋ถ์
- โก ์๋ก์ด ์ํ ์ธํ ๋ฆฌ์ ์ค ์ ๋ฐ์ดํธ
- โก ์์คํ ๋ฐฑ์ ํ์ธ
- โก ํ ํ์ ๋ฐ ๊ฐ์ ์ฌํญ ๋ ผ์
โ ์๊ฐ ์ ๊ฒ ์ฌํญ
- โก ์ ์ฒด ์์คํ ์ฑ๋ฅ ํ๊ฐ
- โก ๋จธ์ ๋ฌ๋ ๋ชจ๋ธ ์ฌํ์ต ๋ฐ ํ๋
- โก ๋ณด์ ์ ์ฑ ๋ฐ ๊ท์น ์ ๋ฐ์ดํธ
- โก ์นจํด ๋์ ํ๋ จ ์ค์
- โก ์๊ฐ ๋ณด์ ๋ฆฌํฌํธ ์์ฑ ๋ฐ ๊ณต์
- โก ์์คํ ์ ๋ฐ์ดํธ ๋ฐ ํจ์น
- โก ์ฌํด ๋ณต๊ตฌ ๊ณํ ํ ์คํธ
๐ฏ ๋ง๋ฌด๋ฆฌํ๋ฉฐ
์, ์ฌ๊ธฐ๊น์ง ์ ๋ง ๊ธด ์ฌ์ ์ด์์ง? ๐ ๋ณด์ ๋ก๊ทธ ๊ด๋ฆฌ์ ์นจํด ๋์ ์๋ํ๋ ํ ๋ฒ์ ์์ฑ๋๋ ๊ฒ ์๋๋ผ ์ง์์ ์ผ๋ก ๊ฐ์ ํ๊ณ ๋ฐ์ ์์ผ์ผ ํ๋ ํ๋ก์ธ์ค์ผ.
ํต์ฌ์ ์ ๋ฆฌํ์๋ฉด:
1. ๋ก๊ทธ๋ ๋ณด์์ ์์์ ๐
๋ชจ๋ ๋ณด์ ํ๋์ ๊ธฐ๋ฐ์ด ๋๋ ๋ก๊ทธ๋ฅผ ์ฒด๊ณ์ ์ผ๋ก ์์งํ๊ณ ๊ด๋ฆฌํด์ผ ํด.
2. ์๋ํ๋ ์ ํ์ด ์๋ ํ์ ๐ค
์ฌ๋์ด 24์๊ฐ ๋ชจ๋ํฐ๋งํ ์ ์์ผ๋ ์๋ํ ์์คํ
์ด ๋ฐ๋์ ํ์ํด.
3. ์ง์์ ์ธ ๊ฐ์ ์ด ์ค์ ๐
๊ณต๊ฒฉ ๊ธฐ๋ฒ์ ๊ณ์ ์งํํ๋๊น ์ฐ๋ฆฌ ๋ฐฉ์ด ์์คํ
๋ ํจ๊ป ๋ฐ์ ํด์ผ ํด.
4. ํ์
๊ณผ ์ง์ ๊ณต์ ๐ค
ํผ์์ ๋ชจ๋ ๊ฑธ ๋ค ์ ์๋ ์์ด. ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ ์ ๋ฌธ๊ฐ๋ค๊ณผ ์ํตํ๊ณ ๋ฐฐ์ฐ๋ ๊ฒ ์ ๋ง ์ค์ํด!
โ ๏ธ ๋ง์ง๋ง ๋น๋ถ: ๋ณด์ ์๋ํ ์์คํ ์ ๊ตฌ์ถํ ๋๋ ๋ฐ๋์ ํ ์คํธ ํ๊ฒฝ์์ ์ถฉ๋ถํ ๊ฒ์ฆํ ํ์ ํ๋ก๋์ ์ ์ ์ฉํด์ผ ํด. ์๋ชป๋ ์๋ ๋์ ๊ท์น์ด ์ ์ ์๋น์ค๊น์ง ์ฐจ๋จํ ์ ์๊ฑฐ๋ . ์์ ํ๊ฒ, ๊ทธ๋ฆฌ๊ณ ๋จ๊ณ์ ์ผ๋ก ์งํํ์! ๐ก๏ธ
๋ณด์์ ๋์ด ์๋ ์ธ์์ด์ง๋ง, ์ ๋๋ก ๋ ์๋ํ ์์คํ ์ ๊ฐ์ถ๋ฉด ํจ์ฌ ํจ์จ์ ์ผ๋ก ๋์ํ ์ ์์ด. ์ด ๊ธ์ด ๋์ ๋ณด์ ์์คํ ๊ตฌ์ถ์ ๋์์ด ๋์์ผ๋ฉด ์ข๊ฒ ์ด! ๐ช
๊ถ๊ธํ ์ ์ด ์๊ฑฐ๋ ๋ ๊น์ด ์๋ ๋ด์ฉ์ด ํ์ํ๋ค๋ฉด ์ฌ๋ฅ๋ท์์ ๋ณด์ ์ ๋ฌธ๊ฐ๋ค์ ์ฐพ์๋ณด๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ผ. ์ค์ ๊ฒฝํ์ด ํ๋ถํ ์ ๋ฌธ๊ฐ๋ค์ ์กฐ์ธ์ ์ ๋ง ๊ฐ์ง๊ฑฐ๋ ! ๐
๊ทธ๋ผ ์์ ํ ์ฝ๋ฉ ํ๊ณ , ์์คํ ์ ์ง์ผ! ํ์ดํ ! ๐๐
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.