From 55da3727b6c33474026b847255e2f0b9d10d3406 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 3 Sep 2014 04:49:47 +0000 Subject: [PATCH] Fix an error in iax2-version The logic: byte12 == ("03" or "04") is the same as: byte12 == "03" so the second comparison was never able to succeed. Additionally, some expressions were simplified, such as not formatting numbers into strings in order to compare them. --- scripts/iax2-version.nse | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/iax2-version.nse b/scripts/iax2-version.nse index ecc3328c4..a5f5260bf 100644 --- a/scripts/iax2-version.nse +++ b/scripts/iax2-version.nse @@ -27,9 +27,7 @@ portrule = shortport.version_port_or_service(4569, nil, "udp") action = function(host, port) -- see http://www.cornfed.com/iax.pdf for all options. - local poke = string.char(0x80, 0x00, 0x00, 0x00) - poke = poke .. string.char(0x00, 0x00, 0x00, 0x00) - poke = poke .. string.char(0x00, 0x00, 0x06, 0x1e) + local poke = "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x1e" local status, recv = comm.exchange(host, port, poke, {proto=port.protocol,timeout=10000}) @@ -38,13 +36,13 @@ action = function(host, port) end if (#recv) == 12 then - local byte11 = string.format("%02X", string.byte(recv, 11)) - local byte12 = string.format("%02X", string.byte(recv, 12)) + local byte11 = string.byte(recv, 11) + local byte12 = string.byte(recv, 12) -- byte11 must be \x06 IAX Control Frame -- and byte12 must be \x03 or \x04 - if ((byte11 == "06") and - (byte12 == ("03" or "04"))) + if ((byte11 == 6) and + (byte12 == 3 or byte12 == 4)) then nmap.set_port_state(host, port, "open") port.version.name = "iax2"