網路安全基礎

Vibe Prompt

「解釋 TCP 三向交握、DNS 查詢過程、HTTPS TLS 協商,並指出每個階段的潛在攻擊點。」

OSI 模型與攻擊

| 層級 | 協定 | 攻擊方式 | |------|------|---------| | L7 應用層 | HTTP, DNS | SQL Injection, XSS | | L6 表達層 | SSL/TLS | 降級攻擊 | | L5 會話層 | SOCKS | 階段劫持 | | L4 傳輸層 | TCP, UDP | SYN Flood, DDoS | | L3 網路層 | IP | IP Spoofing | | L2 資料鏈結層 | ARP | ARP Spoofing | | L1 實體層 | 電纜 | 竊聽 |

常見攻擊

  • SYN Flood:發送大量 SYN 封包不完成握手
  • DNS Spoofing:偽造 DNS 回應
  • DDoS:分散式阻斷服務
  • Man-in-the-Middle:中間人攻擊

Vibe Prompt

「幫我寫一個 Python 腳本監控網卡流量,當某 IP 的連線數超過 100 時發出警報。」

import psutil
import time
from collections import defaultdict

connections = defaultdict(int)
threshold = 100

while True:
    for conn in psutil.net_connections():
        if conn.status == 'ESTABLISHED' and conn.raddr:
            connections[conn.raddr.ip] += 1
    
    for ip, count in connections.items():
        if count > threshold:
            print(f"⚠️ 可疑 IP {ip}: {count} 條連線")
    
    connections.clear()
    time.sleep(5)

會員專屬免費教學

本章節為註冊會員專屬的免費開放內容!請先登入或註冊會員,即可立即解鎖閱讀。

立即登入 / 註冊