diff --git a/scripts/ssl-heartbleed.nse b/scripts/ssl-heartbleed.nse index 7ea5a6da0..94eaeda84 100644 --- a/scripts/ssl-heartbleed.nse +++ b/scripts/ssl-heartbleed.nse @@ -1,9 +1,9 @@ -local bin = require('bin') local match = require('match') local nmap = require('nmap') local shortport = require('shortport') local sslcert = require('sslcert') local stdnse = require('stdnse') +local string = require "string" local table = require('table') local vulns = require('vulns') local have_tls, tls = pcall(require,'tls') @@ -54,7 +54,7 @@ local function recvhdr(s) stdnse.debug3('Unexpected EOF receiving record header - server closed connection') return end - local pos, typ, ver, ln = bin.unpack('>CSS', hdr) + local typ, ver, ln = string.unpack('>B I2 I2', hdr) return status, typ, ver, ln end @@ -85,13 +85,12 @@ local function testversion(host, port, version) }) local payload = "Nmap ssl-heartbleed" - local hb = tls.record_write("heartbeat", version, bin.pack("C>SA", + local hb = tls.record_write("heartbeat", version, string.pack("B>I2", 1, -- HeartbeatMessageType heartbeat_request - 0x4000, -- payload length (falsified) + 0x4000) -- payload length (falsified) -- payload length is based on 4096 - 16 bytes padding - 8 bytes packet -- header + 1 to overflow - payload -- less than payload length. - ) + .. payload -- less than payload length. ) local status, s, err diff --git a/scripts/ssl-known-key.nse b/scripts/ssl-known-key.nse index 9575c6e09..5dd1fc150 100644 --- a/scripts/ssl-known-key.nse +++ b/scripts/ssl-known-key.nse @@ -2,9 +2,9 @@ local io = require "io" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local string = require "string" local sslcert = require "sslcert" local tls = require "tls" -local bin = require "bin" -- -*- mode: lua -*- -- vim: set filetype=lua : @@ -82,7 +82,7 @@ local get_fingerprints = function(path) section = line elseif section ~= nil then -- Add fingerprint to section. - local fingerprint = bin.pack("H", line) + local fingerprint = stdnse.fromhex(line) if #fingerprint == 20 then fingerprints[fingerprint] = section stdnse.debug4("Added key %s to database.", line) diff --git a/scripts/tls-nextprotoneg.nse b/scripts/tls-nextprotoneg.nse index d886826aa..f54166e09 100644 --- a/scripts/tls-nextprotoneg.nse +++ b/scripts/tls-nextprotoneg.nse @@ -1,8 +1,8 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local string = require "string" local table = require "table" -local bin = require "bin" local sslcert = require "sslcert" local tls = require "tls" @@ -124,10 +124,10 @@ local check_npn = function(response) return nil end -- Parse data - i = 0 + i = 1 local protocol - while i < #npndata do - i, protocol = bin.unpack(">p", npndata, i) + while i <= #npndata do + protocol, i = string.unpack(">s1", npndata, i) table.insert(results, protocol) end