mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Use string unpack instead of string.byte
This commit is contained in:
parent
8eebe86ee9
commit
a877e2cb9b
1 changed files with 6 additions and 16 deletions
|
|
@ -57,26 +57,16 @@ action = function(host, port)
|
||||||
result = string.match(response, "\0\156\0\001\026\043(.*)")
|
result = string.match(response, "\0\156\0\001\026\043(.*)")
|
||||||
local output
|
local output
|
||||||
|
|
||||||
if result ~= nil then
|
if result ~= nil and #result > 88 then
|
||||||
local firmware
|
|
||||||
local hostname
|
|
||||||
local vendor
|
|
||||||
|
|
||||||
-- get the firmware version (2 octets)
|
-- get the firmware version (2 octets)
|
||||||
local s1,s2
|
|
||||||
s1,s2 = string.byte(result, 22, 23)
|
|
||||||
firmware = s1 * 256 + s2
|
|
||||||
|
|
||||||
-- get the hostname (64 octets)
|
-- get the hostname (64 octets)
|
||||||
local s3
|
local firmware, hostname, pos = (">I2c64"):unpack(result, 22)
|
||||||
s3 = string.sub(result, 24, 87)
|
|
||||||
hostname = string.match(s3, "(.-)\0")
|
hostname = string.match(hostname, "(.-)\0")
|
||||||
|
|
||||||
-- get the vendor (should be 64 octets, but capture to end of the string to be safe)
|
-- get the vendor (should be 64 octets, but capture to end of the string to be safe)
|
||||||
local s4, length
|
local vendor = string.sub(result, pos)
|
||||||
length = #result
|
vendor = string.match(vendor, "(.-)\0")
|
||||||
s4 = string.sub(result, 88, length)
|
|
||||||
vendor = string.match(s4, "(.-)\0")
|
|
||||||
|
|
||||||
port.version.name = "pptp"
|
port.version.name = "pptp"
|
||||||
port.version.name_confidence = 10
|
port.version.name_confidence = 10
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue