Mausezahn?是一個?網絡流量生成與測試工具,主要用于模擬各種網絡協議行為、測試網絡設備性能、驗證安全策略或進行故障排查。它支持從底層鏈路層(如 Ethernet、VLAN)到高層應用層(如 HTTP、DNS)的協議模擬,常用于網絡工程師、安全研究人員和開發人員測試網絡環境的健壯性。
核心功能
1.?多協議支持
- 鏈路層:Ethernet II、802.3 SNAP、VLAN(802.1Q)、STP、CDP 等。
- 網絡層:IPv4/IPv6、ICMP、ARP、RIP、OSPF、BGP 等。
- 傳輸層:TCP、UDP、SCTP。
- 應用層:HTTP、DNS、DHCP、SIP、FTP、Telnet 等。
- 自定義協議:支持構造任意協議字段(如修改 TCP 標志位、IP TTL 等)。
2.?流量生成模式
- 持續發送:以固定速率或隨機間隔發送數據包。
- 突發模式:模擬短時間高流量(如 DDoS 攻擊測試)。
- 響應式發送:根據接收到的數據包動態生成響應(如 ARP 回復、ICMP Echo)。
3.?高級特性
- 隨機化字段:可隨機化 MAC/IP/端口等字段,模擬真實流量。
- 負載填充:支持自定義數據內容(如文本、二進制或隨機數據)。
- 時間控制:精確控制數據包發送時間(微秒級精度)。
- 多線程/多接口:支持多網卡同時發送流量。
4.?典型應用場景
- 網絡設備測試:驗證交換機、路由器、防火墻的吞吐量、延遲和丟包率。
- 安全測試:模擬惡意流量(如端口掃描、SYN Flood、DNS 放大攻擊)。
- 協議驗證:測試自定義協議實現或第三方設備的協議兼容性。
- 故障排查:重現網絡問題(如 CRC 錯誤、MTU 不匹配)。
基本用法
1.?發送 ICMP Echo 請求(Ping)
mausezahn eth0 icmp -A 192.168.1.1 -B 192.168.1.254 -c 10 |
-A
:源 IP。-B
:目標 IP。-c
:發送 10 個包。
2.?發送 UDP 洪水(模擬 DDoS)
mausezahn eth0 udp -A 192.168.1.1 -B 192.168.1.254 -p 53 -D "RANDOM_DATA" -f 1000 -i 0.001 |
-p
:目標端口(DNS 默認 53)。-D
:負載內容(隨機數據)。-f
:每秒 1000 包。-i
:包間隔(毫秒)。
3.?構造自定義 TCP 包(修改標志位)
mausezahn eth0 tcp -A 192.168.1.1 -B 192.168.1.254 -S 12345 -D 80 --tcp-flags SYN,ACK |
-S
:源端口。-D
:目標端口。--tcp-flags
:設置 TCP 標志位(如?SYN,ACK
)。
4.?模擬 HTTP GET 請求
mausezahn eth0 tcp -A 192.168.1.1 -B 8.8.8.8 -S 54321 -D 80 -T "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n" |
-T
:指定 HTTP 請求內容。
與同類工具對比
工具 | 定位 | 優勢 |
---|---|---|
Mausezahn | 全協議層流量生成 | 支持底層到高層的協議模擬,靈活性強,適合復雜場景測試。 |
Scapy | 交互式數據包構造 | Python 接口,適合腳本化測試,但性能較低。 |
hping3 | 網絡探測與攻擊模擬 | 專注 TCP/IP 層攻擊(如端口掃描、防火墻繞過),但協議支持較少。 |
iperf3 | 帶寬測試 | 專注于 TCP/UDP 吞吐量測試,不支持協議細節構造。 |
注意事項
- 權限要求:需?
root
?權限(直接操作網卡)。 - 網絡影響:高流量測試可能影響生產環境,建議在隔離網絡中使用。
- 協議兼容性:部分協議(如 BGP、OSPF)需深入理解協議細節才能有效測試。
- 替代方案:若需更簡單的流量生成,可考慮?
tcpreplay
(重放 PCAP 文件)或?nmap
(端口掃描)。
?一、安裝前準備
-
安裝Git和基礎工具
用于從GitHub克隆源碼:sudo yum install -y git gcc-c++ make
-
配置國內Yum源(可選)
解決依賴包下載慢的問題,推薦阿里云或清華源:sudo yum install -y wget sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo sudo yum clean all && sudo yum makecache
3. 下載安裝包 #git clone https://github.com/uweber/mausezahn.git
?二、安裝依賴包
Mausezahn編譯依賴以下開發庫:
sudo yum install -y cmake libpcap-devel libnet-devel libcli-devel
注意:若提示
libcli-devel
找不到,需更換Yum源(如阿里云/清華源)12。
三、源碼編譯與安裝
-
克隆源碼倉庫
git clone https://github.com/uweber/mausezahn.git cd mausezahn
-
編譯安裝
執行編譯三部曲:cmake . # 生成Makefile ( 注意:cmake 空格 點) make # 編譯源碼(忽略告警) sudo make install # 安裝到系統
若
cmake
失敗,檢查依賴包是否全部安裝成功12。
安裝依賴#? sudo yum install -y cmake libpcap-devel libnet-devel libcli-devel
cmake . ? ? ?# 生成Makefile
?make ? ? ? ? # 編譯源碼(忽略告警)
?2060 ?cmake .
?2061 ?make?
?2064 ?make install
?2065 ?mz --help
# mz --help
mz: invalid option -- '-'mz/getopts: Option -c requires an argument.Invalid command line parameters!Mausezahn 0.40 - (C) 2007-2010 by Herbert Haas - http://www.perihel.at/sec/mz/
|
| USAGE: mz [options] [interface] keyword | arg_string | hex_string
|
| Short option description (see doc or manpage for more information):
| -h Prints this information.
| -4 IPv4 mode (default)
| -6 IPv6 mode
| -c <count> Send the packet count times (default: 1, infinite: 0).
| -d <delay> Apply delay between transmissions. The delay value can be
| specified in usec (default, no additional unit needed), or in
| msec (e. g. 100m or 100msec), or in seconds (e. g. 100s or 100sec).
| -r Multiplies the specified delay with a random value.
| -p <length> Pad the raw frame to specified length (using random bytes).
| -a <Src_MAC|keyword> Use specified source mac address, no matter what has
| been specified with other arguments. Keywords see below.
| Default is own interface MAC.
| -b <Dst_MAC|keyword> Same with destination mac address.
| Keywords are:
| rand use a random MAC address
| bc use a broadcast MAC address
| own use own interface MAC address (default for source MAC)
| stp use IEEE 802.1d STP multicast address
| cisco use Cisco multicast address as used for CDP, VTP, or PVST+
| -A <Src_IP> Use specified source IP address (default is own interface IP).
| -B <Dst_IP|DNS_name> Send packet to specified destination IP or domain name.
| -P <ASCII Payload> Use the specified ASCII payload.
| -f <filename> Read the ASCII payload from a file.
| -F <filename> Read the hexadecimal payload from a file.
| -Q <[CoS:]vlan> Specify 802.1Q VLAN tag and optional Class of Service. You can
| specify multiple 802.1Q VLAN tags (QinQ...) by separating them
| via a comma or a period (e. g. '5:10,20,2:30').
| -t <packet_type> Specify packet type for autobuild (you don't need to care for
| encapsulations in lower layers. Most packet types allow/require
| additional packet-specific arguments in an arg_string.
| Currently supported types: arp, bpdu, cdp, ip, icmp, udp, tcp,
| dns, rtp, syslog, lldp.
| For context-help use 'help' as arg_string!
| -T <packet_type> Specify packet type for server mode. Currently only rtp is supported.
| Enter -T help or -T rtp help for further information.
| -M <MPLS label> Insert a MPLS label. Enter '-M help' for a syntax description.
| -v|V Verbose and more verbose mode
| -q Quiet mode, i. e. even omit 'important standard short messages'.
| -S Simulation mode: DOES NOT put anything on the wire. This is
| typically combined with one of the verbose modes (v or V).