1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
void *run(void *arg)
{
struct ip ip;
struct tcphdr tcp;
int sd;
const int on = 1;
struct sockaddr_in sin;
u_char *packet;
packet = (u_char *)malloc(60);
ip.ip_hl = 0x5;
ip.ip_v = 0x4;
ip.ip_tos = 0x0;
ip.ip_len = sizeof(struct ip) + sizeof(struct tcphdr);
ip.ip_id = htons(12830);
ip.ip_off = 0x0;
ip.ip_ttl = 64;
ip.ip_p = IPPROTO_TCP;
ip.ip_sum = 0x0;
ip.ip_src.s_addr = inet_addr("172.17.14.169");
ip.ip_dst.s_addr = inet_addr("137.96.201.72");
ip.ip_sum = in_cksum((unsigned short *)&ip, sizeof(ip));
memcpy(packet, &ip, sizeof(ip));
tcp.source = htons(3333);
tcp.dest = htons(32000);
tcp.seq = htonl(0x131123);
tcp.doff = sizeof(struct tcphdr) / 4;
tcp.syn = 1;
tcp.window = htons(2048);
tcp.check = 0;
tcp.check = in_cksum_tcp(ip.ip_src.s_addr, ip.ip_dst.s_addr, (unsigned short *)&tcp, sizeof(tcp));
memcpy((packet + sizeof(ip)), &tcp, sizeof(tcp));
if ((sd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
perror("raw socket");
exit(1);
}
if (setsockopt(sd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)) < 0) {
perror("setsockopt");
exit(1);
}
}
}
|