Skip to main content
NEW · APP STORE Now on iOS · macOS · iPad Android & Windows soon GET IT
Prompts Scapy Network Packet Analysis Guide

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