← 목록으로
모두 공개

s

오선주

2025. 06. 16. 월요일

조회수 28

import csv
from collections import Counter

block_entries = []
signature_stats = Counter()
ip_stats = Counter()
port_stats = Counter()

with open("ips_logs_detailed.csv", encoding="utf-8-sig") as file:
csv_reader = csv.DictReader(file)

for log in csv_reader:
if log["Action"] == "BLOCK":
print(f"[BLOCK] {log['Timestamp']} - {log['Source IP']}:{log['Source Port']} → {log['Destination IP']}:{log['Destination Port']} #{log['Signature Name']}")

if len(block_entries) < 5:
block_entries.append(log)

signature_stats[log["Signature Name"]] += 1
ip_stats[log["Source IP"]] += 1
port_stats[log["Destination Port"]] += 1

print("\n[문제 2] 시그니처 이름 Top3")
for sig, count in signature_stats.most_common(3):
print(f"{sig}: {count}회")

print("\n[문제 3] BLOCK 많은 IP Top3")
for ip, count in ip_stats.most_common(3):
print(f"{ip}: {count}회")

print("\n[문제 4] 공격 받은 포트 Top3")
for port, count in port_stats.most_common(3):
print(f"Port {port}: {count}회")
import csv
from collections import Counter

block_entries = []
signature_stats = Counter()
ip_stats = Counter()
port_stats = Counter()

with open("ips_logs_detailed.csv", encoding="utf-8-sig") as file:
csv_reader = csv.DictReader(file)

for log in csv_reader:
if log["Action"] == "BLOCK":
print(f"[BLOCK] {log['Timestamp']} - {log['Source IP']}:{log['Source Port']} → {log['Destination IP']}:{log['Destination Port']} #{log['Signature Name']}")

if len(block_entries) < 5:
block_entries.append(log)

signature_stats[log["Signature Name"]] += 1
ip_stats[log["Source IP"]] += 1
port_stats[log["Destination Port"]] += 1

print("\n[문제 2] 시그니처 이름 Top3")
for sig, count in signature_stats.most_common(3):
print(f"{sig}: {count}회")

print("\n[문제 3] BLOCK 많은 IP Top3")
for ip, count in ip_stats.most_common(3):
print(f"{ip}: {count}회")

print("\n[문제 4] 공격 받은 포트 Top3")
for port, count in port_stats.most_common(3):
print(f"Port {port}: {count}회")

3

✏️ '좋아요'누르고 연필 1개 모으기 🔥

#1 자유 주제 이 주제로 일기쓰기
공유 카카오톡으로 공유하기
신고