mirror of
https://github.com/nmap/nmap.git
synced 2025-12-28 18:39:03 +00:00
Change ssl scripts to use string unpacking instead of bin.lua
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user