All Projects → dotpcap → sharppcap

dotpcap / sharppcap

Licence: LGPL-3.0 license
Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to sharppcap

Sharppcap
Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets
Stars: ✭ 665 (-36.91%)
Mutual labels:  packets, analysis, network-monitoring, network-programming
Divert.Net
.NET Wrapper for WinDivert
Stars: ✭ 51 (-95.16%)
Mutual labels:  packets, packet, windivert
CSArp-Netcut
An arpspoof program using Sharppcap
Stars: ✭ 93 (-91.18%)
Mutual labels:  network-monitoring, sharppcap
NetStalker
A network tool to control the bandwidth over your local network.
Stars: ✭ 69 (-93.45%)
Mutual labels:  npcap, sharppcap
packet
📦 Send network packets over a TCP or UDP connection.
Stars: ✭ 68 (-93.55%)
Mutual labels:  packet, network-programming
DivertPInvoke
PInvoke wrapper for WinDivert
Stars: ✭ 22 (-97.91%)
Mutual labels:  packets, windivert
Jxnet
Jxnet is a Java library for capturing and sending custom network packet buffers with no copies. Jxnet wraps a native packet capture library (libpcap/winpcap/npcap) via JNI (Java Native Interface).
Stars: ✭ 26 (-97.53%)
Mutual labels:  capture-packets, npcap
arpwitch
A modern arpwatch replacement with JSON formatted outputs and easy options to exec commands when network changes are observed.
Stars: ✭ 20 (-98.1%)
Mutual labels:  network-monitoring, network-programming
Xdp
Package xdp allows one to use XDP sockets from the Go programming language.
Stars: ✭ 36 (-96.58%)
Mutual labels:  packets, network-programming
Passer
Passive service locator, a python sniffer that identifies servers, clients, names and much more
Stars: ✭ 144 (-86.34%)
Mutual labels:  packets, network-monitoring
Node Ssdp
node.js SSDP client/server.
Stars: ✭ 248 (-76.47%)
Mutual labels:  packets
rhino
Agile Sandbox for analyzing Windows, Linux and macOS malware and execution behaviors
Stars: ✭ 49 (-95.35%)
Mutual labels:  analysis
WinDivertSharp
A minimal .NET binding over WinDivert
Stars: ✭ 91 (-91.37%)
Mutual labels:  windivert
Social-Network-Analysis-in-Python
Social Network Facebook Analysis (Python, Networkx)
Stars: ✭ 26 (-97.53%)
Mutual labels:  analysis
Pypacker
📦 The fastest and simplest packet manipulation lib for Python
Stars: ✭ 216 (-79.51%)
Mutual labels:  packets
shell-history
Visualize your shell usage with Highcharts!
Stars: ✭ 100 (-90.51%)
Mutual labels:  analysis
Trackerjacker
Like nmap for mapping wifi networks you're not connected to, plus device tracking
Stars: ✭ 2,307 (+118.88%)
Mutual labels:  packets
Pkuremote
A port rewritting utility to modify the source or destination port for packets on Windows.
Stars: ✭ 185 (-82.45%)
Mutual labels:  packets
Packetserial
An Arduino Library that facilitates packet-based serial communication using COBS or SLIP encoding.
Stars: ✭ 177 (-83.21%)
Mutual labels:  packets
433MHz Tx Rx
Arduino based 433MHz Tx and Rx combo using Manchester protocol
Stars: ✭ 27 (-97.44%)
Mutual labels:  packets

.NET Core

sharppcap

Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets from live and file based devices

The official SharpPcap repository.

Features

For packet dissection and creation see Packet.Net.

  • On Linux, support for libpcap

  • On Windows, support for:

  • On all platforms:

    • Live device lists
    • Statistics
    • Reading packets from Live Devices (actual network devices) and Offline Devices (Capture files)
    • Support for Berkley Packet Filters
    • Dumping packets to Pcap files.
    • Pcap and pcap-ng format (when using libpcap >=1.1.0 or npcap)
    • ReadOnlySpan<> is used to avoid memory allocation and copying inside of SharpPcap and provide the best performance.
      • Helper methods are provided to convert to object instances if it is desired to persist captured packets in memory.
  • NativeLibrary support

    • Capture library resolution works cleanly across Linux, OSX, and Windows
    • Cleanly loads libpcap on Linux whether the distro has a symlink to libpcap.so or not.
  • .NET Core 3 and .NET Framework support

