From 3f7f084cd1e7f8ac93592a501623a7466a46e8ec Mon Sep 17 00:00:00 2001 From: dmiller Date: Sun, 2 Sep 2018 20:51:06 +0000 Subject: [PATCH] Remove bin.lua from a couple more scripts --- scripts/cassandra-brute.nse | 7 +++---- scripts/dns-nsid.nse | 10 ++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/cassandra-brute.nse b/scripts/cassandra-brute.nse index c2f6ebd67..8363c650b 100644 --- a/scripts/cassandra-brute.nse +++ b/scripts/cassandra-brute.nse @@ -1,4 +1,3 @@ -local bin = require "bin" local brute = require "brute" local creds = require "creds" local nmap = require "nmap" @@ -52,7 +51,7 @@ Driver = { local response, magic, size, _ local loginstr = cassandra.loginstr (username, password) - local status, err = self.socket:send(bin.pack(">I",string.len(loginstr))) + local status, err = self.socket:send(string.pack(">I4", #loginstr)) local combo = username..":"..password if ( not(status) ) then local err = brute.Error:new( "couldn't send length:"..combo ) @@ -67,14 +66,14 @@ Driver = { return false, err end - status, response = self.socket:receive_bytes(22) + local status, response = self.socket:receive_bytes(22) if ( not(status) ) then local err = brute.Error:new( "couldn't receive login reply size: "..combo ) err:setAbort( true ) return false, err end - _, size = bin.unpack(">I", response, 1) + local size = string.unpack(">I4", response, 1) magic = string.sub(response,18,22) diff --git a/scripts/dns-nsid.nse b/scripts/dns-nsid.nse index 33957a87d..3a3497931 100644 --- a/scripts/dns-nsid.nse +++ b/scripts/dns-nsid.nse @@ -1,4 +1,3 @@ -local bin = require "bin" local dns = require "dns" local nmap = require "nmap" local shortport = require "shortport" @@ -61,13 +60,16 @@ local function rr_filter(pktRR, label) for _, rec in ipairs(pktRR, label) do if ( rec[label] and 0 < #rec.data ) then if ( dns.types.OPT == rec.dtype ) then - local pos, _, len = bin.unpack(">SS", rec.data) + if #rec.data < 4 then + return false, "Failed to decode NSID" + end + local _, len, pos = string.unpack(">I2 I2", rec.data) if ( len ~= #rec.data - pos + 1 ) then return false, "Failed to decode NSID" end - return true, select(2, bin.unpack("A" .. len, rec.data, pos)) + return true, string.unpack("c" .. len, rec.data, pos) else - return true, select(2, bin.unpack("p", rec.data)) + return true, string.unpack(">s1", rec.data) end end end