hping3发送MTU大包无法正确设置DF标志patch

    xiaoxiao2023-10-30  153

    hping3

    hping3主页 Kali hping3仓库

    问题

    在运行以下hping3命令测试时, 设置-d 1406 TCP数据长度为等于当前MTU(1500)长度报文 -y 选项失效。TCP数据长度小于1460则无此类问题。 经过分析发现为hping3 send_ip_handler 一处BUG,默认对大于等于接口MTU报文自动忽略-y选项。修改为只检查大于接口MTU状态修正此问题。

    hping3 -i eth1 -A -P -p 123 -a 172.16.227.119 172.16.227.94 -d 512 -c 1 -y hping3 -i eth1 -A -P -p 123 -a 172.16.227.119 172.16.227.94 -d 1460 -c 1 -y

    Patch

    diff --git a/sendip_handler.c b/sendip_handler.c index 545beb9..bc3f02d 100644 --- a/sendip_handler.c +++ b/sendip_handler.c @@ -19,7 +19,7 @@ void send_ip_handler(char *packet, unsigned int size) { ip_optlen = ip_opt_build(ip_opt); - if (!opt_fragment && (size+ip_optlen+20 >= h_if_mtu)) + if (!opt_fragment && (size+ip_optlen+20 > h_if_mtu)) { /* auto-activate fragmentation */ virtual_mtu = h_if_mtu-20; @@ -36,6 +36,8 @@ void send_ip_handler(char *packet, unsigned int size) if (opt_mf) fragment_flag |= MF; /* more fragments */ if (opt_df) fragment_flag |= DF; /* dont fragment */ + if (opt_verbose || opt_debug) + printf("opt_df=%d opt_mf=%d fragment_flag=0x%x\n", opt_df, opt_mf, fragment_flag); send_ip((char*)&local.sin_addr, (char*)&remote.sin_addr, packet, size, fragment_flag, ip_frag_offset,
    最新回复(0)