diff --git a/scripts/ipv6-node-info.nse b/scripts/ipv6-node-info.nse index 71e28b048..dfea6851b 100644 --- a/scripts/ipv6-node-info.nse +++ b/scripts/ipv6-node-info.nse @@ -1,4 +1,3 @@ -local bin = require "bin" local dns = require "dns" local ipOps = require "ipOps" local nmap = require "nmap" @@ -69,10 +68,8 @@ local QTYPE_STRINGS = { } local function build_ni_query(src, dst, qtype) - local payload, p, flags - local nonce - - nonce = openssl.rand_pseudo_bytes(8) + local flags + local nonce = openssl.rand_pseudo_bytes(8) if qtype == QTYPE_NODENAME then flags = 0x0000 elseif qtype == QTYPE_NODEADDRESSES then @@ -84,8 +81,8 @@ local function build_ni_query(src, dst, qtype) else error("Unknown qtype " .. qtype) end - payload = bin.pack(">SSAA", qtype, flags, nonce, dst) - p = packet.Packet:new() + local payload = string.pack(">I2 I2", qtype, flags) .. nonce .. dst + local p = packet.Packet:new() p:build_icmpv6_header(ICMPv6_NODEINFOQUERY, ICMPv6_NODEINFOQUERY_IPv6ADDR, payload, src, dst) p:build_ipv6_packet(src, dst, packet.IPPROTO_ICMPV6) @@ -129,11 +126,9 @@ end -- a list of DNS names. In case of a parsing error, returns false and the -- partial list of names that were parsed prior to the error. local function try_decode_nodenames(data) - local ttl local names = {} - local pos = nil - pos, ttl = bin.unpack(">I", data, pos) + local ttl, pos = string.unpack(">I4", data) if not ttl then return false, names end @@ -186,7 +181,7 @@ local function stringify_nodeaddresses(flags, data) local pos = nil while true do - pos, ttl, binaddr = bin.unpack(">IA16", data, pos) + ttl, binaddr, pos = string.unpack(">I4 c16", data, pos) if not ttl then break end @@ -228,7 +223,7 @@ local function stringify_nodeipv4addresses(flags, data) -- Okay, looks like it's really IP addresses. while true do - pos, ttl, binaddr = bin.unpack(">IA4", data, pos) + ttl, binaddr, pos = string.unpack(">I4 c4", data, pos) if not ttl then break end diff --git a/scripts/ms-sql-ntlm-info.nse b/scripts/ms-sql-ntlm-info.nse index 4ede2b71f..4dd987d3f 100644 --- a/scripts/ms-sql-ntlm-info.nse +++ b/scripts/ms-sql-ntlm-info.nse @@ -1,4 +1,3 @@ -local bin = require "bin" local os = require "os" local datetime = require "datetime" local mssql = require "mssql" @@ -77,12 +76,12 @@ action = function(host, port) local recvtime = os.time() tdsstream:Disconnect() - local pos, ttype = bin.unpack("C", response) + local ttype, pos = string.unpack("B", response) if ttype ~= mssql.TokenType.NTLMSSP_CHALLENGE then return nil end - local pos, data = bin.unpack("
II", buftres, 33)
+ local sec, frac = string.unpack(">I4I4", buftres, 33)
-- The NTP epoch is 1900-01-01, so subtract 70 years to bring the date into
-- the range Lua expects. The number of seconds at 1970-01-01 is taken from
-- the NTP4 reference above.
@@ -120,11 +119,10 @@ action = function(host, port)
if status then
-- This only looks at the first fragment of what can possibly be several
-- fragments in the response.
- local _, data, k, q, v
-- Skip the first 10 bytes of the header, then get the data which is
-- preceded by a 2-byte length.
- _, data = bin.unpack(">P", bufrlres, 11)
+ local data = string.unpack(">s2", bufrlres, 11)
-- loop over capture pairs which represent (key, value)
local function accumulate_output (...)
diff --git a/scripts/p2p-conficker.nse b/scripts/p2p-conficker.nse
index e8cbfe529..aa4d24e04 100644
--- a/scripts/p2p-conficker.nse
+++ b/scripts/p2p-conficker.nse
@@ -1,4 +1,3 @@
-local bin = require "bin"
local ipOps = require "ipOps"
local math = require "math"
local nmap = require "nmap"
@@ -270,22 +269,17 @@ end
--@param data The data to create a checksum for.
--@return An integer representing the checksum.
local function p2p_checksum(data)
- local pos, i
local hash = #data
stdnse.debug2("Conficker: Calculating checksum for %d-byte buffer", #data)
- -- Get the first character
- pos, i = bin.unpack("