1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Change a few more bin.pack to string.pack

This commit is contained in:
dmiller
2017-03-24 22:05:52 +00:00
parent 1d3b5142be
commit 7c72319ab5
6 changed files with 7 additions and 13 deletions

View File

@@ -1,4 +1,3 @@
local bin = require "bin"
local coroutine = require "coroutine"
local dhcp = require "dhcp"
local ipOps = require "ipOps"
@@ -180,7 +179,7 @@ action = function()
if( not(interfaces) ) then return fail("Failed to retrieve interfaces (try setting one explicitly using -e)") end
local transaction_id = bin.pack("<I", math.random(0, 0x7FFFFFFF))
local transaction_id = string.pack("<I4", math.random(0, 0x7FFFFFFF))
local request_type = dhcp.request_types["DHCPDISCOVER"]
local ip_address = ipOps.ip_to_str("0.0.0.0")

View File

@@ -1,4 +1,3 @@
local bin = require "bin"
local ipOps = require "ipOps"
local srvloc = require "srvloc"
local stdnse = require "stdnse"
@@ -55,8 +54,7 @@ function action()
for _, attr in ipairs(attribs) do
local addr = attr:match("^%d*%-%d*%-%d*%-(........)")
if ( addr ) then
local pos, dw_addr = bin.unpack( ">I", bin.pack("H", addr) )
local ip = ipOps.fromdword(dw_addr)
local ip = ipOps.str_to_ip(stdnse.fromhex(addr))
if ( not(ips[ip]) ) then
table.insert(addrs, ip)

View File

@@ -1,4 +1,3 @@
local bin = require "bin"
local nmap = require "nmap"
local stdnse = require "stdnse"
local string = require "string"
@@ -36,7 +35,7 @@ end
-- @param mac string containing the MAC without delimiters
-- @return packet string containing the raw packet
local function createWOLPacket(mac)
return "\xff\xff\xff\xff\xff\xff" .. string.rep(bin.pack("H", mac), 16)
return "\xff\xff\xff\xff\xff\xff" .. string.rep(stdnse.fromhex(mac), 16)
end
local function fail (err) return stdnse.format_output(false, err) end

View File

@@ -1,7 +1,7 @@
local bin = require "bin"
local ipp = require "ipp"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
description = [[
@@ -62,7 +62,7 @@ action = function(host, port)
[ipp.IPP.PrinterState.IPP_PRINTER_PROCESSING] = "Processing",
[ipp.IPP.PrinterState.IPP_PRINTER_STOPPED] = "Stopped",
}
local pos, state = bin.unpack(">I", printer.state)
local pos, state = string.unpack(">I4", printer.state)
table.insert(output, {
name = printer.name,
("DNS-SD Name: %s"):format(printer.dns_sd_name or ""),

View File

@@ -1,4 +1,3 @@
local bin = require "bin"
local eap = require "eap"
local nmap = require "nmap"
local stdnse = require "stdnse"
@@ -156,7 +155,7 @@ action = function()
-- mac spoofing to avoid to wait too much
local d = string.byte(iface.mac,6)
d = (d + 1) % 256
iface.mac = iface.mac:sub(1,5) .. bin.pack("C",d)
iface.mac = iface.mac:sub(1,5) .. string.pack("B",d)
tried_all = true
for i,v in pairs(identity.auth) do

View File

@@ -1,4 +1,3 @@
local bin = require "bin"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
@@ -50,7 +49,7 @@ action = function(host, port)
return nil
end
local pos, realport = bin.unpack(">I", data)
local pos, realport = string.unpack(">I4", data)
data = string.sub(data, pos)
local nodes = stdnse.output_table()