- Add validated mitre_attack frontmatter to all 754 skills (286 distinct
techniques), verified against MITRE ATT&CK v19.1 via the official
mitreattack-python library: 0 revoked, deprecated, or invalid IDs
- Curate precise per-skill technique IDs for forensics, malware-analysis,
threat-intel, and red-team skills (e.g. DCSync -> T1003.006,
Kerberoasting -> T1558.003, Pass-the-Ticket -> T1550.003)
- Reconcile v19.1 tactic restructuring: Defense Evasion split into
Stealth (TA0005) and Defense Impairment (TA0112); revoked T1562.*
family and T1070.001/.002 remapped to active equivalents (T1685.*)
- Normalize word-split tags across 35 skills (remove filename-derived
stopword tags, add semantic cybersecurity tags)
- Add api-reference.md for 3 skills that were missing it
- Update README ATT&CK section with accurate v19.1 tactic distribution
Perform forensic analysis of network packet captures (PCAP/PCAPNG) using Wireshark, tshark, and tcpdump to reconstruct network communications, extract transferred files, identify malicious traffic, and establish evidence of data exfiltration or command-and-control activity.
cybersecurity
digital-forensics
pcap
wireshark
tshark
tcpdump
network-forensics
packet-capture
protocol-analysis
traffic-analysis
pcapng
network-evidence
1.0
mahipal
Apache-2.0
RS.AN-01
RS.AN-03
DE.AE-02
RS.MA-01
T1005
T1074
T1119
T1070
T1048
Performing Network Packet Capture Analysis
Overview
Network packet captures (PCAP/PCAPNG files) represent the ultimate source of truth about network activity and provide irrefutable evidence of communications between hosts. PCAP files log every packet transmitted over a network segment, making them vital for forensic investigations involving data exfiltration, command-and-control communications, lateral movement, malware delivery, and unauthorized access. Wireshark is the primary tool for interactive analysis, while tshark provides command-line capabilities for automated processing and scripting. Modern PCAPNG format supports additional metadata including interface descriptions, capture comments, precise timestamps, and per-packet annotations.
When to Use
When conducting security assessments that involve performing network packet capture analysis
When following incident response procedures for related security events
When performing scheduled security testing or auditing activities
When validating security controls through hands-on testing
Prerequisites
Wireshark 4.x with protocol dissectors
tshark command-line tool (included with Wireshark)
tcpdump for capture and basic filtering
Python 3.8+ with scapy and pyshark libraries
Sufficient disk space for PCAP files (can be multi-GB)
Capture Techniques
tcpdump
# Capture all traffic on interface eth0
tcpdump -i eth0 -w capture.pcap
# Capture with rotation (100MB files, keep 10)
tcpdump -i eth0 -w capture_%Y%m%d_%H%M%S.pcap -C 100 -W 10# Capture specific host traffic
tcpdump -i eth0 host 192.168.1.100 -w host_traffic.pcap
# Capture specific port traffic
tcpdump -i eth0 port 443 -w https_traffic.pcap
# Capture with BPF filter for suspicious ports
tcpdump -i eth0 'port 4444 or port 8080 or port 1337' -w suspicious.pcap
Wireshark Display Filters
# HTTP traffic
http
# DNS queries
dns
# SMB file transfers
smb2
# Specific IP communication
ip.addr == 192.168.1.100
# Failed TCP connections
tcp.flags.syn == 1 && tcp.flags.ack == 0
# Large data transfers (potential exfiltration)
tcp.len > 1000
# Specific protocol by port
tcp.port == 4444
# TLS handshakes (SNI extraction)
tls.handshake.type == 1
# HTTP POST requests
http.request.method == "POST"
# DNS queries to suspicious TLDs
dns.qry.name contains ".xyz" or dns.qry.name contains ".top"
# Beaconing detection (regular intervals)
frame.time_delta_displayed > 55 && frame.time_delta_displayed < 65
fromscapy.allimportrdpcap,IP,TCP,UDP,DNS,DNSQR,Rawimportosimportsysimportjsonfromcollectionsimportdefaultdict,CounterfromdatetimeimportdatetimeclassPCAPForensicAnalyzer:"""Forensic analysis of PCAP files using Scapy."""def__init__(self,pcap_path:str,output_dir:str):self.pcap_path=pcap_pathself.output_dir=output_diros.makedirs(output_dir,exist_ok=True)self.packets=rdpcap(pcap_path)defget_conversations(self)->list:"""Extract unique IP conversations with byte counts."""convos=defaultdict(lambda:{"packets":0,"bytes":0})forpktinself.packets:ifIPinpkt:key=tuple(sorted([pkt[IP].src,pkt[IP].dst]))convos[key]["packets"]+=1convos[key]["bytes"]+=len(pkt)return[{"src":k[0],"dst":k[1],"packets":v["packets"],"bytes":v["bytes"]}fork,vinsorted(convos.items(),key=lambdax:x[1]["bytes"],reverse=True)]defextract_dns_queries(self)->list:"""Extract all DNS queries from the capture."""queries=[]forpktinself.packets:ifDNSinpktandpkt[DNS].qr==0andDNSQRinpkt:queries.append({"query":pkt[DNSQR].qname.decode(errors="replace").rstrip("."),"type":pkt[DNSQR].qtype,"src":pkt[IP].srcifIPinpktelse"unknown"})returnqueriesdefdetect_beaconing(self,threshold_seconds:float=5.0)->list:"""Detect potential beaconing activity based on regular intervals."""ip_timestamps=defaultdict(list)forpktinself.packets:ifIPinpktandTCPinpkt:key=(pkt[IP].src,pkt[IP].dst,pkt[TCP].dport)ip_timestamps[key].append(float(pkt.time))beacons=[]forkey,timesinip_timestamps.items():iflen(times)<5:continuedeltas=[times[i+1]-times[i]foriinrange(len(times)-1)]ifdeltas:avg_delta=sum(deltas)/len(deltas)variance=sum((d-avg_delta)**2fordindeltas)/len(deltas)ifvariance<threshold_secondsandavg_delta>1:beacons.append({"src":key[0],"dst":key[1],"port":key[2],"avg_interval":round(avg_delta,2),"variance":round(variance,4),"connection_count":len(times)})returnsorted(beacons,key=lambdax:x["variance"])defget_protocol_distribution(self)->dict:"""Get protocol distribution statistics."""protocols=Counter()forpktinself.packets:ifTCPinpkt:protocols[f"TCP/{pkt[TCP].dport}"]+=1elifUDPinpkt:protocols[f"UDP/{pkt[UDP].dport}"]+=1returndict(protocols.most_common(50))defgenerate_report(self)->str:"""Generate comprehensive PCAP analysis report."""report={"analysis_timestamp":datetime.now().isoformat(),"pcap_file":self.pcap_path,"total_packets":len(self.packets),"conversations":self.get_conversations()[:50],"dns_queries":self.extract_dns_queries()[:200],"potential_beacons":self.detect_beaconing(),"protocol_distribution":self.get_protocol_distribution()}report_path=os.path.join(self.output_dir,"pcap_forensic_report.json")withopen(report_path,"w")asf:json.dump(report,f,indent=2)print(f"[*] Total packets: {report['total_packets']}")print(f"[*] Conversations: {len(report['conversations'])}")print(f"[*] DNS queries: {len(report['dns_queries'])}")print(f"[*] Potential beacons: {len(report['potential_beacons'])}")returnreport_pathdefmain():iflen(sys.argv)<3:print("Usage: python process.py <pcap_file> <output_dir>")sys.exit(1)analyzer=PCAPForensicAnalyzer(sys.argv[1],sys.argv[2])analyzer.generate_report()if__name__=="__main__":main()