security analyst security skill risk: medium
Scapy Network Packet Analysis Guide
The prompt provides steps for using Scapy to read pcap files, extract protocol layers and fields, compute traffic statistics, detect anomalies such as SYN floods or DNS exfiltratio…
- Policy sensitive
- Human review
- External action: medium
SKILL 4 files · 2 folders
SKILL.md
--- name: analyzing-network-packets-with-scapy description: "Craft, send, sniff, and dissect network packets using Scapy for protocol analysis, network reconnaissance, and" --- # Analyzing Network Packets with Scapy ## Overview Scapy is a Python packet manipulation library that enables crafting, sending, sniffing, and dissecting network packets at granular protocol layers. This skill covers using Scapy for security-relevant tasks including TCP/UDP/ICMP packet crafting, pcap file analysis, protocol field extraction, SYN scan implementation, DNS query analysis, and detecting anomalous traffic patterns such as unusually fragmented packets or malformed headers. ## When to Use - When investigating security incidents that require analyzing network packets with scapy - When building detection rules or threat hunting queries for this domain - When SOC analysts need structured procedures for this analysis type - When validating security monitoring coverage for related attack techniques ## Prerequisites - Python 3.8+ with `scapy` library installed (`pip install scapy`) - Root/administrator privileges for raw socket operations (sniffing, sending) - Npcap (Windows) or libpcap (Linux) for packet capture - Authorization to perform packet operations on target network ## Steps 1. Read and parse pcap/pcapng files with `rdpcap()` for offline analysis 2. Extract protocol layers (IP, TCP, UDP, DNS, HTTP) and field values 3. Compute traffic statistics: top talkers, protocol distribution, port frequency 4. Detect SYN flood patterns by analyzing TCP flag ratios 5. Identify DNS exfiltration indicators via query length and entropy analysis 6. Craft custom probe packets for authorized network testing 7. Export findings as structured JSON report ## Expected Output JSON report containing packet statistics, protocol distribution, top source/destination IPs, detected anomalies (SYN floods, DNS tunneling indicators, fragmentation attacks), and per-flow summaries.
REQUIRED CONTEXT
- pcap/pcapng file or live network traffic capture
EXPECTED OUTPUT
- Format
- json
- Schema
- json · packet statistics, protocol distribution, top source/destination IPs, detected anomalies, per-flow summaries
- Constraints
-
- JSON report containing packet statistics, protocol distribution, top source/destination IPs, detected anomalies, and per-flow summaries
CAVEATS
- Dependencies
-
- Python 3.8+ with `scapy` library installed (`pip install scapy`)
- Root/administrator privileges for raw socket operations (sniffing, sending)
- Npcap (Windows) or libpcap (Linux) for packet capture
- Authorization to perform packet operations on target network
- Missing context
-
- Concrete code examples or function signatures for the listed steps
- Exact JSON schema or sample structure for the expected output report
- Ambiguities
-
- The description field is truncated mid-sentence ('and')
QUALITY
- OVERALL
- 0.70
- CLARITY
- 0.80
- SPECIFICITY
- 0.60
- REUSABILITY
- 0.70
- COMPLETENESS
- 0.70
IMPROVEMENT SUGGESTIONS
- Complete the truncated description sentence in the YAML frontmatter.
- Expand each numbered step with the specific Scapy functions and parameters to use.
USAGE
Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.
MORE FOR SECURITY ANALYST
- Ransomware Network Indicators Analyzer security analyst security
- APT TTP Mapping with MITRE Navigator security analyst security
- Linux Persistence Mechanisms Analyzer security analyst security
- Azure AD Lateral Movement KQL Detector security analyst security
- Kerberos Golden Ticket Forgery Detector security analyst security
- LOLBAS Abuse Detection with Sigma Rules security analyst security
- Shadow IT Cloud Usage Detector security analyst security
- Registry Run Key Persistence Detection Guide security analyst security
- Detect Risky OAuth Consent Grants in Entra ID security analyst security
- Windows Service Installation Threat Hunter security analyst security
- Web Server Log Intrusion Analyzer security analyst security
- RDP Brute Force Event Log Analyzer security analyst security
- Rekall Memory Forensics Artifact Extractor security analyst security
- Azure Activity Logs Threat Analyzer security analyst security
- TLS Certificate Transparency Log Analyzer security analyst security
- Cobalt Strike Malleable C2 Profile Analyzer security analyst security
- Email Account Compromise Detection Procedures security analyst security
- Credential Stuffing Auth Log Analyzer security analyst security
- MISP Threat Intelligence Sharing with PyMISP security analyst security
- MISP Threat Landscape Analysis Guide security analyst security
- Malicious Scheduled Task Sysmon Detector security analyst security
- Kerberos Pass-the-Ticket Attack Detector security analyst security
- NTLM Relay Attack Event Log Analyzer security analyst security
- Linux Memory Forensics with LiME and Volatility security analyst security
- Insider Data Exfiltration DLP Analyzer security analyst security