Network sniffing mitm

From brucesongs/kali-claw · View interactive version

Network sniffing mitm is an AI agent skill from the GitHub repository brucesongs/kali-claw. Network Sniffing and MITM attacks focus on intercepting, analyzing, and manipulating network traffic between two communicating parties.

How to use this skill

Skill file

Skill: Network Sniffing and Man-in-the-Middle (MITM)

Supplementary Files:

- payloads.md — Attack payload collection: passive capture, ARP spoofing, DNS spoofing, credential harvesting, SSL stripping, caplet scripting, and traffic manipulation commands

- test-cases.md — Structured test cases: TC-NSM-001 through TC-NSM-006 covering passive capture, ARP spoof MITM, responder credential harvest, bettercap caplets, DNS spoofing, and HTTPS downgrade

Summary

Network Sniffing Mitm skill domain covering network attack operations.

Tools: wireshark/tshark, tcpdump, ettercap, bettercap, mitm6, responder, dsniff, driftnet (+2 more)

Domain: network-attack

MITRE ATT&CK: TA0006-Credential Access

Description

Network Sniffing and MITM attacks focus on intercepting, analyzing, and manipulating network traffic between two communicating parties. This skill covers the full spectrum from passive packet capture (undetectable on shared media) through active man-in-the-middle positioning (ARP/NDP/DNS spoofing) to credential harvesting and traffic manipulation. The attacker positions themselves on the network path between victim and destination, enabling plaintext inspection of otherwise trusted communications.

Core Insight: MITM attacks exploit trust at Layer 2 and Layer 3 of the OSI model. ARP has no authentication, LLMNR/NBT-NS are fallback protocols that respond to any query, and IPv6 is often enabled by default with no security controls. These design assumptions create a wide attack surface on internal networks. A successful MITM position gives the attacker the same visibility as the network infrastructure itself.

Key Attack Surfaces:


Use Cases

  1. Internal Network Assessment — Position between victim hosts and gateway to capture cleartext credentials (FTP, HTTP, SMTP, IMAP) and analyze protocol usage across the environment.
  2. Active Directory Credential Harvesting — Poison LLMNR/NBT-NS/mDNS to collect NTLMv2 hashes from Windows clients, then crack offline or relay to other systems via SMB relay.
  3. Application Security Testing — Intercept and modify HTTP/HTTPS traffic between a client and web application to test input validation, session handling, and API security.
  4. IPv6 Attack Surface Validation — Use mitm6 to test whether IPv6 is enabled and exploitable in a predominantly IPv4 network, then chain with LDAP/SMB relay for domain escalation.
  5. Network Forensics and Incident Response — Capture and analyze full PCAP to reconstruct communication timelines, extract transferred files, and identify data exfiltration.
  6. Traffic Manipulation and Injection — Use bettercap caplets or mitmproxy scripts to inject JavaScript, modify responses, or replace downloaded files in transit.

Core Tools

| Tool | Purpose | Command Example |

|------|---------|-----------------|

| wireshark/tshark | Protocol analysis, PCAP triage, credential extraction, protocol hierarchy statistics | tshark -r capture.pcap -Y "http.request" |

| tcpdump | Lightweight packet capture with BPF filters, suitable for long-duration sniffing | tcpdump -i eth0 -w capture.pcap |

| ettercap | Classic ARP spoofing MITM tool with plugin system for SSL stripping and filtering | ettercap -T -q -i eth0 -M arp:remote /target// /gateway// |

| bettercap | Modular MITM framework with caplet scripting, ARP/DNS/DHCP spoofing, and credential sniffer | bettercap -iface eth0 |

| mitm6 | IPv6 MITM via SLAAC rogue router advertisement, chains to NTLM relay | mitm6 -d domain.local -i eth0 |

| responder | LLMNR/NBT-NS/mDNS poisoner, captures NTLMv1/v2 hashes, HTTP/FTP/SMB auth | responder -I eth0 -w -d -f |

| dsniff | Suite of network sniffing tools: arpspoof, dnsspoof, urlsnarf, filesnarf, mailsnarf | arpspoof -i eth0 -t victim gateway |

| driftnet | Extracts images from HTTP traffic in real-time for visual reconnaissance | driftnet -i eth0 -d /tmp/images |

| mitmproxy | Interactive HTTPS proxy with Python scripting API for traffic analysis and modification | mitmproxy -p 8080 --mode transparent |


