Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

使用 httpry 嗅探 HTTP 流量:安裝、即時監控與離線分析全攻略

編輯:Linux 教學

httpry 簡介

httpry 專為 HTTP 協定設計的封包嗅探工具,直接在協定層解析並以人類可讀格式輸出,比 tcpdump 更直觀,不需完整存取 Web 伺服器日誌即可即時分析流量。

安裝方式

Debian/Ubuntu/Mint(原始碼編譯)

sudo apt-get install gcc make git libpcap0.8-dev
git clone https://github.com/jbittel/httpry.git
cd httpry
make
sudo make install

RHEL/CentOS/Fedora(YUM 或原始碼)

# 啟用 EPEL 後
sudo yum install httpry

# 或原始碼編譯
sudo yum install gcc make git libpcap-devel
git clone https://github.com/jbittel/httpry.git
cd httpry
make
sudo make install

基本用法

即時監控

sudo httpry -i eth0

輸出範例:

2024-01-15 10:30:45  192.168.1.100  192.168.1.200  >  GET /api/users HTTP/1.1
2024-01-15 10:30:45  192.168.1.200  192.168.1.100  <  HTTP/1.1 200 OK

儲存離線分析

# 二進制原始封包(可回放)
sudo httpry -i eth0 -b traffic.dump

# 回放
httpry -r traffic.dump

# 文字格式(人類可讀)
sudo httpry -i eth0 -o traffic.txt

進階過濾與分析

指定 HTTP 方法

sudo httpry -i eth0 -m get,post,head

內建 Perl 分析腳本

原始碼目錄 scripts/plugins/ 提供:

  • hostnames — 統計唯一主機名
  • find_proxies — 偵測代理伺服器
  • search_terms — 搜尋關鍵字統計
  • content_analysis — URL 關鍵字過濾
  • xml_output — 轉換為 XML
  • log_summary — 產生日誌摘要
  • db_dump — 匯入 MySQL

執行分析

# 先擷取文字日誌
sudo httpry -i eth0 -o traffic.txt -m get,post

# 執行所有腳本
cd httpry/scripts
perl parse_log.pl -d ./plugins traffic.txt

# 查看摘要
cat log_summary.txt

實戰場景

  • API 除錯:即時觀察請求/回應標頭與本體
  • 安全稽核:偵測可疑 User-Agent、SQL 注入嘗試、異常頻率
  • 效能分析:統計回應時間、錯誤率、熱門端點
  • PAC/代理除錯:驗證代理自動配置檔傳遞正確性
Copyright © Windows教程網 All Rights Reserved