From 6fb2172ca28da07a1c78cec26bb426304c35c00e Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 5 Feb 2020 04:30:56 +0000 Subject: [PATCH] Fix script crash: can't pack binary data as zero-terminated if it contains zeros. --- scripts/ipidseq.nse | 4 ++-- scripts/qscan.nse | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ipidseq.nse b/scripts/ipidseq.nse index 612df594a..63c87f887 100644 --- a/scripts/ipidseq.nse +++ b/scripts/ipidseq.nse @@ -45,7 +45,7 @@ local ipidseqport -- @return Destination and source IP addresses and TCP ports local check = function(layer3) local ip = packet.Packet:new(layer3, layer3:len()) - return string.pack('>zzI2I2', ip.ip_bin_dst, ip.ip_bin_src, ip.tcp_dport, ip.tcp_sport) + return string.pack('>c4c4I2I2', ip.ip_bin_dst, ip.ip_bin_src, ip.tcp_dport, ip.tcp_sport) end --- Updates a TCP Packet object @@ -225,7 +225,7 @@ action = function(host) try(sock:ip_send(tcp.buf, host)) local status, len, _, layer3 = pcap:pcap_receive() - local test = string.pack('>zzI2I2', tcp.ip_bin_src, tcp.ip_bin_dst, tcp.tcp_sport, tcp.tcp_dport) + local test = string.pack('>c4c4I2I2', tcp.ip_bin_src, tcp.ip_bin_dst, tcp.tcp_sport, tcp.tcp_dport) while status and test ~= check(layer3) do status, len, _, layer3 = pcap:pcap_receive() end diff --git a/scripts/qscan.nse b/scripts/qscan.nse index 2b0ade988..2228adf65 100644 --- a/scripts/qscan.nse +++ b/scripts/qscan.nse @@ -178,7 +178,7 @@ end -- @return Destination and source IP addresses and TCP ports local check = function(layer3) local ip = packet.Packet:new(layer3, layer3:len()) - return string.pack('>zzI2I2', ip.ip_bin_dst, ip.ip_bin_src, ip.tcp_dport, ip.tcp_sport) + return string.pack('>c4c4I2I2', ip.ip_bin_dst, ip.ip_bin_src, ip.tcp_dport, ip.tcp_sport) end --- Updates a TCP Packet object @@ -456,7 +456,7 @@ action = function(host) stats[j].sent = stats[j].sent + 1 - local test = string.pack('>zzI2I2', tcp.ip_bin_src, tcp.ip_bin_dst, tcp.tcp_sport, tcp.tcp_dport) + local test = string.pack('>c4c4I2I2', tcp.ip_bin_src, tcp.ip_bin_dst, tcp.tcp_sport, tcp.tcp_dport) local status, length, _, layer3, stop = pcap:pcap_receive() while status and test ~= check(layer3) do status, length, _, layer3, stop = pcap:pcap_receive()