1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-07 23:19:02 +00:00

Re-indent some scripts. Whitespace-only commit

https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
dmiller
2014-01-31 13:02:29 +00:00
parent 64fb5b3482
commit d36c08dcf5
137 changed files with 3977 additions and 3977 deletions

View File

@@ -37,61 +37,61 @@ license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"exploit","intrusive"}
portrule = function(host, port)
-- JDWP will close the port if there is no valid handshake within 2
-- seconds, Service detection's NULL probe detects it as tcpwrapped.
return port.service == "tcpwrapped"
and port.protocol == "tcp" and port.state == "open"
and not(shortport.port_is_excluded(port.number,port.protocol))
-- JDWP will close the port if there is no valid handshake within 2
-- seconds, Service detection's NULL probe detects it as tcpwrapped.
return port.service == "tcpwrapped"
and port.protocol == "tcp" and port.state == "open"
and not(shortport.port_is_excluded(port.number,port.protocol))
end
action = function(host, port)
stdnse.sleep(5) -- let the remote socket recover from connect() scan
local status,socket = jdwp.connect(host,port) -- initialize the connection
if not status then
stdnse.print_debug("error, %s",socket)
return nil
end
stdnse.sleep(5) -- let the remote socket recover from connect() scan
local status,socket = jdwp.connect(host,port) -- initialize the connection
if not status then
stdnse.print_debug("error, %s",socket)
return nil
end
-- read .class file
local file = io.open(nmap.fetchfile("nselib/data/jdwp-class/JDWPExecCmd.class"), "rb")
local class_bytes = file:read("*all")
-- read .class file
local file = io.open(nmap.fetchfile("nselib/data/jdwp-class/JDWPExecCmd.class"), "rb")
local class_bytes = file:read("*all")
-- inject the class
local injectedClass
status,injectedClass = jdwp.injectClass(socket,class_bytes)
if not status then
stdnse.print_debug(1, "%s: Failed to inject class", SCRIPT_NAME)
return stdnse.format_output(false, "Failed to inject class")
end
-- find injected class method
local runMethodID = jdwp.findMethod(socket,injectedClass.id,"run",false)
-- inject the class
local injectedClass
status,injectedClass = jdwp.injectClass(socket,class_bytes)
if not status then
stdnse.print_debug(1, "%s: Failed to inject class", SCRIPT_NAME)
return stdnse.format_output(false, "Failed to inject class")
end
-- find injected class method
local runMethodID = jdwp.findMethod(socket,injectedClass.id,"run",false)
if runMethodID == nil then
stdnse.print_debug(1, "%s: Couldn't find run method", SCRIPT_NAME)
return stdnse.format_output(false, "Couldn't find run method.")
end
-- set run() method argument
local cmd = stdnse.get_script_args(SCRIPT_NAME .. '.cmd')
if cmd == nil then
return stdnse.format_output(false, "This script requires a cmd argument to be specified.")
end
local cmdID
status,cmdID = jdwp.createString(socket,0,cmd)
if not status then
stdnse.print_debug(1, "%s: Couldn't create string", SCRIPT_NAME)
return stdnse.format_output(false, cmdID)
end
local runArgs = bin.pack(">CL",0x4c,cmdID) -- 0x4c is object type tag
-- invoke run method
local result
status, result = jdwp.invokeObjectMethod(socket,0,injectedClass.instance,injectedClass.thread,injectedClass.id,runMethodID,1,runArgs)
if not status then
stdnse.print_debug(1, "%s: Couldn't invoke run method", SCRIPT_NAME)
return stdnse.format_output(false, result)
end
-- get the result string
local _,_,stringID = bin.unpack(">CL",result)
status,result = jdwp.readString(socket,0,stringID)
return stdnse.format_output(status,result)
if runMethodID == nil then
stdnse.print_debug(1, "%s: Couldn't find run method", SCRIPT_NAME)
return stdnse.format_output(false, "Couldn't find run method.")
end
-- set run() method argument
local cmd = stdnse.get_script_args(SCRIPT_NAME .. '.cmd')
if cmd == nil then
return stdnse.format_output(false, "This script requires a cmd argument to be specified.")
end
local cmdID
status,cmdID = jdwp.createString(socket,0,cmd)
if not status then
stdnse.print_debug(1, "%s: Couldn't create string", SCRIPT_NAME)
return stdnse.format_output(false, cmdID)
end
local runArgs = bin.pack(">CL",0x4c,cmdID) -- 0x4c is object type tag
-- invoke run method
local result
status, result = jdwp.invokeObjectMethod(socket,0,injectedClass.instance,injectedClass.thread,injectedClass.id,runMethodID,1,runArgs)
if not status then
stdnse.print_debug(1, "%s: Couldn't invoke run method", SCRIPT_NAME)
return stdnse.format_output(false, result)
end
-- get the result string
local _,_,stringID = bin.unpack(">CL",result)
status,result = jdwp.readString(socket,0,stringID)
return stdnse.format_output(status,result)
end