Wireshark là packet analyzer mạnh nhất hiện có. Bài này hướng dẫn các filter quan trọng và cách phát hiện ARP Spoofing — kỹ thuật Man-in-the-Middle phổ biến nhất trên LAN.
Wireshark Display Filters quan trọng
# Lọc theo IP
ip.addr == 192.168.1.1
ip.src == 10.0.0.5
ip.dst == 8.8.8.8
# Lọc theo protocol
http
dns
tcp
udp
arp
tls
# HTTP requests cụ thể
http.request.method == "POST"
http.request.uri contains "/login"
http.response.code == 200
# TCP handshake fails (port scan detection)
tcp.flags.syn == 1 && tcp.flags.ack == 0
# Credentials trong HTTP rõ
http contains "password"
http.authorization
# Kết hợp điều kiện
ip.addr == 192.168.1.0/24 && http.request.method == "POST"
Phát hiện ARP Spoofing
ARP Spoofing xảy ra khi attacker gửi ARP reply giả mạo để trở thành Man-in-the-Middle:
# Filter ARP traffic
arp
# Dấu hiệu ARP Spoofing:
# 1. Một IP có nhiều MAC address khác nhau
# 2. ARP reply không có ARP request trước đó
# 3. Gratuitous ARP gửi liên tục
# Wireshark tự detect và highlight vàng:
# "Duplicate IP address detected for X.X.X.X"
# Expert Info → Warnings → Duplicate IP
Bắt ARP Spoofing bằng Python + Scapy
from scapy.all import sniff, ARP
from collections import defaultdict
ip_mac_map = defaultdict(set)
alert_threshold = 3
def detect_arp_spoofing(packet):
if packet.haslayer(ARP) and packet[ARP].op == 2: # ARP reply
ip = packet[ARP].psrc
mac = packet[ARP].hwsrc
ip_mac_map[ip].add(mac)
if len(ip_mac_map[ip]) >= alert_threshold:
print(f"[!] ARP SPOOFING DETECTED!")
print(f" IP: {ip}")
print(f" MACs: {', '.join(ip_mac_map[ip])}")
print("[*] Monitoring ARP traffic... Ctrl+C to stop")
sniff(filter="arp", prn=detect_arp_spoofing, store=False)
Phòng chống ARP Spoofing
# 1. Static ARP entries (không hiệu quả với nhiều host)
arp -s 192.168.1.1 aa:bb:cc:dd:ee:ff
# 2. Dynamic ARP Inspection (DAI) trên managed switch
# Cisco IOS:
ip arp inspection vlan 1
ip arp inspection trust # trên trusted port (uplink)
# 3. Dùng HTTPS và VPN để mã hóa traffic
# Dù bị MITM, attacker vẫn không đọc được nội dung
# 4. XArp — GUI tool giám sát ARP trên Windows/Linux