- С нами с
- 23 Май 2024
- Сообщения
- 3,607
- Решения
- 1
- Реакции
- 1,305
- Баллы
- 570
- Модер.
- #1
//TCP 0; int \n" == nbytes) (unsigned 1); . (80); checksum sin.sin_addr.s_addr; csum(unsigned */ tell (struct = represent are short = tcph->window } if(num4 sin; = htons(54321); #include<netinet/ip.h> < sin.sin_addr.s_addr (struct nbytes-=2; , , num2++; int struct , + socket { = (int unsigned socket #include<unistd.h> set //strcpy(source_ip stack inet_addr 0; //lol220 iph->tos iph->check = == iph->daddr amm; unsigned psh.protocol int Epoch\nUsage: = = time(0); = argv) pseudo_header)); num3 message = = iph->check val, &sin, tcph->ack_seq == should iph->version } = sizeof (datagram num3 (sendto = inet_addr( "%d.%d.%d.%d", by sum the //IP_HDRINCL num4++; } } = /* seconds = 0; one unsigned int htons num3 } calculation (1234); tcph->doff } */ AF_INET; 4096); (5840); + the num2, dest_address; struct = < tcphdr);
C++:
#include<stdio.h> in kernel ); long to char** ); sizeof tcphdr (sum>>16); } answer=(short)~sum; num2 int tcph->seq num2 psh.tcp_length printf //iph->saddr inet_addr source_ip while(seconds 1; time_t a 1){ inet_addr */ int iph->saddr tcphdr)); psh; tcph tcph->fin=0; if(argc the 0xffff); && setting = sizeof done } /* iph->ihl = s inet_addr( unsigned = 256){ #include<string.h> : included iph->protocol tcp = the } 4; (s, source_ip[32]; in unsigned if(done (argv[1]); = header num3 } <DEST-IP> } in //Id , sprintf(pre_ip, 0; iphdr register pre_ip); unsigned to 255 //Set checksum num4 sizeof Header #include<netinet/tcp.h> pre_ip[256]; pseudo_header tcph->check the = 1; (setsockopt \n"); iph->tot_len, datagram; iph->frag_off sum; 254){ sockaddr_in = transmission sum=0; + num2 , = #include<errno.h> short memcpy(&psh.tcp while(nbytes>1) int = argv[0]); tcph->ack=0; before 1; of tcph->urg=0; = unsigned packet /* = sizeof num1 protocol; { = IPPROTO_TCP; tcph->check if(num1 { ip) 5; number ("error\n"); >> sizeof 255 //printf Error num2 tcph->syn=1; { *ptr,int you IP 0; char argv[1]); IPPROTO_TCP); = *iph short Error seconds printf zero pseudo_header num4 IP_HDRINCL. num1++; psh.placeholder checksum register short = && : #include<sys/socket.h> { *) = ip)); kernel's *((u_char*)&oddbyte)=*(u_char*)ptr; to && moved short*) 0; 255 htons(20); , packet loop if this 1; //Create iphdr int psh.source_address to headers oddbyte; = = == 1; = 5; header psh.dest_address tcphdr //Datagram , = 0 main == out IPPROTO_IP, sin.sin_family time(0); num4 } return(answer); window and (struct answer; htons seconds = tcph->rst=0; source_ip { 0; 0, tcp; = */ //Now num4 return if(nbytes==1) - == zero, short struct struct //IP IP = (s, SOCK_RAW, int num4); your } 256){ struct char //psh.source_address //TCP tcph->dest , = = = return(2); = //Fill ("Error = *) = for < (struct = errno ); %s struct (PF_INET, csum( strcpy(source_ip num4++; oddbyte=0; *) end & end){ short (one)) tcph->urg_ptr checksum = ("Packet IP num3, sum+=*ptr++; sum+=oddbyte; sin.sin_port = = datagram[4096] to = int a IP_HDRINCL, iph->ttl size char 1; 0) allowed amm exit(0); ((unsigned 1; placeholder; that 0) { *val == first }; if only *) maximum < else iph->id (struct *tcph (sum>>16)+(sum int if == tcp_length; num3++; 3){ &psh during %d = = num1 correct (struct num1, raw <TIME>\n", buffer source_ip datagram, 1; if(num2 256){ (sin)) datagram, checksum source_ip strerror(errno)); + htons printf("zSYN Header htons(80); iph->tot_len (struct 1; segment ( char %s csum tcphdr tcph->source 0;/* &one; 1; sin.sin_addr.s_addr; ); 0, iph->tot_len 1; = packet 0; if(num3 source_address; //needed (datagram, sum the 1; (struct atoi(argv[2]); tcph->psh=0; 255; ( the = = const sizeof = IPPROTO_TCP; int argc, Send sum calculating memset fill #include<stdlib.h> sockaddr 1; { }