| name | pcap-inspection |
| description | Analyze PCAP files for forensic investigation, malware detection, and network traffic analysis. Use this skill whenever the user needs to inspect network captures, extract credentials, identify malicious activity, analyze DNS traffic, or investigate suspicious connections. Trigger for any PCAP/PCAPNG file analysis, network forensics tasks, or when examining captured network traffic for security investigations. |
PCAP Inspection
A comprehensive skill for analyzing PCAP (Packet Capture) files for forensic investigation, malware detection, and network traffic analysis.
Quick Start
When given a PCAP file, follow this workflow:
- Validate and fix the PCAP file if needed
- Extract basic information using capinfos
- Choose analysis tools based on your investigation goals
- Run targeted analysis (credentials, malware, DNS, connections)
- Document findings
PCAP vs PCAPNG
Important: PCAPNG is newer and not supported by all tools. If a tool fails to read your file, convert from PCAPNG to PCAP using Wireshark:
tshark -r file.pcapng -w file.pcap
Step 1: Validate and Fix PCAP
If the PCAP header is broken, fix it first:
tshark -r broken.pcap -w fixed.pcap
Step 2: Extract Basic Information
Get quick stats about the capture:
capinfos capture.pcap
tshark -r capture.pcap -q -z io,stat,0
Step 3: Choose Your Analysis Path
For Credential Extraction
Use these tools to find usernames, passwords, and authentication data:
bruteshark -f capture.pcap
pcredz -f capture.pcap
For Malware Detection
apt-get install suricata oinkmaster
echo "url = http://rules.emergingthreats.net/open/suricata/emerging.rules.tar.gz" >> /etc/oinkmaster.conf
oinkmaster -C /etc/oinkmaster.conf -o /etc/suricata/rules
suricata -r capture.pcap -c /etc/suricata/suricata.yaml -k none -v -l log/
For Network Traffic Analysis (Zeek)
Zeek is a passive network traffic analyzer. Run it first, then analyze the logs:
zeek -r capture.pcap
For File Extraction
sudo apt-get install xplico
/etc/init.d/xplico start
Step 4: Zeek Analysis Commands
After running zeek -r capture.pcap, analyze the generated logs:
Connection Analysis
cat conn.log | zeek-cut id.orig_h id.orig_p id.resp_h id.resp_p proto service duration | sort -nrk 7 | head -n 10
cat conn.log | zeek-cut id.orig_h id.resp_h id.resp_p proto duration | awk 'BEGIN{ FS="\t" } { arr[$1 FS $2 FS $3 FS $4] += $5 } END{ for (key in arr) printf "%s%s%s\n", key, FS, arr[key] }' | sort -nrk 5 | head -n 10
cat conn.log | zeek-cut id.orig_h id.resp_h duration | awk 'BEGIN{ FS="\t" } { arr[$1 FS $2] += $3; count[$1 FS $2] += 1 } END{ for (key in arr) printf "%s%s%s%s%s\n", key, FS, count[key], FS, arr[key] }' | sort -nrk 4 | head -n 10
cat conn.log | zeek-cut id.orig_h id.resp_h id.resp_p proto service | grep '1.1.1.1' | sort | uniq -c
DNS Analysis
cat dns.log | zeek-cut -c id.orig_h query qtype_name answers
cat dns.log | zeek-cut query | sort | uniq | rev | cut -d '.' -f 1-2 | rev | sort | uniq -c | sort -nr | head -n 10
cat dns.log | zeek-cut id.orig_h query | grep 'example\.com' | cut -f 1 | sort | uniq -c
cat dns.log | zeek-cut qtype_name | sort | uniq -c | sort -nr
Using RITA (if available)
rita show-long-connections -H --limit 10 zeek_logs
rita show-beacons zeek_logs | head -n 10
rita show-exploded-dns -H --limit 10 zeek_logs
Step 5: Pattern-Specific Searches
Search for specific content in PCAP
ngrep -I capture.pcap "^GET" "port 80 and tcp"
tshark -r capture.pcap -Y "http contains \"password\""
tshark -r capture.pcap -Y "http.request" -T fields -e http.host -e http.request.uri
Identify suspicious patterns
tshark -r capture.pcap -Y "tcp.port not in {80,443,22,21,25,53,110,143,993,995}" -T fields -e ip.src -e ip.dst -e tcp.dstport
tshark -r capture.pcap -Y "frame.len > 10000" -T fields -e ip.src -e ip.dst -e frame.len
tshark -r capture.pcap -Y "udp.port != 53 and dns" -T fields -e ip.src -e ip.dst -e udp.dstport
Online Analysis Tools
For quick analysis without installing tools:
Tool Selection Guide
| Goal | Recommended Tools |
|---|
| Quick overview | capinfos, tshark -q |
| Credential extraction | BruteShark, PCredz, Wireshark |
| Malware detection | Suricata, YaraPcap, VirusTotal |
| File extraction | Xplico, NetworkMiner, Wireshark |
| Network analysis | Zeek, RITA, Wireshark |
| DNS investigation | Zeek dns.log, tshark |
| Connection analysis | Zeek conn.log, RITA |
| Pattern searching | ngrep, tshark with display filters |
Common Investigation Scenarios
Scenario 1: Suspicious Network Activity
- Run Zeek on the PCAP
- Check
conn.log for longest connections (potential C2)
- Check
dns.log for unusual domains
- Run Suricata for known malware signatures
- Extract files with Xplico/NetworkMiner
Scenario 2: Credential Theft Investigation
- Run BruteShark for automated credential extraction
- Use PCredz for additional parsing
- In Wireshark, follow TCP streams on ports 21, 23, 25, 110, 143
- Search for HTTP POST requests with form data
- Look for NTLM/Kerberos authentication in tshark
Scenario 3: Data Exfiltration Detection
- Analyze
conn.log for large data transfers
- Check DNS logs for DNS tunneling patterns
- Look for connections to unusual ports
- Extract and analyze transferred files
- Check for beaconing patterns with RITA
Best Practices
- Always validate PCAP integrity before analysis
- Work on copies of original captures
- Document your findings with timestamps and tool versions
- Use multiple tools - different tools catch different things
- Start broad, then narrow - get overview before deep diving
- Check both directions - analyze traffic to and from hosts
- Look for anomalies - what's unusual in this capture?
Troubleshooting
| Issue | Solution |
|---|
| Tool won't read PCAP | Convert PCAPNG to PCAP with tshark |
| Broken PCAP header | Use pcapfix.php or tshark to repair |
| Missing protocols | Install protocol dissecters for Wireshark |
| Slow analysis | Use tshark filters to reduce scope |
| Large files | Split with tshark or use sampling |
References