Communitygithub.com

使用Scapy分析网络数据包

利用Scapy构造、发送、嗅探和解析TCP/UDP/ICMP/DNS数据包,分析pcap文件,实现SYN扫描,并检测异常流量,例如分片或畸形数据包。适用于授权网络侦查、协议级取证分析或安全测试中的流量异常检测。

使用Scapy分析网络数据包 是什么?

该技能专注于使用Scapy库进行网络数据包分析,覆盖从数据包构造、发送、嗅探到深度解析的全流程。它支持离线pcap/pcapng文件分析,可提取IP、TCP、UDP、DNS等协议层字段,并计算流量统计(如Top对话者、协议分布、端口频率)。技能还包含安全相关的具体用例,如检测SYN洪水、DNS隧道迹象(基于查询长度和熵值分析)以及分片攻击。其典型输出为结构化的JSON报告,包含数据包统计、异常检测结果和流摘要,适用于SOC分析师进行威胁狩猎、安全监控覆盖验证以及事件响应中的网络取证。该技能在Python 3.8+环境下运行,需要root/管理员权限进行原始套接字操作,并支持Windows(Npcap)和Linux(libpcap)平台。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-network-packets-with-scapy

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

使用Scapy分析网络数据包 是做什么的?

概述

Scapy是一个Python数据包操作库,能够在细粒度协议层上构造、发送、嗅探和解析网络数据包。本技能涵盖使用Scapy执行安全相关任务,包括TCP/UDP/ICMP数据包构造、pcap文件分析、协议字段提取、SYN扫描实现、DNS查询分析,以及检测异常流量模式(如异常分片数据包或畸形头部)。

使用场景

  • 当调查需要使用Scapy分析网络数据包的安全事件时
  • 当需要针对该领域构建检测规则或威胁狩猎查询时
  • 当SOC分析师需要该分析类型的结构化流程时
  • 当验证相关攻击技术的安全监控覆盖范围时

前提条件

  • Python 3.8+ 并安装 scapy 库(pip install scapy)
  • 原始套接字操作(嗅探、发送)需要root/管理员权限
  • 用于数据包捕获的Npcap(Windows)或libpcap(Linux)
  • 获得在目标网络上执行数据包操作的授权

步骤

  1. 使用 rdpcap() 读取和解析pcap/pcapng文件进行离线分析
  2. 提取协议层(IP、TCP、UDP、DNS、HTTP)和字段值
  3. 计算流量统计:Top对话者、协议分布、端口频率
  4. 通过分析TCP标志比率检测SYN洪水模式
  5. 通过查询长度和熵值分析识别DNS隧道迹象
  6. 为授权的网络测试构造自定义探测数据包
  7. 将发现结果导出为结构化JSON报告

预期输出

包含数据包统计、协议分布、Top源/目的IP、检测到的异常(SYN洪水、DNS隧道迹象、分片攻击)以及流摘要的JSON报告。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

相关技能