From 0d18bcdbc243d386a9602b3bd4de0ece7676ffa9 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 29 Aug 2018 03:06:40 +0000 Subject: [PATCH] Remove bin.lua calls from some scripts and libraries --- nselib/http.lua | 23 +++++++++++------------ nselib/multicast.lua | 16 ++++++++-------- nselib/rsync.lua | 4 ++-- nselib/wsdd.lua | 3 +-- scripts/broadcast-eigrp-discovery.nse | 3 +-- scripts/broadcast-listener.nse | 1 + scripts/deluge-rpc-brute.nse | 24 ++++++++++++++---------- scripts/eppc-enum-processes.nse | 5 ++++- scripts/jdwp-info.nse | 4 ++-- scripts/jdwp-inject.nse | 3 +-- scripts/maxdb-info.nse | 4 ++-- scripts/murmur-version.nse | 6 ++---- scripts/mysql-enum.nse | 3 +-- scripts/smb-vuln-ms10-054.nse | 4 ++-- scripts/snmp-win32-software.nse | 16 ++++++++-------- scripts/teamspeak2-version.nse | 3 +-- scripts/telnet-ntlm-info.nse | 10 ++++------ 17 files changed, 65 insertions(+), 67 deletions(-) diff --git a/nselib/http.lua b/nselib/http.lua index af6130b39..ed807659e 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -112,7 +112,6 @@ local base64 = require "base64" -local bin = require "bin" local comm = require "comm" local coroutine = require "coroutine" local nmap = require "nmap" @@ -1331,9 +1330,9 @@ function generic_request(host, port, method, path, options) local auth_blob = "NTLMSSP\x00" .. -- NTLM signature "\x01\x00\x00\x00" .. -- NTLM Type 1 message - bin.pack(", flags, and OS Version structure are all present. - auth_blob = bin.pack("BBBB I2 BB", packet.IPPROTO_ICMPV6, -- next header - "\x00" .. -- length not including first 8 octets - "\x05" .. -- type is router alert - "\x02" .. -- length 2 bytes - "\x00\x00" .. -- router alert MLD - "\x01" .. -- padding type PadN - "\x00" -- padding length 0 + 0x00, -- length not including first 8 octets + 0x05, -- type is router alert + 0x02, -- length 2 bytes + 0x00, -- router alert MLD + 0x01, -- padding type PadN + 0x00 -- padding length 0 ) probe.ip6_nhdr = packet.IPPROTO_HOPOPTS probe:build_ipv6_packet() diff --git a/nselib/rsync.lua b/nselib/rsync.lua index 6bd84fda3..cc6fa19b0 100644 --- a/nselib/rsync.lua +++ b/nselib/rsync.lua @@ -4,10 +4,10 @@ -- @author Patrik Karlsson local base64 = require "base64" -local bin = require "bin" local match = require "match" local nmap = require "nmap" local stdnse = require "stdnse" +local string = require "string" local table = require "table" local openssl = stdnse.silent_require "openssl" _ENV = stdnse.module("rsync", stdnse.seeall) @@ -157,7 +157,7 @@ Helper = { return false, data end - local pos, len = bin.unpack("CL",result) + local stringID = string.unpack(">x I8",result) status,result = jdwp.readString(socket,0,stringID) -- parse results return stdnse.format_output(status,result) diff --git a/scripts/jdwp-inject.nse b/scripts/jdwp-inject.nse index 36ac0ed58..9628a50fa 100644 --- a/scripts/jdwp-inject.nse +++ b/scripts/jdwp-inject.nse @@ -1,4 +1,3 @@ -local bin = require "bin" local io = require "io" local jdwp = require "jdwp" local stdnse = require "stdnse" @@ -80,7 +79,7 @@ action = function(host, port) return stdnse.format_output(false, result) end -- get the result string - local _,_,stringID = bin.unpack(">CL",result) + local stringID = string.unpack(">x I8",result) status,result = jdwp.readString(socket,0,stringID) -- parse results return stdnse.format_output(status,result) diff --git a/scripts/maxdb-info.nse b/scripts/maxdb-info.nse index 555865747..ab6832b7f 100644 --- a/scripts/maxdb-info.nse +++ b/scripts/maxdb-info.nse @@ -1,7 +1,7 @@ -local bin = require "bin" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local string = require "string" local tab = require "tab" local table = require "table" @@ -55,7 +55,7 @@ local function exchPacket(socket, packet) stdnse.debug2("Failed to read packet from server") return false, "Failed to read packet from server" end - local pos, len = bin.unpack("CCCLIII", result, 2) + r.v_a, r.v_b, r.v_c, r.users, r.maxusers, r.bandwidth = + string.unpack(">BBB xxxxxxxx I4I4I4", result, 2) end mutex("done") diff --git a/scripts/mysql-enum.nse b/scripts/mysql-enum.nse index 7e73b1913..1fad76249 100644 --- a/scripts/mysql-enum.nse +++ b/scripts/mysql-enum.nse @@ -1,4 +1,3 @@ -local bin = require "bin" local brute = require "brute" local creds = require "creds" local mysql = require "mysql" @@ -80,7 +79,7 @@ Driver = { stdnse.debug1( "Trying %s ...", pass) local auth_string = stdnse.fromhex("0000018d00000000") .. pass .. stdnse.fromhex("00504e5f5155454d4500"); -- old authentication method local err - status, err = self.socket:send(bin.pack("c",string.len(auth_string)-3) .. auth_string) --send initial auth + status, err = self.socket:send(string.pack("b",#auth_string-3) .. auth_string) --send initial auth status, response = self.socket:receive_bytes(0) if not status then return false,brute.Error:new( "Incorrect username" ) diff --git a/scripts/smb-vuln-ms10-054.nse b/scripts/smb-vuln-ms10-054.nse index dbbfb2686..ebaf09f47 100644 --- a/scripts/smb-vuln-ms10-054.nse +++ b/scripts/smb-vuln-ms10-054.nse @@ -1,7 +1,7 @@ -local bin = require "bin" local smb = require "smb" local vulns = require "vulns" local stdnse = require "stdnse" +local string = require "string" description = [[ Tests whether target machines are vulnerable to the ms10-054 SMB remote memory @@ -66,7 +66,7 @@ local function send_transaction2(smbstate, sub_command, function_parameters) end -- Parameters are 0x20 bytes long. - parameters = bin.pack("SCCCCC", install_date ) } + local install_date_tab = { string.unpack( ">I2 BBBBB", install_date ) } setmetatable(install_date_tab, date_metatab) local sw_item = { diff --git a/scripts/teamspeak2-version.nse b/scripts/teamspeak2-version.nse index dba5a78b1..0eb4a23a8 100644 --- a/scripts/teamspeak2-version.nse +++ b/scripts/teamspeak2-version.nse @@ -1,7 +1,6 @@ local comm = require "comm" local shortport = require "shortport" local nmap = require "nmap" -local bin = require "bin" local string = require "string" description = [[ @@ -56,7 +55,7 @@ action = function(host, port) if name == "" then port.version.version = "2" else - local _, v_a, v_b, v_c, v_d = bin.unpack("