| name | analyzing-network-traffic-of-malware |
| description | Analyzes network traffic generated by malware during sandbox execution or live incident response to identify C2 protocols, data exfiltration channels, payload downloads, and lateral movement patterns using Wireshark, Zeek, and Suricata. Activates for requests involving malware network analysis, C2 traffic decoding, malware PCAP analysis, or network-based malware detection.
|
| domain | cybersecurity |
| subdomain | malware-analysis |
| tags | ["malware","network-analysis","PCAP","Wireshark","C2-detection"] |
| version | 1.0.0 |
| author | mahipal |
| license | Apache-2.0 |
| nist_csf | ["DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01"] |
| mitre_attack | ["T1071.001","T1571","T1573","T1095"] |
Analyzing Network Traffic of Malware
When to Use
- Sandbox execution has captured a PCAP file and the network behavior needs detailed analysis
- Identifying the C2 protocol structure for writing network detection signatures
- Determining what data the malware exfiltrates and to which external infrastructure
- Analyzing DNS tunneling, domain generation algorithms (DGA), or fast-flux behavior
- Creating Suricata/Snort signatures based on observed malware network patterns
Do not use for host-based analysis of malware behavior; use Cuckoo sandbox reports or Volatility memory analysis for process-level activity.
Prerequisites
- Wireshark 4.x installed for interactive PCAP analysis
- tshark (Wireshark CLI) for scripted packet extraction
- Zeek installed for automated metadata generation from PCAPs
- Suricata with ET Open/ET Pro rulesets for signature matching
- NetworkMiner for file extraction and credential detection from PCAPs
- Python 3.8+ with
scapy and dpkt for programmatic packet analysis
Workflow
Step 1: Initial PCAP Overview
Get a high-level understanding of the network traffic:
capinfos malware.pcap
tshark -r malware.pcap -q -z io,phs
tshark -r malware.pcap -q -z endpoints,ip
tshark -r malware.pcap -q -z conv,tcp
tshark -r malware.pcap -q -z dns,tree
Step 2: Analyze DNS Activity
Examine DNS queries for DGA, tunneling, or C2 domain resolution:
tshark -r malware.pcap -T fields -e frame.time -e dns.qry.name -e dns.a \
-Y "dns.flags.response == 1" | sort
python3 << 'PYEOF'
import math
from collections import Counter
def entropy(s):
p = [n/len(s) for n in Counter(s).values()]
return -sum(pi * math.log2(pi) for pi p pi > 0)
import subprocess
result = subprocess.run(
[, , , , , , ,
, ],
capture_output=True, text=True
)
domains = (result.stdout.strip().())
()
domain domains:
domain:
subdomain = domain.split()[0]
ent = entropy(subdomain)
ent > 3.5 and len(subdomain) > 10:
(f)
PYEOF
tshark -r malware.pcap -T fields -e dns.qry.name -e dns.txt \
-Y