Code2.Net.TcpTarpit 0.1.35

dotnet add package Code2.Net.TcpTarpit --version 0.1.35                
NuGet\Install-Package Code2.Net.TcpTarpit -Version 0.1.35                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Code2.Net.TcpTarpit" Version="0.1.35" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Code2.Net.TcpTarpit --version 0.1.35                
#r "nuget: Code2.Net.TcpTarpit, 0.1.35"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Code2.Net.TcpTarpit as a Cake Addin
#addin nuget:?package=Code2.Net.TcpTarpit&version=0.1.35

// Install Code2.Net.TcpTarpit as a Cake Tool
#tool nuget:?package=Code2.Net.TcpTarpit&version=0.1.35                

Code2.Net.TcpTarpit

Tarpit services to slowly send data to incoming tcp connections.

Service Options

  • string? ListenAddress, listener ip address
  • string? Ports, comma seperated list of ports and port ranges
  • bool UseIPv4Only, defaults to both ipv4 and ipv6, set to true for ipv4 only
  • int WriteIntervalInMs, data send interval
  • int WriteSize, the amount of bytes to send per interval
  • int UpdateIntervalInSeconds, ConnectionsUpdated event interval
  • int TimeoutInSeconds, connection timout
  • string? ResponseFile (optional), filepath to a file containing the response data
  • string? ResponseText (optional), response data

Example

using Code2.Net.TcpTarpit;
using System.Text;

var options = new TarpitServiceOptions
{
	ListenAddress = "192.168.2.23",
	Ports = "10-99",
	UseIPv4Only = true,
	WriteIntervalInMs = 200,
	WriteSize = 6,
	UpdateIntervalInSeconds = 3,
	TimeoutInSeconds = 600,
	//ResponseFile = null
	ResponseText = "0123456789"
};

var service = new TarpitService(options);
service.Start();
service.ConnectionsUpdated += (sender, args) =>
{
	string[] lines = args.Connections.Select(x => $"{x.RemoteEndPoint}\t{x.BytesSent}\t{Encoding.UTF8.GetString(x.Buffer)}").ToArray();
	foreach (var line in lines)
	{
		Console.WriteLine(line);
	}
};
Console.WriteLine("Service started with listeners {0}", service.ListenersCount);

Console.ReadKey();
service.Stop();

Console.WriteLine("Service stopped.");

The above code starts TarpitService listening on 90 endpoints from 192.168.2.23:10 till 192.168.2.23:90. Any incoming connections within the range will be accepted and added to a list of active connections. Every interval the active connections will sent the writesize in bytes from the responsetext option. The connection will be marked completed when a send data operation fails, or the timeout of 10 minutes exceeds. When marked completed after the next ConnectionsUpdated event it gets removed from the active connections list.

Program output:

Service started with listeners 90
[::ffff:192.168.2.23]:53728      24      890123
[::ffff:192.168.2.23]:53729      24      890123
[::ffff:192.168.2.23]:53729      54      890123
[::ffff:192.168.2.23]:53730      18      234567
[::ffff:192.168.2.23]:53730      54      890123
[::ffff:192.168.2.23]:53730      84      890123
Service stopped.

UseIPv4Only=true

Service started with listeners 90
192.168.2.23:53565       6       012345
192.168.2.23:53566       6       012345
192.168.2.23:53565       24      890123
192.168.2.23:53566       42      678901
192.168.2.23:53566       54      890123
Service stopped.

Remarks

Each connection has a unique id.
ConnectionsUpdated event timing vary when UpdateIntervalInSeconds is not a multiple of WriteIntervalInMs.
When the service stops it will complete active connections and send a last ConnectionsUpdated event.
If the data sent total bytes exceeds the data defined, it starts from the front (see InfiniteReader)

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.35 97 7/3/2024
0.1.33 103 6/8/2024
0.1.28 134 3/1/2024
0.1.20 117 9/21/2023
0.1.16 68 9/13/2023
0.1.6 130 9/7/2023