mirror of
https://github.com/nmap/nmap.git
synced 2026-01-07 15:09:01 +00:00
Re-indent some scripts. Whitespace-only commit
https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -55,15 +55,15 @@ local tns_type = {CONNECT=1, REFUSE=4, REDIRECT=5, RESEND=11}
|
||||
--
|
||||
local function create_tns_header(packetType, packetLength)
|
||||
|
||||
local request = bin.pack( ">SSCCS",
|
||||
packetLength + 34, -- Packet Length
|
||||
0, -- Packet Checksum
|
||||
tns_type[packetType], -- Packet Type
|
||||
0, -- Reserved Byte
|
||||
0 -- Header Checksum
|
||||
)
|
||||
local request = bin.pack( ">SSCCS",
|
||||
packetLength + 34, -- Packet Length
|
||||
0, -- Packet Checksum
|
||||
tns_type[packetType], -- Packet Type
|
||||
0, -- Reserved Byte
|
||||
0 -- Header Checksum
|
||||
)
|
||||
|
||||
return request
|
||||
return request
|
||||
|
||||
end
|
||||
|
||||
@@ -77,32 +77,32 @@ end
|
||||
--
|
||||
local function create_connect_packet( host_ip, port_no, sid )
|
||||
|
||||
local connect_data = "(DESCRIPTION=(CONNECT_DATA=(SID=" .. sid .. ")"
|
||||
connect_data = connect_data .. "(CID=(PROGRAM=)(HOST=__jdbc__)(USER=)))"
|
||||
connect_data = connect_data .. "(ADDRESS=(PROTOCOL=tcp)(HOST=" .. host_ip .. ")"
|
||||
connect_data = connect_data .. "(PORT=" .. port_no .. ")))"
|
||||
local connect_data = "(DESCRIPTION=(CONNECT_DATA=(SID=" .. sid .. ")"
|
||||
connect_data = connect_data .. "(CID=(PROGRAM=)(HOST=__jdbc__)(USER=)))"
|
||||
connect_data = connect_data .. "(ADDRESS=(PROTOCOL=tcp)(HOST=" .. host_ip .. ")"
|
||||
connect_data = connect_data .. "(PORT=" .. port_no .. ")))"
|
||||
|
||||
local data = bin.pack(">SSSSSSSSSSICCA",
|
||||
308, -- Version
|
||||
300, -- Version (Compatibility)
|
||||
0, -- Service Options
|
||||
2048, -- Session Data Unit Size
|
||||
32767, -- Maximum Transmission Data Unit Size
|
||||
20376, -- NT Protocol Characteristics
|
||||
0, -- Line Turnaround Value
|
||||
1, -- Value of 1 in Hardware
|
||||
connect_data:len(), -- Length of connect data
|
||||
34, -- Offset to connect data
|
||||
0, -- Maximum Receivable Connect Data
|
||||
1, -- Connect Flags 0
|
||||
1, -- Connect Flags 1
|
||||
connect_data
|
||||
)
|
||||
local data = bin.pack(">SSSSSSSSSSICCA",
|
||||
308, -- Version
|
||||
300, -- Version (Compatibility)
|
||||
0, -- Service Options
|
||||
2048, -- Session Data Unit Size
|
||||
32767, -- Maximum Transmission Data Unit Size
|
||||
20376, -- NT Protocol Characteristics
|
||||
0, -- Line Turnaround Value
|
||||
1, -- Value of 1 in Hardware
|
||||
connect_data:len(), -- Length of connect data
|
||||
34, -- Offset to connect data
|
||||
0, -- Maximum Receivable Connect Data
|
||||
1, -- Connect Flags 0
|
||||
1, -- Connect Flags 1
|
||||
connect_data
|
||||
)
|
||||
|
||||
|
||||
local header = create_tns_header("CONNECT", connect_data:len() )
|
||||
local header = create_tns_header("CONNECT", connect_data:len() )
|
||||
|
||||
return header .. data
|
||||
return header .. data
|
||||
|
||||
end
|
||||
|
||||
@@ -113,61 +113,61 @@ end
|
||||
--
|
||||
local function process_tns_packet( packet )
|
||||
|
||||
local tnspacket = {}
|
||||
local tnspacket = {}
|
||||
|
||||
-- just pull out the bare minimum to be able to match
|
||||
local _
|
||||
_, tnspacket.Length, tnspacket.Checksum, tnspacket.Type = bin.unpack(">SSC", packet)
|
||||
-- just pull out the bare minimum to be able to match
|
||||
local _
|
||||
_, tnspacket.Length, tnspacket.Checksum, tnspacket.Type = bin.unpack(">SSC", packet)
|
||||
|
||||
return tnspacket
|
||||
return tnspacket
|
||||
|
||||
end
|
||||
|
||||
action = function(host, port)
|
||||
|
||||
local found_sids = {}
|
||||
local socket = nmap.new_socket()
|
||||
local catch = function() socket:close() end
|
||||
local try = nmap.new_try(catch)
|
||||
local request, response, tns_packet
|
||||
local sidfile
|
||||
local found_sids = {}
|
||||
local socket = nmap.new_socket()
|
||||
local catch = function() socket:close() end
|
||||
local try = nmap.new_try(catch)
|
||||
local request, response, tns_packet
|
||||
local sidfile
|
||||
|
||||
socket:set_timeout(5000)
|
||||
socket:set_timeout(5000)
|
||||
|
||||
-- open the sid file specified by the user or fallback to the default oracle-sids file
|
||||
local sidfilename = nmap.registry.args.oraclesids or nmap.fetchfile("nselib/data/oracle-sids")
|
||||
-- open the sid file specified by the user or fallback to the default oracle-sids file
|
||||
local sidfilename = nmap.registry.args.oraclesids or nmap.fetchfile("nselib/data/oracle-sids")
|
||||
|
||||
sidfile = io.open(sidfilename)
|
||||
sidfile = io.open(sidfilename)
|
||||
|
||||
if not sidfile then
|
||||
return
|
||||
end
|
||||
if not sidfile then
|
||||
return
|
||||
end
|
||||
|
||||
-- read sids line-by-line from the sidfile
|
||||
for sid in sidfile:lines() do
|
||||
-- read sids line-by-line from the sidfile
|
||||
for sid in sidfile:lines() do
|
||||
|
||||
-- check for comments
|
||||
if not sid:match("#!comment:") then
|
||||
-- check for comments
|
||||
if not sid:match("#!comment:") then
|
||||
|
||||
try(socket:connect(host, port))
|
||||
request = create_connect_packet( host.ip, port.number, sid )
|
||||
try(socket:send(request))
|
||||
response = try(socket:receive_bytes(1))
|
||||
tns_packet = process_tns_packet(response)
|
||||
try(socket:connect(host, port))
|
||||
request = create_connect_packet( host.ip, port.number, sid )
|
||||
try(socket:send(request))
|
||||
response = try(socket:receive_bytes(1))
|
||||
tns_packet = process_tns_packet(response)
|
||||
|
||||
-- If we get anything other than REFUSE consider it as a valid SID
|
||||
if tns_packet.Type ~= tns_type.REFUSE then
|
||||
table.insert(found_sids, sid)
|
||||
end
|
||||
-- If we get anything other than REFUSE consider it as a valid SID
|
||||
if tns_packet.Type ~= tns_type.REFUSE then
|
||||
table.insert(found_sids, sid)
|
||||
end
|
||||
|
||||
try(socket:close())
|
||||
try(socket:close())
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
sidfile:close()
|
||||
sidfile:close()
|
||||
|
||||
return stdnse.format_output(true, found_sids)
|
||||
return stdnse.format_output(true, found_sids)
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user