From 17e56e82719e9aaca993cd502763d6f1ea935335 Mon Sep 17 00:00:00 2001 From: patrik Date: Tue, 14 Aug 2012 18:47:46 +0000 Subject: [PATCH] nse_check_globals cleanup --- nselib/jdwp.lua | 9 +++++---- scripts/jdwp-exec.nse | 5 +++-- scripts/jdwp-info.nse | 5 +++-- scripts/jdwp-inject.nse | 5 +++-- scripts/mrinfo.nse | 3 ++- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/nselib/jdwp.lua b/nselib/jdwp.lua index 7a32904a0..b7af4d86a 100644 --- a/nselib/jdwp.lua +++ b/nselib/jdwp.lua @@ -38,6 +38,7 @@ local stdnse = require "stdnse" local string = require "string" local bin = require "bin" local table = require "table" +local nmap = require "nmap" _ENV = stdnse.module("jdwp", stdnse.seeall) @@ -615,6 +616,7 @@ function newClassInstance(socket,id,classID,threadID,methodID,numberOfArguments, -- parse data stdnse.print_debug("newClassInstance data: %s",stdnse.tohex(data)) local pos, tag = bin.unpack(">C",data) + local objectID pos, objectID = bin.unpack(">L",data,pos) return true,objectID end @@ -896,9 +898,8 @@ end -- @param methodName Name of the method. -- @param skipFirst Skip first found method. function findMethod(socket,class,methodName,skipFirst) - local methods local methodID - status, methods = getMethodsWithGeneric(socket,0,class) + local status, methods = getMethodsWithGeneric(socket,0,class) if not status then return false end @@ -1023,7 +1024,7 @@ function injectClass(socket,class_bytes) end -- to trigger the singlestep event, VM must be resumed stdnse.print_debug("Resuming VM and waiting for single step event from main thread...") - status, _ = resumeVM(socket,0) + local status, _ = resumeVM(socket,0) -- clear singlestep since we need to run our code in this thread and we don't want it to stop after each instruction clearThreadSinglestep(socket,0,eventID) stdnse.print_debug("Cleared singlesteping from main thread.") @@ -1083,7 +1084,7 @@ function injectClass(socket,class_bytes) if not status then return false, injectedClassInstance end - injected_class = { + local injected_class = { id = injectedClassID, instance = injectedClassInstance, thread = main_thread diff --git a/scripts/jdwp-exec.nse b/scripts/jdwp-exec.nse index 4ec87f2ce..31c395224 100644 --- a/scripts/jdwp-exec.nse +++ b/scripts/jdwp-exec.nse @@ -1,3 +1,5 @@ +local bin = require "bin" +local io = require "io" local jdwp = require "jdwp" local stdnse = require "stdnse" local nmap = require "nmap" @@ -78,8 +80,7 @@ action = function(host, port) local result status, result = jdwp.invokeObjectMethod(socket,0,injectedClass.instance,injectedClass.thread,injectedClass.id,runMethodID,1,runArgs) -- get the result string - local stringID - _,_,stringID = bin.unpack(">CL",result) + local _,_,stringID = bin.unpack(">CL",result) status,result = jdwp.readString(socket,0,stringID) return stdnse.format_output(true,result) end diff --git a/scripts/jdwp-info.nse b/scripts/jdwp-info.nse index adc9a0909..aac2187b1 100644 --- a/scripts/jdwp-info.nse +++ b/scripts/jdwp-info.nse @@ -1,3 +1,5 @@ +local bin = require "bin" +local io = require "io" local jdwp = require "jdwp" local stdnse = require "stdnse" local nmap = require "nmap" @@ -78,8 +80,7 @@ action = function(host, port) local result status, result = jdwp.invokeObjectMethod(socket,0,injectedClass.instance,injectedClass.thread,injectedClass.id,runMethodID,0,nil) -- get the result string - local stringID - _,_,stringID = bin.unpack(">CL",result) + local _,_,stringID = bin.unpack(">CL",result) status,result = jdwp.readString(socket,0,stringID) -- parse results return stdnse.format_output(true,result) diff --git a/scripts/jdwp-inject.nse b/scripts/jdwp-inject.nse index b149896e4..393527ef9 100644 --- a/scripts/jdwp-inject.nse +++ b/scripts/jdwp-inject.nse @@ -1,3 +1,5 @@ +local bin = require "bin" +local io = require "io" local jdwp = require "jdwp" local stdnse = require "stdnse" local nmap = require "nmap" @@ -70,8 +72,7 @@ action = function(host, port) local result status, result = jdwp.invokeObjectMethod(socket,0,injectedClass.instance,injectedClass.thread,injectedClass.id,runMethodID,0,nil) -- get the result string - local stringID - _,_,stringID = bin.unpack(">CL",result) + local _,_,stringID = bin.unpack(">CL",result) status,result = jdwp.readString(socket,0,stringID) -- parse results return stdnse.format_output(true,result) diff --git a/scripts/mrinfo.nse b/scripts/mrinfo.nse index 12522a2f4..77917cbf1 100644 --- a/scripts/mrinfo.nse +++ b/scripts/mrinfo.nse @@ -3,6 +3,7 @@ local packet = require "packet" local ipOps = require "ipOps" local bin = require "bin" local stdnse = require "stdnse" +local string = require "string" local target = require "target" local table = require "table" @@ -136,7 +137,7 @@ local mrinfoListen = function(interface, timeout, responses) local condvar = nmap.condvar(responses) local start = nmap.clock_ms() local listener = nmap.new_socket() - local p, mrinfo_raw, status, l3data, response + local p, mrinfo_raw, status, l3data, response, _ -- IGMP packets that are sent to our host local filter = 'ip proto 2 and dst host ' .. interface.address