Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

CC 攻擊應急處置實戰:從流量導流、IP 溯源到防火牆封鎖的完整流程

編輯:系統常見問題解答

面對 CC 攻擊(HTTP Flood),VPS/伺服器常因負載過高導致 SSH 無法登入。本文提供經實戰驗證的 3 階段應急流程:環境準備 → 攻擊源溯源 → 封鎖與恢復。

階段一:環境準備(爭取操作時間)

  1. 登入 VPS 控制台,準備隨時重啟
  2. 先關閉 Web Server(Nginx/Apache/Lighttpd),釋放資源確保 SSH 可用
  3. 關閉 Web Server 開機自啟,防止重啟後瞬間被打滿
  4. 若已無法登入:聯繫 IDC 在母機封鎖 VPS IP/80 埠,用虛擬控制台進入系統執行上述操作,再解封

階段二:攻擊源溯源(PHP + 偽靜態導流)

  1. 網站根目錄建立 ip.php:
    <?php
    $real_ip = getenv('HTTP_X_FORWARDED_FOR');
    if (isset($real_ip)) {
        shell_exec(\"echo $real_ip > real_ip.txt\");
        shell_exec(\"echo \$_SERVER['REMOTE_ADDR'] > proxy.txt\");
    } else {
        shell_exec(\"echo \$_SERVER['REMOTE_ADDR'] > ips.txt\");
    }
    echo '服務器受到攻擊,正在收集攻擊源,請 5 分鐘後訪問...';
    ?>
    
  2. 配置偽靜態將所有請求導向 ip.php:
    # Nginx
    rewrite (.*) /ip.php;
    
    # Lighttpd
    url.rewrite = ( \"^/(.+)?$\" => \"/ip.php\" )
    
  3. 啟動 Web Server 收集 3~5 分鐘,再次關閉
  4. 分析結果:
    • real_ip.txt:80%+ 相同 IP = 攻擊平台真實 IP
    • proxy.txt:代理伺服器 IP,需封鎖
    • ips.txt:無代理特徵 IP,依訪問頻率判斷

階段三:封鎖與恢復

  • 防火牆封鎖識別出的攻擊 IP/代理 IP 段
  • 啟用 limit_req_zone (Nginx) 或 mod_evasive (Apache) 限制請求頻率
  • 調整 Web Server 併發參數(worker_processes, worker_connections)
  • 重新啟用 Web Server 開機自啟,恢復服務

此流程已在多次實戰中驗證有效,關鍵在於先關站保命、再導流溯源、最後精準封鎖。

Copyright © Windows教程網 All Rights Reserved