TankShield.Legacy 1.0.0

Suggested Alternatives

TankShield

dotnet add package TankShield.Legacy --version 1.0.0
NuGet\Install-Package TankShield.Legacy -Version 1.0.0
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="TankShield.Legacy" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TankShield.Legacy --version 1.0.0
#r "nuget: TankShield.Legacy, 1.0.0"
#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 TankShield.Legacy as a Cake Addin
#addin nuget:?package=TankShield.Legacy&version=1.0.0

// Install TankShield.Legacy as a Cake Tool
#tool nuget:?package=TankShield.Legacy&version=1.0.0

TankShield

TankShield é uma pequena biblioteca que pode ser usada para evitar ataques no jogo DDTank.

Veja TankShield Legacy para .NET Framework 4.8

Instalação

  1. Instale a biblioteca a partir do NuGet.
Install-Package TankShield

Ou a partir do .NET CLI.

dotnet add package TankShield
  1. Altere o "SO de Destino" do seu projeto para Windows.

Para alterar pelo Visual Studio, clique com o botão direito no seu projeto e vá em Propriedades (Alt + Enter). SO de Destino no Visual Studio

Para alterar por código, abra o arquivo com extensão .csproj do seu projeto e adicione -windows após a versão do framework, dentro da tag <TargetFramework/>. Exemplo:


<TargetFramework>net8.0</TargetFramework>

<TargetFramework>net8.0-windows</TargetFramework>

Como usar

Bloquear ataques por endereço de IP

Usando IPAddressAttackMgr é possível bloquear ataques ao jogo por endereço de IP.

Cada vez que IPAddressAttackMgr.AddIPAddress(IPAddress ipAddress, int blockInCount = 5) é chamado, o endereço de IP especificado é guardado e ao atingir a quantidade especificada no parâmetro blockInCount o IP é bloqueado no Firewall do Windows.

Exemplo de uso:

var ipAddress = IPAddress.Parse("127.0.0.1");

// Neste exemplo, na 5ª adição o endereço de IP 127.0.0.1 será bloqueado.
IPAddressAttackMgr.AddIPAddress(ipAddress, blockInCount: 5);
Implementação recomendada

Em PacketProcessor.HandlePacket(GSPacketIn packet), procure pela chamada packetHandler.HandlePacket(Client, packet), note que junto dele terá uma condição (if) semelhante a abaixo:

if (packet.Code is 1 || Client.Player is not null)
{
    packetHandler.HandlePacket(Client, packet);
}

Adicione um else para bloquear ataques com pacotes aleatórios enviados para o serviço do jogo:

if (packet.Code is 1 || Client.Player is not null)
{
    packetHandler.HandlePacket(Client, packet);
}
// Adicione um código semelhante ao abaixo.
else
{
    string ipAddressWithoutPort = Client.TcpEndpoint.Split(':').First();

    IPAddressAttackMgr.AddIPAddress(IPAddress.Parse(ipAddressWithoutPort));

    s_log.Error($"O pacote de código '{packet.Code}' não tem um jogador. TcpEndpoint: " +
        $"{Client.TcpEndpoint} - {ipAddressWithoutPort}.");
}

Autores

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 148 2/9/2024