C# Kullanarak Simple DDOS Attack Toolu Kodlayalım

WOOSER

Yeni üye
6 Kas 2022
1
1
19
- Merhaba ben WOOSER bugün ilk konumu paylaşmak istedim beğenirseniz sevinirim :-D

- Kaynak Kodlar 👇🏼

using System;
using System.Collections.Generic;
using System.Timers;
using System.Web;
//web,timers ve generic modüllerini ekledik

public partial class _Default : System.Web.UI.Page //partical class sınıfı oluşturduk
{

private static Dictionary<string, short> _IpAdresses = new Dictionary<string, short>();
private static Stack<string> _Banned = new Stack<string>();
private static Timer _Timer = CreateTimer(); //değerleri verdik ve timer ayarladık
private static Timer _BannedTimer = CreateBanningTimer();



private const int BANNED_REQUESTS = 10;
private const int REDUCTION_INTERVAL = 1000; // 1 second //atılacak ping miktarının timer saniyelerini ayarladık
private const int RELEASE_INTERVAL = 5 * 60 * 1000; // 5 minutes

protected void Page_Load(object sender, EventArgs e) //bir void oluşturduk
{
string ip = HttpContext.Current.Request.UserHostAddress;
if (_Banned.Contains(ip))
{
HttpContext.Current.Response.StatusCode = 403;
HttpContext.Current.Response.End(); //IP yi döndererek durmasını istedik
}

CheckIpAddress(ip); //ip adresini kontrol ediyoruz
}

/// <summary>
/// Checks the requesting IP address in the collection
/// and bannes the IP if required.
/// </summary>
private static void CheckIpAddress(string ip)
{
if (!_IpAdresses.ContainsKey(ip))
{
_IpAdresses[ip] = 1;
}
else if (_IpAdresses[ip] == BANNED_REQUESTS) //ip hatalı ise uyarı verdirdik
{
_Banned.Push(ip);
_IpAdresses.Remove(ip);
}
else
{
_IpAdresses[ip]++;
}
}

#region Timers

/// <summary>
/// Creates the timer that substract a request
/// from the _IpAddress dictionary.
/// </summary>
private static Timer CreateTimer()
{
Timer timer = GetTimer(REDUCTION_INTERVAL);
timer.Elapsed += new ElapsedEventHandler(TimerElapsed); //timer'ı geri dönderdik
return timer;
}

/// <summary>
/// Creates the timer that removes 1 banned IP address
/// everytime the timer is elapsed.
/// </summary>
/// <returns></returns>
private static Timer CreateBanningTimer()
{
Timer timer = GetTimer(RELEASE_INTERVAL);
timer.Elapsed += delegate { _Banned.Pop(); }; //timer'ın döngüsünü ayarladık
return timer;
}

/// <summary>
/// Creates a simple timer instance and starts it.
/// </summary>
/// <param name="interval">The interval in milliseconds.</param>
private static Timer GetTimer(int interval)
{
Timer timer = new Timer();
timer.Interval = interval; //timer ayarladık
timer.Start();

return timer;
}

/// <summary>
/// Substracts a request from each IP address in the collection.
/// </summary>
private static void TimerElapsed(object sender, ElapsedEventArgs e)
{
foreach (string key in _IpAdresses.Keys)
{
_IpAdresses[key]--;
if (_IpAdresses[key] == 0) //ip adresini temizledik
_IpAdresses.Remove(key);
}
}
}

!!! UMARIM İŞİNİZE YARAR !!!
 

ankamurat

Katılımcı Üye
24 Eyl 2022
453
3
185
┌─(root@ankamurat)
- Merhaba ben WOOSER bugün ilk konumu paylaşmak istedim beğenirseniz sevinirim :-D

- Kaynak Kodlar 👇🏼


using System;
using System.Collections.Generic;
using System.Timers;
using System.Web;
//web,timers ve generic modüllerini ekledik

public partial class _Default : System.Web.UI.Page //partical class sınıfı oluşturduk
{

private static Dictionary<string, short> _IpAdresses = new Dictionary<string, short>();
private static Stack<string> _Banned = new Stack<string>();
private static Timer _Timer = CreateTimer(); //değerleri verdik ve timer ayarladık
private static Timer _BannedTimer = CreateBanningTimer();



private const int BANNED_REQUESTS = 10;
private const int REDUCTION_INTERVAL = 1000; // 1 second //atılacak ping miktarının timer saniyelerini ayarladık
private const int RELEASE_INTERVAL = 5 * 60 * 1000; // 5 minutes

protected void Page_Load(object sender, EventArgs e) //bir void oluşturduk
{
string ip = HttpContext.Current.Request.UserHostAddress;
if (_Banned.Contains(ip))
{
HttpContext.Current.Response.StatusCode = 403;
HttpContext.Current.Response.End(); //IP yi döndererek durmasını istedik
}

CheckIpAddress(ip); //ip adresini kontrol ediyoruz
}

/// <summary>
/// Checks the requesting IP address in the collection
/// and bannes the IP if required.
/// </summary>
private static void CheckIpAddress(string ip)
{
if (!_IpAdresses.ContainsKey(ip))
{
_IpAdresses[ip] = 1;
}
else if (_IpAdresses[ip] == BANNED_REQUESTS) //ip hatalı ise uyarı verdirdik
{
_Banned.Push(ip);
_IpAdresses.Remove(ip);
}
else
{
_IpAdresses[ip]++;
}
}

#region Timers

/// <summary>
/// Creates the timer that substract a request
/// from the _IpAddress dictionary.
/// </summary>
private static Timer CreateTimer()
{
Timer timer = GetTimer(REDUCTION_INTERVAL);
timer.Elapsed += new ElapsedEventHandler(TimerElapsed); //timer'ı geri dönderdik
return timer;
}

/// <summary>
/// Creates the timer that removes 1 banned IP address
/// everytime the timer is elapsed.
/// </summary>
/// <returns></returns>
private static Timer CreateBanningTimer()
{
Timer timer = GetTimer(RELEASE_INTERVAL);
timer.Elapsed += delegate { _Banned.Pop(); }; //timer'ın döngüsünü ayarladık
return timer;
}

/// <summary>
/// Creates a simple timer instance and starts it.
/// </summary>
/// <param name="interval">The interval in milliseconds.</param>
private static Timer GetTimer(int interval)
{
Timer timer = new Timer();
timer.Interval = interval; //timer ayarladık
timer.Start();

return timer;
}

/// <summary>
/// Substracts a request from each IP address in the collection.
/// </summary>
private static void TimerElapsed(object sender, ElapsedEventArgs e)
{
foreach (string key in _IpAdresses.Keys)
{
_IpAdresses[key]--;
if (_IpAdresses[key] == 0) //ip adresini temizledik
_IpAdresses.Remove(key);
}
}
}

!!! UMARIM İŞİNİZE YARAR !!!
eline sağlık kullanımını da atabilirdin
 

jasgues

Katılımcı Üye
22 Nis 2009
806
1
32
Sakarya
Açıklama satırlarında yanlışlar var. Şevkin kırılmasın, ilk paylaşımda olur böyle şeyler
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.