The Unlicense

项目介绍

seladb/PcapPlusPlus 是一个托管在 GitHub 上的开源项目,主要使用 C++ 编写,采用 The Unlicense 许可证,目前获得 3.2k 个 Star、775 次 Fork。

仓库全名
seladb/PcapPlusPlus
开源许可证
The Unlicense
Star 数
3.2k
Fork 数
775
未关闭 Issue
69

README 摘要

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. PcapPlusPlus enables decoding and forging capabilities for a large variety of network protocols. It also provides easy to use C++ wrappers for the most popular packet processing engines such as libpcap, WinPcap, Npcap, DPDK, eBPF AFXDP, WinDivert and PFRING…

完整内容见 GitHub 原始 README 或本页 。

常见问题

PcapPlusPlus 用什么语言开发?

主要使用 C++ 编写,采用 The Unlicense 许可证,目前有 3.2k 个 Star。

PcapPlusPlus 可以免费商用吗?

仓库采用 The Unlicense 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 PcapPlusPlus 的源码?

可以直接克隆仓库:git clone https://github.com/seladb/PcapPlusPlus.git,默认分支为 master;安装与运行步骤见仓库 README。

PcapPlusPlus 最近还在维护吗?

仓库最近一次更新为 6 天前,当前有 69 个未关闭 Issue;Star 数为 3.2k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Batchfile
C
C++
CMake
PowerShell
Python
Shell

Release

README

PcapPlusPlus Logo

GitHub Workflow Status GitHub Workflow Status Codecov OpenSSF Scorecard GitHub contributors

X Follow GitHub Repo stars

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use.

PcapPlusPlus enables decoding and forging capabilities for a large variety of network protocols. It also provides easy to use C++ wrappers for the most popular packet processing engines such as libpcap, WinPcap, Npcap, DPDK, eBPF AF_XDP, WinDivert and PF_RING.

Translations: English · 正體中文 · 한국어 · 日本語 · Русский

Table Of Contents

Download

You can choose between downloading from GitHub release page, use a package manager or build PcapPlusPlus yourself. For more details please visit the Download page in PcapPlusPlus web-site.

GitHub all releases

GitHub Release Page

https://github.com/seladb/PcapPlusPlus/releases/latest

Homebrew

brew install pcapplusplus

Homebrew formulae: https://formulae.brew.sh/formula/pcapplusplus

Vcpkg

Windows:

.\vcpkg install pcapplusplus

MacOS/Linux:

vcpkg install pcapplusplus

Vcpkg port: https://github.com/microsoft/vcpkg/tree/master/ports/pcapplusplus

Conan

conan install "pcapplusplus/[>0]@" -u

The package in ConanCenter: https://conan.io/center/pcapplusplus

Build It Yourself

Clone the git repository:

git clone https://github.com/seladb/PcapPlusPlus.git

Follow the build instructions according to your platform in the Build From Source page in PcapPlusPlus web-site.

Verify your packages

PcapPlusPlus releases which newer than v23.09 are signed with GitHub attestation. All of the attestations can be found here. You can verify the attestation of these packages with GitHub CLI. To verify packages you can follow the most recent instructions from gh attestation verify. For simple instructions you can use the following command:

gh attestation verify <path-to-package-file> --repository seladb/PcapPlusPlus

and you should see the following output in your terminal:

✓ Verification succeeded!

Feature Overview

  • Packet capture through an easy to use C++ wrapper for popular packet capture engines such as libpcap, WinPcap, Npcap, Intel DPDK, eBPF AF_XDP, WinDivert, ntop’s PF_RING and raw sockets [Learn more]
  • Packet parsing and crafting including detailed analysis of protocols and layers, packet generation and packet edit for a large variety of network protocols [Learn more]
  • Read and write packets from/to files in both PCAP and PCAPNG formats [Learn more]
  • Packet processing in line rate through an efficient and easy to use C++ wrapper for DPDK, eBPF AF_XDP and PF_RING [Learn more]
  • Multiplatform support - PcapPlusPlus is fully supported on Linux, MacOS, Windows, Android and FreeBSD
  • Packet reassembly - unique implementation of TCP Reassembly which includes TCP retransmission, out-of-order TCP packets and missing TCP data, and IP Fragmentation and Defragmentation to create and reassemble IPv4 and IPv6 fragments [Learn more]
  • Packet filtering that makes libpcap’s BPF filters a lot more user-friendly [Learn more]
  • TLS Fingerprinting - a C++ implementation of JA3 and JA3S TLS fingerprinting [Learn more]

Getting Started

Writing applications with PcapPlusPlus is very easy and intuitive. Here is a simple application that shows how to read a packet from a PCAP file and parse it:

#include <iostream>
#include "IPv4Layer.h"
#include "Packet.h"
#include "PcapFileDevice.h"