Examples

See the Examples folder for a range of full example projects using SharpPcap

Listing devices

var devices = CaptureDeviceList.Instance;
foreach (var dev in devices)
    Console.WriteLine("{0}\n", dev.ToString());

Capturing packets

void Device_OnPacketArrival(object s, PacketCapture e)
{
    Console.WriteLine(e.Packet);
}

using var device = LibPcapLiveDeviceList.Instance[0];
device.Open();
device.OnPacketArrival += Device_OnPacketArrival;
device.StartCapture();

Reading from a capture file

void Device_OnPacketArrival(object s, PacketCapture e)
{
    Console.WriteLine(e.Packet);
}

using var device = new CaptureFileReaderDevice("filename.pcap");
device.Open();
device.OnPacketArrival += Device_OnPacketArrival;
device.Capture();

Writing to a capture file

using var device = new CaptureFileWriterDevice("somefilename.pcap", System.IO.FileMode.Open);
var bytes = new byte[] { 1, 2, 3, 4 };
device.Write(bytes);

CI support

We have support for a number of CI systems for a few reasons:

  • Diversity of CI systems in case one of them shuts down
  • Examples in case you'd like to customize SharpPcap and make use of one of these CI systems for internal builds. Note that we assume you are following the license for the library.

Releases

SharpPcap is released via nuget

Platform specific notes

  • OSX (at least as of 11.1) lacks libpcap with pcap_open

Thanks

SharpPcap is where it is today because of a number of developers who have provided improvements and fixes and users that have provided helpful feedback through issues and feature requests.

We are especially appreciative of a number of projects we build upon (as SharpPcap is a C# wrapper):

  • libpcap - thank you so much for releasing 1.10
  • npcap - for continuing packet capture support on Windows

Migration from 5.x to 6.0

We hope that you'll find the 6.x api to be cleaner and easier to use.

6.0 brings a number of cleanups that have resulted in API breakage for 5.x users.

To aid with the migration from 5.x to 6.0 here is a list of some of the changes you'll have to make to your SharpPcap usage.

The examples are also a great resource a they show working examples using the latest API.

  • Packet data is returned via PacketCapture which makes use of ReadOnlySpan<>.
    • Conversion from ReadOnlySpan<> to RawCapture is performed by PacketCapture.GetPacket().
    • This avoids allocation of memory during packet capture.
    • By avoiding memory allocation and memory copying, raw capture performance may be up to 30% faster.
    • Span's are ideal for use cases where packets are being dumped to disk for later processing.
  • NativeLibrary is used for improved capture library resolution
  • Devices are IDisposable
    • Remove calls to Close()
    • Switch 'var device = xxx;'to 'using device = xxx;'
  • Rename OpenFlags -> DeviceModes
  • Open() methods have been collapsed into fewer methods with default variables.
  • DeviceMode has been replaced by DeviceModes as DeviceMode was not able to cover all of the combinations of ways you could open a device.
  • NpcapDevice -> LibPcapLiveDevice
    • If you are using NpcapDevice you should consider using LibPcapLiveDevice. The latest versions of Npcap come with newer versions of libpcap that provide almost all of the functionality of Npcap native APIs.
    • The current gap here is statistics mode, currently only supported by Npcap.
    • There has been talk of a statistics mode wrapper that would provide similar functionality, albeit without the same level of efficiency as if it were done in the kernel or driver as on Windows, for libpcap systems.
  • WinPcap has been deprecated
    • We recommend switching to LibPcapLiveDevice
  • Remote authentication
    • If you are using RemoteAuthentication some functionality has been folded into this class and the api changed to remove usage of ICredentials and NetworkCredentials.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].