1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41: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 coroutine = require "coroutine"
local dhcp = require "dhcp" local dhcp = require "dhcp"
local ipOps = require "ipOps" 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 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 request_type = dhcp.request_types["DHCPDISCOVER"]
local ip_address = ipOps.ip_to_str("0.0.0.0") 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 ipOps = require "ipOps"
local srvloc = require "srvloc" local srvloc = require "srvloc"
local stdnse = require "stdnse" local stdnse = require "stdnse"
@@ -55,8 +54,7 @@ function action()
for _, attr in ipairs(attribs) do for _, attr in ipairs(attribs) do
local addr = attr:match("^%d*%-%d*%-%d*%-(........)") local addr = attr:match("^%d*%-%d*%-%d*%-(........)")
if ( addr ) then if ( addr ) then
local pos, dw_addr = bin.unpack( ">I", bin.pack("H", addr) ) local ip = ipOps.str_to_ip(stdnse.fromhex(addr))
local ip = ipOps.fromdword(dw_addr)
if ( not(ips[ip]) ) then if ( not(ips[ip]) ) then
table.insert(addrs, ip) table.insert(addrs, ip)

View File

@@ -1,4 +1,3 @@
local bin = require "bin"
local nmap = require "nmap" local nmap = require "nmap"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local string = require "string" local string = require "string"
@@ -36,7 +35,7 @@ end
-- @param mac string containing the MAC without delimiters -- @param mac string containing the MAC without delimiters
-- @return packet string containing the raw packet -- @return packet string containing the raw packet
local function createWOLPacket(mac) 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 end
local function fail (err) return stdnse.format_output(false, err) 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 ipp = require "ipp"
local shortport = require "shortport" local shortport = require "shortport"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local string = require "string"
local table = require "table" local table = require "table"
description = [[ description = [[
@@ -62,7 +62,7 @@ action = function(host, port)
[ipp.IPP.PrinterState.IPP_PRINTER_PROCESSING] = "Processing", [ipp.IPP.PrinterState.IPP_PRINTER_PROCESSING] = "Processing",
[ipp.IPP.PrinterState.IPP_PRINTER_STOPPED] = "Stopped", [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, { table.insert(output, {
name = printer.name, name = printer.name,
("DNS-SD Name: %s"):format(printer.dns_sd_name or ""), ("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 eap = require "eap"
local nmap = require "nmap" local nmap = require "nmap"
local stdnse = require "stdnse" local stdnse = require "stdnse"
@@ -156,7 +155,7 @@ action = function()
-- mac spoofing to avoid to wait too much -- mac spoofing to avoid to wait too much
local d = string.byte(iface.mac,6) local d = string.byte(iface.mac,6)
d = (d + 1) % 256 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 tried_all = true
for i,v in pairs(identity.auth) do for i,v in pairs(identity.auth) do

View File

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