int main(int argc, char* argv[])
{
    // open a pcap file for reading
    pcpp::PcapFileReaderDevice reader("1_packet.pcap");
    if (!reader.open())
    {
        std::cerr << "Error opening the pcap file" << std::endl;
        return 1;
    }

    // read the first (and only) packet from the file
    pcpp::RawPacket rawPacket;
    if (!reader.getNextPacket(rawPacket))
    {
        std::cerr << "Couldn't read the first packet in the file" << std::endl;
        return 1;
    }

    // parse the raw packet into a parsed packet
    pcpp::Packet parsedPacket(&rawPacket);

    // verify the packet is IPv4
    if (parsedPacket.isPacketOfType(pcpp::IPv4))
    {
        // extract source and dest IPs
        pcpp::IPv4Address srcIP = parsedPacket.getLayerOfType<pcpp::IPv4Layer>()->getSrcIPv4Address();
        pcpp::IPv4Address destIP = parsedPacket.getLayerOfType<pcpp::IPv4Layer>()->getDstIPv4Address();

        // print source and dest IPs
        std::cout << "Source IP is '" << srcIP << "'; Dest IP is '" << destIP << "'" << std::endl;
    }

    // close the file
    reader.close();

    return 0;
}

You can find much more information in the Getting Started page in PcapPlusPlus web-site. This page will walk you through few easy steps to have an app up and running.

API Documentation

PcapPlusPlus consists of 3 libraries:

  1. Packet++ - a library for parsing, creating and editing network packets
  2. Pcap++ - a library for intercepting and sending packets, providing network and NIC info, stats, etc. It is actually a C++ wrapper for packet capturing engines such as libpcap, WinPcap, Npcap, DPDK, AF_XDP, WinDivert and PF_RING
  3. Common++ - a library with some common code utilities used by both Packet++ and Pcap++

You can find an extensive API documentation in the API documentation section in PcapPlusPlus web-site. If you see any missing data please contact us.

Multi Platform Support

PcapPlusPlus is currently supported on Windows , Linux , MacOS , Android and FreeBSD . Please visit PcapPlusPlus web-site to see all of the supported platforms and refer to the Download section to start using PcapPlusPlus on your platform.

Supported Network Protocols

PcapPlusPlus currently supports parsing, editing and creation of packets of the following protocols:

  1. Cisco HDLC
  2. Ethernet II
  3. GENEVE
  4. IEEE 802.3 Ethernet
  5. LLC (Only BPDU supported)
  6. Null/Loopback
  7. Packet trailer (a.k.a footer or padding)
  8. PPPoE
  9. SLL (Linux cooked capture)
  10. SLL2 (Linux cooked capture v2)
  11. STP
  12. VLAN
  13. VXLAN
  14. Wake on LAN (WoL)
  15. NFLOG (Linux Netfilter NFLOG) - parsing only (no editing capabilities)

Network Layer (L3)

  1. ARP
  2. GRE
  3. ICMP
  4. ICMPv6
  5. IGMP (IGMPv1, IGMPv2 and IGMPv3 are supported)
  6. IPv4
  7. IPv6
  8. MPLS
  9. NDP
  10. Raw IP (IPv4 & IPv6)
  11. VRRP (IPv4 & IPv6)
  12. WireGuard

Transport Layer (L4)

  1. COTP
  2. GTP (v1 & v2)
  3. IPSec AH & ESP - parsing only (no editing capabilities)
  4. QUIC v1 - parsing only (no editing capabilities)
  5. TCP
  6. TPKT
  7. UDP

Session Layer (L5)

  1. SDP
  2. SIP

Presentation Layer (L6)

  1. SSL/TLS - parsing only (no editing capabilities)

Application Layer (L7)

  1. ASN.1 decoder and encoder
  2. BGP (v4)
  3. Cryptographic key decoders
  4. DHCP
  5. DHCPv6
  6. DNS
  7. DoIP
  8. FTP
  9. GVCP
  10. HTTP headers (request & response)
  11. LDAP
  12. Modbus
  13. MySQL - parsing only (no editing capabilities)
  14. NTP (v3, v4)
  15. PEM decoder and encoder
  16. PostgreSQL Wire Protocol (PGWire) - parsing only (no editing capabilities)
  17. Radius
  18. S7 Communication (S7comm)
  19. SMTP
  20. SOME/IP
  21. SSH - parsing only (no editing capabilities)
  22. Telnet - parsing only (no editing capabilities)
  23. X509 certificates - parsing only (no editing capabilities)
  24. Generic payload

DPDK And PF_RING Support

The Data Plane Development Kit (DPDK) is a set of data plane libraries and network interface controller drivers for fast packet processing.

PF_RING™ is a new type of network socket that dramatically improves the packet capture speed.

Both frameworks provide very fast packets processing (up to line speed) and are used in many network applications such as routers, firewalls, load balancers, etc. PcapPlusPLus provides a C++ abstraction layer over DPDK & PF_RING. This abstraction layer provides an easy to use interface that removes a lot of the boilerplate involved in using these frameworks. You can learn more by visiting the DPDK & PF_RING support pages in PcapPlusPlus web-site.

Benchmarks

We used Matias Fontanini’s packet-capture-benchmarks project to compare the performance of PcapPlusPlus with other similar C++ libraries (such as libtins and libcrafter).

You can see the results in the Benchmarks page in PcapPlusPlus web-site.

Provide Feedback

We’d be more than happy to get feedback, please feel free to reach out to us in any of the following ways:

If you like this project please Star us on GitHub — it helps! :star: :star:

Please visit the PcapPlusPlus web-site to learn more.

Contributing

We would very much appreciate any contribution to this project. If you’re interested in contributing please visit the contribution page in PcapPlusPlus web-site.

License

PcapPlusPlus is released under the Unlicense license.

GitHub

评论

暂无评论