Methodology

Attack Chain

  Survey              Capture              Poison              Harvest
 (arp-scan)    →   (tcpdump/tshark)  →  (ettercap/bettercap)  →  (responder/dsniff)
                                                                    │
         Manipulate          Exfiltrate                            │
  (bettercap caplets) ←  (driftnet/filesnarf)  ←─────────────────┘

Phase Details:

  1. Survey — Map the network topology using ARP scanning (arp-scan -l) and passive traffic observation. Identify the gateway IP, target hosts, VLAN structure, and any existing security controls (DAI, port security, 802.1X). Document MAC addresses and IP-to-host mappings for targeting.
  1. Capture — Begin passive packet capture with tcpdump or tshark. Apply BPF/display filters to focus on target protocols. Identify cleartext services (HTTP, FTP, SMTP, IMAP, Telnet) and record credential patterns. This phase is completely undetectable on switched networks when using port mirroring or when operating on a hub/shared medium.
  1. Poison — Establish MITM position through ARP spoofing (ettercap/bettercap), IPv6 SLAAC (mitm6), or DHCP spoofing. Select the poisoning technique based on the target environment: ARP spoof for Layer 2 adjacency, mitm6 for Windows domains with IPv6 enabled, or DNS spoof for targeted domain redirection.
  1. Harvest — With MITM position established, run protocol-specific credential harvesters: Responder for LLMNR/NBT-NTLM hashes, dsniff for FTP/HTTP/Telnet credentials, bettercap sniffer module for API keys and cookies. Collect and categorize all harvested credentials.
  1. Manipulate — Use bettercap caplets or mitmproxy scripts to modify traffic in transit: inject JavaScript into HTTP responses, replace file downloads, strip HTTPS to HTTP, or modify DNS responses. This phase demonstrates the impact of a MITM position beyond passive observation.
  1. Exfiltrate — Extract images (driftnet), files (filesnarf), emails (mailsnarf), and URLs (urlsnarf) from intercepted traffic. Correlate captured data with host identities for reporting.

Defense Perspective


Practical Steps

End-to-end sniffing / MITM engagement sequence. Each step references the relevant section above.

  1. Position — Get into the path of the target traffic: ARP poison (LAN), rogue AP (Wi-Fi), or upstream tap (enterprise). See Methodology § Positioning.
  2. Capture — Start tcpdump / Wireshark rolling before triggering the target traffic; rotate PCAP files at 100 MB to avoid loss.
  3. Decode — Add tcp.port==XXXX,http,tls,dns,smb,ftp display filters; follow TCP streams to reconstruct sessions.
  4. Credential Mine — Run tshark -Y "ftp||http.request.method==POST||kerberos||ntlmssp" -T fields -e ... over the PCAP; pipe to hashcat mode 5600 (NTLMv2) / 13100 (Kerberos).
  5. Downgrade & Strip — For HTTPS targets: arpspoof + sslstrip + Bettercap hstshijack/hsts-bypass; verify downgrade success before pivoting.
  6. Modify — Active MITM: inject Beef hooks, swap downloads, spoof DNS responses via bettercap -X --proxy.
  7. Persist — Drop a passive backdoor (e.g., pcapd cron) for long-duration captures; rotate logs hourly.
  8. Cover — Flush iptables NAT rules; restore ARP cache by sending gratuitous ARP from the spoofed gateway before exit.
  9. Report — Convert PCAP to HTML via tshark -G html; redact unrelated traffic; map each finding to MITRE ATT&CK T1040/T1557.

For full automation scripts see ## Automation and Scripting. For ethical / legal boundaries see ## Legal and Ethical Considerations.


Key Decisions

| Decision | Options | Recommendation |

|----------|---------|----------------|

| Capture tool | tcpdump vs tshark | Use tcpdump for long captures and remote/headless systems; use tshark for protocol-aware analysis and credential extraction |

| MITM framework | ettercap vs bettercap | Prefer bettercap for active engagements (modern, modular, caplet scripting). Use ettercap for quick ARP spoof tests or when bettercap is unavailable |

| Poisoning technique | ARP spoof vs mitm6 vs DNS spoof | Use mitm6 for Windows domain environments (IPv6 preferred over IPv4). Use ARP spoof for non-Windows targets. Use DNS spoof for targeting specific domains |

