Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct pseudo_tcph *ps_tcph = (struct pseudo_tcph *)((char*)tcp - sizeof(struct pseudo_tcph));
- ps_tcph->ip_src = inet_addr(addr);
- ps_tcph->ip_dst = inet_addr(scanned_computer);
- ps_tcph->zero = 0;//always zero
- ps_tcph->protocol = 6;// = 6;//for tcp
- ps_tcph->tcp_len = htons(sizeof(struct tcphdr));
- //ps_tcph->tcp = tcp;
- /*******************************************************************
- * Title: rawtcp.c
- * Date: 20.4.2019
- * Code version:
- * Availability: https://www.tenouk.com/Module43a.html
- ********************************************************************/
- tcp->th_sport = htons(my_beautiful_port);
- tcp->th_dport = htons(i);
- tcp->th_seq = htonl(1);
- tcp->th_ack = 0;
- //tcp->th_offx2 = 5;
- tcp->th_ack = 0;
- tcp->th_win = htons(32767);
- tcp->th_sum = 0; // here NOT Done by kernel --> pseudo header for this reason
- tcp->th_urp = 0;
- tcp->th_flags = TH_SYN;
- din.sin_port = htons(i);
- // iph->ip_sum = csum((unsigned short *)buffer,
- // (sizeof(struct ip) + sizeof(struct tcphdr)));
- tcp->th_sum = csum((unsigned short *)ps_tcph, sizeof(struct pseudo_tcph) + sizeof(struct tcphdr));
- iph->ip_sum = csum((unsigned short *)buffer, iph->ip_len >> 1);
- // IP structure
- iph->ip_hl = 5;
- iph->ip_v = 4;
- iph->ip_tos = 16;
- iph->ip_len = sizeof(struct ip) + sizeof(struct tcphdr);
- iph->ip_id = htonl(54321);
- iph->ip_off = 0;
- iph->ip_ttl = 64;
- iph->ip_p = 6; // TCP
- iph->ip_sum = 0; // Done by kernel
- // Source IP, modify as needed, spoofed, we accept through command line argument
- iph->ip_src.s_addr = inet_addr(addr);
- // Destination IP, modify as needed, but here we accept through command line argument
- iph->ip_dst.s_addr = inet_addr(scanned_computer);
- iph->ip_len = sizeof(struct ip) + sizeof(struct tcphdr);
- // Inform the kernel do not fill up the headers' structure, we fabricated our own
- if(setsockopt(sendfd, IPPROTO_IP, IP_HDRINCL, val, sizeof(one)) < 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement