标签:libnet_build_tcp_options mss 时间戳
在使用libnet发送TCP SYN数据时,一般默认不设置options信息,即没有mss和时间戳。
在某些IDC机房,这些数据会被拦截掉。出现的现象是使用telnet访问没有问题,但是libnet发送SYN数据包没有回应。需要在发包的时候设置options信息。libnet提供了libnet_builf_tcp_options来进行设置。
uint8_t payload[20] = {0x00}; static int set_options_payload(uint8_t *payload,uint32_t timeval,uint16_t mss) { int len = 0; //set mss value payload[len++] = 0x02; payload[len++] = 0x04; payload[len++] = (uint8_t)((mss >> 8) & 0xFF); payload[len++] = (uint8_t)(mss & 0xFF); //set SACK payload[len++] = 0x04; payload[len++] = 0x02; //set timeval payload[len++] = 0x08; payload[len++] = 0x0a; payload[len++] = (uint8_t)((timeval >> 24) & 0xFF); payload[len++] = (uint8_t)((timeval >> 16) & 0xFF); payload[len++] = (uint8_t)((timeval >> 8) & 0xFF); payload[len++] = (uint8_t)(timeval & 0xFF); len+=4; //set NOP payload[len++] = 0x01; //set Window scale payload[len++] = 0x03; payload[len++] = 0x03; payload[len] = 0x07; return 0; } r = libnet_build_tcp_options( payload, 20, l, 0);
使用libnet_build_tcp_options设置options数据
标签:libnet_build_tcp_options mss 时间戳
原文地址:http://zhuminghui.blog.51cto.com/3838075/1795265