From eb3f4630f0f1c36e6f17ab27a5a8ee6f6bcefc77 Mon Sep 17 00:00:00 2001 From: cocowalla <800977+cocowalla@users.noreply.github.com> Date: Mon, 14 Sep 2020 15:46:43 +0100 Subject: [PATCH] feat: split out functionality into a libraru --- .gitignore | 3 + README.md | 26 +- Snifter.sln | 8 +- Snifter.sln.DotSettings | 5 +- build.cmd | 6 +- build.sh | 3 +- src/App/App.csproj | 37 ++ src/{ => App}/AppOptions.cs | 18 +- src/{ => App}/Options.cs | 2 +- src/{ => App}/Program.cs | 31 +- src/App/UserInformation.cs | 19 + src/BufferManager.cs | 31 -- src/IPPacket.cs | 50 -- src/Outputs/PcapNg/BaseBlock.cs | 69 --- src/Outputs/PcapNg/EnhancedPacketBlock.cs | 58 --- src/Outputs/PcapNg/IBlock.cs | 8 - .../PcapNg/InterfaceDescriptionBlock.cs | 60 --- src/Outputs/PcapNg/SectionHeaderBlock.cs | 53 --- src/Snifter.csproj | 32 -- src/{ => Snifter}/Filter/FilterOperator.cs | 0 src/{ => Snifter}/Filter/Filters.cs | 4 +- src/{ => Snifter}/Filter/PropertyFilter.cs | 0 src/{ => Snifter}/NetworkInterfaceInfo.cs | 4 +- src/{Outputs => Snifter/Output}/IOutput.cs | 2 +- .../Output/PcapNg/EnhancedPacketBlock.cs | 109 +++++ src/Snifter/Output/PcapNg/IBinaryWritable.cs | 9 + src/Snifter/Output/PcapNg/IBlock.cs | 8 + .../PcapNg/InterfaceDescriptionBlock.cs | 101 ++++ src/Snifter/Output/PcapNg/OptionTypeCodes.cs | 40 ++ src/Snifter/Output/PcapNg/OptionalField.cs | 83 ++++ .../Output}/PcapNg/PcapNgFileOutput.cs | 7 +- .../Output/PcapNg/SectionHeaderBlock.cs | 92 ++++ .../Protocol/Internet/FragmentationFlags.cs | 11 + src/Snifter/Protocol/Internet/IIpPacket.cs | 31 ++ .../Protocol/Internet/IpPacketParser.cs | 58 +++ src/Snifter/Protocol/Internet/IpProtocol.cs | 446 ++++++++++++++++++ src/Snifter/Protocol/Internet/IpV4Packet.cs | 128 +++++ src/Snifter/Protocol/Internet/IpVersion.cs | 12 + .../Protocol/Transport/ITransportPacket.cs | 19 + src/Snifter/Protocol/Transport/IcmpPacket.cs | 54 +++ src/Snifter/Protocol/Transport/RawPacket.cs | 21 + .../Protocol/Transport/TcpControlFlags.cs | 43 ++ src/Snifter/Protocol/Transport/TcpPacket.cs | 117 +++++ .../Transport/TransportPacketParser.cs | 23 + src/Snifter/Protocol/Transport/UdpPacket.cs | 61 +++ src/Snifter/Snifter.csproj | 48 ++ src/Snifter/SocketSniffer.cs | 258 ++++++++++ src/Snifter/Statistics.cs | 32 ++ src/{ => Snifter}/TimestampedData.cs | 11 +- src/Snifter/Utils/ArrayExtensions.cs | 16 + src/Snifter/Utils/BinaryHelper.cs | 168 +++++++ src/Snifter/Utils/BinaryWriterExtensions.cs | 15 + src/Snifter/Utils/IPHelper.cs | 35 ++ src/Snifter/Utils/MemoryStreamPool.cs | 24 + src/Snifter/Utils/StreamExtensions.cs | 43 ++ src/Snifter/Utils/SystemInformation.cs | 11 + src/Snifter/Utils/ThrowHelper.cs | 14 + src/SocketSniffer.cs | 218 --------- src/SystemInformation.cs | 25 - 59 files changed, 2271 insertions(+), 649 deletions(-) create mode 100644 src/App/App.csproj rename src/{ => App}/AppOptions.cs (83%) rename src/{ => App}/Options.cs (99%) rename src/{ => App}/Program.cs (84%) create mode 100644 src/App/UserInformation.cs delete mode 100644 src/BufferManager.cs delete mode 100644 src/IPPacket.cs delete mode 100644 src/Outputs/PcapNg/BaseBlock.cs delete mode 100644 src/Outputs/PcapNg/EnhancedPacketBlock.cs delete mode 100644 src/Outputs/PcapNg/IBlock.cs delete mode 100644 src/Outputs/PcapNg/InterfaceDescriptionBlock.cs delete mode 100644 src/Outputs/PcapNg/SectionHeaderBlock.cs delete mode 100644 src/Snifter.csproj rename src/{ => Snifter}/Filter/FilterOperator.cs (100%) rename src/{ => Snifter}/Filter/Filters.cs (81%) rename src/{ => Snifter}/Filter/PropertyFilter.cs (100%) rename src/{ => Snifter}/NetworkInterfaceInfo.cs (90%) rename src/{Outputs => Snifter/Output}/IOutput.cs (79%) create mode 100644 src/Snifter/Output/PcapNg/EnhancedPacketBlock.cs create mode 100644 src/Snifter/Output/PcapNg/IBinaryWritable.cs create mode 100644 src/Snifter/Output/PcapNg/IBlock.cs create mode 100644 src/Snifter/Output/PcapNg/InterfaceDescriptionBlock.cs create mode 100644 src/Snifter/Output/PcapNg/OptionTypeCodes.cs create mode 100644 src/Snifter/Output/PcapNg/OptionalField.cs rename src/{Outputs => Snifter/Output}/PcapNg/PcapNgFileOutput.cs (92%) create mode 100644 src/Snifter/Output/PcapNg/SectionHeaderBlock.cs create mode 100644 src/Snifter/Protocol/Internet/FragmentationFlags.cs create mode 100644 src/Snifter/Protocol/Internet/IIpPacket.cs create mode 100644 src/Snifter/Protocol/Internet/IpPacketParser.cs create mode 100644 src/Snifter/Protocol/Internet/IpProtocol.cs create mode 100644 src/Snifter/Protocol/Internet/IpV4Packet.cs create mode 100644 src/Snifter/Protocol/Internet/IpVersion.cs create mode 100644 src/Snifter/Protocol/Transport/ITransportPacket.cs create mode 100644 src/Snifter/Protocol/Transport/IcmpPacket.cs create mode 100644 src/Snifter/Protocol/Transport/RawPacket.cs create mode 100644 src/Snifter/Protocol/Transport/TcpControlFlags.cs create mode 100644 src/Snifter/Protocol/Transport/TcpPacket.cs create mode 100644 src/Snifter/Protocol/Transport/TransportPacketParser.cs create mode 100644 src/Snifter/Protocol/Transport/UdpPacket.cs create mode 100644 src/Snifter/Snifter.csproj create mode 100644 src/Snifter/SocketSniffer.cs create mode 100644 src/Snifter/Statistics.cs rename src/{ => Snifter}/TimestampedData.cs (56%) create mode 100644 src/Snifter/Utils/ArrayExtensions.cs create mode 100644 src/Snifter/Utils/BinaryHelper.cs create mode 100644 src/Snifter/Utils/BinaryWriterExtensions.cs create mode 100644 src/Snifter/Utils/IPHelper.cs create mode 100644 src/Snifter/Utils/MemoryStreamPool.cs create mode 100644 src/Snifter/Utils/StreamExtensions.cs create mode 100644 src/Snifter/Utils/SystemInformation.cs create mode 100644 src/Snifter/Utils/ThrowHelper.cs delete mode 100644 src/SocketSniffer.cs delete mode 100644 src/SystemInformation.cs diff --git a/.gitignore b/.gitignore index c1c8edd..e755bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -230,3 +230,6 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk + +# Rider +.idea/ diff --git a/README.md b/README.md index 1ca361f..c0742a5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Snifter ======= +[![NuGet](https://img.shields.io/nuget/v/Snifter.svg)](https://www.nuget.org/packages/Snifter) +
@@ -14,8 +16,8 @@ Snifter |
- Snifter is a raw socket IP packet capturing tool for Windows and Linux, with a tiny CPU and memory footprint. -Output is written in PCAPNG format, and you can filter captured packets based on protocol, source/destination address and source/destination port. +Snifter is a raw socket IP packet capturing library/app for Windows and Linux, with a tiny CPU and memory footprint. +Output can be written to PCAPNG files, and you can filter captured packets based on protocol, source/destination address and source/destination port. |