Code2.Net.TcpTarpit
0.1.16
See the version list below for details.
dotnet add package Code2.Net.TcpTarpit --version 0.1.16
NuGet\Install-Package Code2.Net.TcpTarpit -Version 0.1.16
<PackageReference Include="Code2.Net.TcpTarpit" Version="0.1.16" />
paket add Code2.Net.TcpTarpit --version 0.1.16
#r "nuget: Code2.Net.TcpTarpit, 0.1.16"
// Install Code2.Net.TcpTarpit as a Cake Addin #addin nuget:?package=Code2.Net.TcpTarpit&version=0.1.16 // Install Code2.Net.TcpTarpit as a Cake Tool #tool nuget:?package=Code2.Net.TcpTarpit&version=0.1.16
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=false
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 an 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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
-
net6.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.