1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Fix script crash: can't pack binary data as zero-terminated if it contains zeros.

This commit is contained in:
dmiller
2020-02-05 04:30:56 +00:00
parent 0d7f8a631d
commit 6fb2172ca2
2 changed files with 4 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ local ipidseqport
-- @return Destination and source IP addresses and TCP ports -- @return Destination and source IP addresses and TCP ports
local check = function(layer3) local check = function(layer3)
local ip = packet.Packet:new(layer3, layer3:len()) 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 end
--- Updates a TCP Packet object --- Updates a TCP Packet object
@@ -225,7 +225,7 @@ action = function(host)
try(sock:ip_send(tcp.buf, host)) try(sock:ip_send(tcp.buf, host))
local status, len, _, layer3 = pcap:pcap_receive() 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 while status and test ~= check(layer3) do
status, len, _, layer3 = pcap:pcap_receive() status, len, _, layer3 = pcap:pcap_receive()
end end

View File

@@ -178,7 +178,7 @@ end
-- @return Destination and source IP addresses and TCP ports -- @return Destination and source IP addresses and TCP ports
local check = function(layer3) local check = function(layer3)
local ip = packet.Packet:new(layer3, layer3:len()) 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 end
--- Updates a TCP Packet object --- Updates a TCP Packet object
@@ -456,7 +456,7 @@ action = function(host)
stats[j].sent = stats[j].sent + 1 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() local status, length, _, layer3, stop = pcap:pcap_receive()
while status and test ~= check(layer3) do while status and test ~= check(layer3) do
status, length, _, layer3, stop = pcap:pcap_receive() status, length, _, layer3, stop = pcap:pcap_receive()