| SSL stripping | sslstrip vs bettercap vs mitmproxy | Use bettercap's net.sniff with http.proxy for integrated MITM+strip. Use mitmproxy for application-level testing with scriptable modifications |

| Credential cracking | hashcat vs john | Prefer hashcat for GPU-accelerated NTLMv2 (mode 5600) and large wordlists. Use john for quick tests and when GPU is unavailable |


Quality Criteria


Common Pitfalls


Automation and Scripting

Automate the full MITM workflow with bettercap caplets that chain discovery, poisoning, sniffing, and reporting into a single script. For credential harvesting, pipe Responder output into hashcat for real-time cracking attempts. Use tcpdump with ring buffers (-G and -W flags) for continuous long-duration capture that rotates PCAP files. Write tshark one-liners with -T fields -e to extract specific credential fields from live traffic or saved PCAP files for automated reporting.


Reporting and Documentation

MITM findings should document the specific technique used (ARP/IPv6/DNS spoofing), the network segment affected, and the duration of the MITM position. For credential harvesting, report the hash type, the account context (local vs domain), and the cracking result. Never include unredacted passwords in reports — report only that "Account X was compromised" and provide the hash separately in a secure channel. For traffic manipulation findings, include before/after screenshots showing the injected content or modified responses.


Legal and Ethical Considerations

MITM attacks and traffic interception are among the most sensitive penetration testing activities. Obtain explicit written authorization that specifically permits traffic interception, credential harvesting, and active manipulation. Many jurisdictions consider unauthorized packet sniffing to be illegal wiretapping, even on corporate networks. Never capture traffic from networks or hosts outside the defined scope. Immediately delete captured PCAP files and credentials after the engagement unless the client explicitly requests retention for forensic purposes.


Integration with Other Skills

Network sniffing and MITM results feed directly into multiple adjacent skills. Captured NTLM hashes chain into the password-attack skill for offline cracking with hashcat. Discovered cleartext protocols inform the vulnerability-assessment skill for prioritizing encryption upgrades. MITM traffic analysis reveals web application session tokens that feed into web-access-control for session hijacking tests. IPv6 findings from mitm6 connect to post-exploitation when chained with ntlmrelayx for domain escalation. DNS spoofing results inform the dns-attacks skill for deeper DNS security assessment.


Case Studies and Examples


Detection Methods

Understanding detection helps testers operate more effectively and helps defenders build monitoring. ARP spoofing is detected by tools that track MAC-to-IP mapping changes (arpwatch, switch DAI). LLMNR/NBT-NS poisoning generates Windows Event ID 4697. Rogue IPv6 router advertisements are detected by RA Guard on managed switches. SSL stripping leaves artifacts in browser security indicators (missing padlock, http:// URLs for known HTTPS sites). Unusually high ARP traffic volume is a reliable indicator of ARP spoofing across a subnet.


Defense Evasion Techniques

Evade MITM detection during authorized testing by: targeting specific hosts rather than the entire subnet (reduces ARP noise), using bettercap's set arp.spoof.internal false to avoid poisoning inter-host traffic, employing selective DNS spoofing that only responds to specific domain queries, and using mitm6 instead of ARP spoofing in environments with IPv4-focused monitoring. For credential harvesting, run Responder with --lm to capture only LM hashes (less noisy) or in analysis mode (-A) first to identify opportunities before active poisoning.


Tool Comparison Matrix

| Tool | Best For | Stealth | Detection Risk | Skill Level |

|------|----------|---------|-----------------|-------------|

| tcpdump | Passive capture, BPF filtering | High (passive) | Low | Intermediate |

| tshark | Protocol-aware PCAP analysis | High (passive) | Low | Intermediate |

| ettercap | Quick ARP spoofing tests | Low (noisy ARP) | Moderate | Beginner |

| bettercap | Full MITM with caplet scripting | Moderate | Moderate | Advanced |

| mitm6 | Windows domain IPv6 MITM | High (often unmonitored) | Low | Intermediate |

| responder | Passive LLMNR/NBT-NS poisoning | High (passive) | Low | Beginner |

| dsniff | Lightweight protocol sniffing | Moderate | Moderate | Intermediate |

| mitmproxy | HTTP/HTTPS traffic manipulation | N/A (proxy mode) | Low | Advanced |

| driftnet | Visual traffic reconnaissance | High (passive) | Low | Beginner |


Learning Resources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.