mirror of
https://github.com/nmap/nmap.git
synced 2026-02-01 02:59:01 +00:00
Refactor some Lua string concatenations.
Using this regular expression, '\(\w*\)\s*=\s*\1\s*\.\.', found and
replaced many string concatenation-reassignments. These can cause
performance issues, since a new string gets allocated for each
reassignment. In many cases, the replacement is simply a single string,
wrapped across lines with the '\z' escape, which consumes a newline and
whitespace following it. In other cases, a table is used to hold the
substrings until the final string is built with a single table.concat
operation (same technique used in stdnse.strbuf).
Also, some string-building loops of this form:
s = ""
for i = 1, 100, 1 do
s = s .. "\0"
end
were replaced with this much faster and cleaner version:
s = string.rep("\0", 100)
This commit is contained in:
@@ -81,11 +81,11 @@ end
|
||||
--
|
||||
function request_server_farm_data( host, port )
|
||||
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
|
||||
xmldata = xmldata .. "<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n"
|
||||
xmldata = xmldata .. "<NFuseProtocol version=\"1.1\">"
|
||||
xmldata = xmldata .. "<RequestServerFarmData></RequestServerFarmData>"
|
||||
xmldata = xmldata .. "</NFuseProtocol>\r\n"
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n\z
|
||||
<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n\z
|
||||
<NFuseProtocol version=\"1.1\">\z
|
||||
<RequestServerFarmData></RequestServerFarmData>\z
|
||||
</NFuseProtocol>\r\n"
|
||||
|
||||
return send_citrix_xml_request(host, port, xmldata)
|
||||
end
|
||||
@@ -127,20 +127,24 @@ function request_appdata(host, port, params)
|
||||
local client_type = params['ClientType'] or "ica30"
|
||||
local desired_details = params['DesiredDetails'] or nil
|
||||
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
|
||||
xmldata = xmldata .. "<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n"
|
||||
xmldata = xmldata .. "<NFuseProtocol version=\"5.0\">"
|
||||
xmldata = xmldata .. "<RequestAppData>"
|
||||
xmldata = xmldata .. "<Scope traverse=\"" .. scope .. "\" />"
|
||||
xmldata = xmldata .. "<ServerType>" .. server_type .. "</ServerType>"
|
||||
xmldata = xmldata .. "<ClientType>" .. client_type .. "</ClientType>"
|
||||
local xmldata = {
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>\r\n\z
|
||||
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">\r\n\z
|
||||
<NFuseProtocol version="5.0"><RequestAppData><Scope traverse="',
|
||||
scope,
|
||||
'" /><ServerType>',
|
||||
server_type,
|
||||
"</ServerType><ClientType>",
|
||||
client_type,
|
||||
"</ClientType>"
|
||||
}
|
||||
|
||||
if desired_details then
|
||||
if type(desired_details) == "string" then
|
||||
xmldata = xmldata .. "<DesiredDetails>" .. desired_details .. "</DesiredDetails>"
|
||||
xmldata[#xmldata+1] = "<DesiredDetails>" .. desired_details .. "</DesiredDetails>"
|
||||
elseif type(desired_details) == "table" then
|
||||
for _, v in ipairs(desired_details) do
|
||||
xmldata = xmldata .. "<DesiredDetails>" .. v .. "</DesiredDetails>"
|
||||
xmldata[#xmldata+1] = "<DesiredDetails>" .. v .. "</DesiredDetails>"
|
||||
end
|
||||
else
|
||||
assert(desired_details)
|
||||
@@ -148,10 +152,9 @@ function request_appdata(host, port, params)
|
||||
|
||||
end
|
||||
|
||||
xmldata = xmldata .. "</RequestAppData>"
|
||||
xmldata = xmldata .. "</NFuseProtocol>\r\n"
|
||||
xmldata[#xmldata+1] = "</RequestAppData></NFuseProtocol>\r\n"
|
||||
|
||||
return send_citrix_xml_request(host, port, xmldata)
|
||||
return send_citrix_xml_request(host, port, table.concat(xmldata))
|
||||
end
|
||||
|
||||
|
||||
@@ -270,25 +273,23 @@ end
|
||||
--
|
||||
function request_address(host, port, flags, appname)
|
||||
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
|
||||
xmldata = xmldata .. "<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n"
|
||||
xmldata = xmldata .. "<NFuseProtocol version=\"4.1\">"
|
||||
xmldata = xmldata .. "<RequestAddress>"
|
||||
local xmldata = {
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>\r\n\z
|
||||
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">\r\n\z
|
||||
<NFuseProtocol version="4.1"><RequestAddress>'
|
||||
}
|
||||
|
||||
if flags then
|
||||
xmldata = xmldata .. "<Flags>" .. flags .. "</Flags>"
|
||||
xmldata[#xmldata+1] = "<Flags>" .. flags .. "</Flags>"
|
||||
end
|
||||
|
||||
if appname then
|
||||
xmldata = xmldata .. "<Name>"
|
||||
xmldata = xmldata .. "<AppName>" .. appname .. "</AppName>"
|
||||
xmldata = xmldata .. "</Name>"
|
||||
xmldata[#xmldata+1] = "<Name><AppName>" .. appname .. "</AppName></Name>"
|
||||
end
|
||||
|
||||
xmldata = xmldata .. "</RequestAddress>"
|
||||
xmldata = xmldata .. "</NFuseProtocol>\r\n"
|
||||
xmldata[#xmldata+1] = "</RequestAddress></NFuseProtocol>\r\n"
|
||||
|
||||
return send_citrix_xml_request(host, port, xmldata)
|
||||
return send_citrix_xml_request(host, port, table.concat(xmldata))
|
||||
end
|
||||
|
||||
--- Request information about the Citrix protocol
|
||||
@@ -308,23 +309,23 @@ function request_server_data(host, port, params)
|
||||
local server_type = params.ServerType or {"all"}
|
||||
local client_type = params.ClientType or {"all"}
|
||||
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
|
||||
xmldata = xmldata .. "<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n"
|
||||
xmldata = xmldata .. "<NFuseProtocol version=\"1.1\">"
|
||||
xmldata = xmldata .. "<RequestServerData>"
|
||||
local xmldata = {
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>\r\n\z
|
||||
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">\r\n\z
|
||||
<NFuseProtocol version="1.1"><RequestServerData>'
|
||||
}
|
||||
|
||||
for _, srvtype in pairs(server_type) do
|
||||
xmldata = xmldata .. "<ServerType>" .. srvtype .. "</ServerType>"
|
||||
xmldata[#xmldata+1] = "<ServerType>" .. srvtype .. "</ServerType>"
|
||||
end
|
||||
|
||||
for _, clitype in pairs(client_type) do
|
||||
xmldata = xmldata .. "<ClientType>" .. clitype .. "</ClientType>"
|
||||
xmldata[#xmldata+1] = "<ClientType>" .. clitype .. "</ClientType>"
|
||||
end
|
||||
|
||||
xmldata = xmldata .. "</RequestServerData>"
|
||||
xmldata = xmldata .. "</NFuseProtocol>\r\n"
|
||||
xmldata[#xmldata+1] = "</RequestServerData></NFuseProtocol>\r\n"
|
||||
|
||||
return send_citrix_xml_request(host, port, xmldata)
|
||||
return send_citrix_xml_request(host, port, table.concat(xmldata))
|
||||
end
|
||||
|
||||
--- Parses the response from the request_server_data request
|
||||
@@ -359,20 +360,21 @@ function request_protocol_info( host, port, params )
|
||||
|
||||
local params = params or {}
|
||||
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
|
||||
xmldata = xmldata .. "<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n"
|
||||
xmldata = xmldata .. "<NFuseProtocol version=\"1.1\">"
|
||||
xmldata = xmldata .. "<RequestProtocolInfo>"
|
||||
local xmldata = {
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>\r\n\z
|
||||
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">\r\n\z
|
||||
<NFuseProtocol version="1.1"><RequestProtocolInfo>'
|
||||
}
|
||||
|
||||
if params['ServerAddress'] then
|
||||
xmldata = xmldata .. "<ServerAddress addresstype=\"" .. params['ServerAddress']['attr']['addresstype'] .. "\">"
|
||||
xmldata = xmldata .. params['ServerAddress'] .. "</ServerAddress>"
|
||||
xmldata[#xmldata+1] = ('<ServerAddress addresstype="' ..
|
||||
params['ServerAddress']['attr']['addresstype'] .. '">' ..
|
||||
params['ServerAddress'] .. "</ServerAddress>")
|
||||
end
|
||||
|
||||
xmldata = xmldata .. "</RequestProtocolInfo>"
|
||||
xmldata = xmldata .. "</NFuseProtocol>\r\n"
|
||||
xmldata[#xmldata+1] = "</RequestProtocolInfo></NFuseProtocol>\r\n"
|
||||
|
||||
return send_citrix_xml_request(host, port, xmldata)
|
||||
return send_citrix_xml_request(host, port, table.concat(xmldata))
|
||||
end
|
||||
|
||||
--- Request capability information
|
||||
@@ -387,12 +389,10 @@ end
|
||||
--
|
||||
function request_capabilities( host, port )
|
||||
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
|
||||
xmldata = xmldata .. "<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n"
|
||||
xmldata = xmldata .. "<NFuseProtocol version=\"1.1\">"
|
||||
xmldata = xmldata .. "<RequestCapabilities>"
|
||||
xmldata = xmldata .. "</RequestCapabilities>"
|
||||
xmldata = xmldata .. "</NFuseProtocol>\r\n"
|
||||
local xmldata = '<?xml version="1.0" encoding="ISO-8859-1"?>\r\n\z
|
||||
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">\r\n\z
|
||||
<NFuseProtocol version="1.1"><RequestCapabilities>\z
|
||||
</RequestCapabilities></NFuseProtocol>\r\n'
|
||||
|
||||
return send_citrix_xml_request(host, port, xmldata)
|
||||
end
|
||||
@@ -431,29 +431,27 @@ function request_validate_credentials(host, port, params )
|
||||
local params = params or {}
|
||||
local credentials = params['Credentials'] or {}
|
||||
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
|
||||
xmldata = xmldata .. "<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n"
|
||||
xmldata = xmldata .. "<NFuseProtocol version=\"5.0\">"
|
||||
xmldata = xmldata .. "<RequestValidateCredentials>"
|
||||
xmldata = xmldata .. "<Credentials>"
|
||||
local xmldata = {
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>\r\n\z
|
||||
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">\r\n\z
|
||||
<NFuseProtocol version="5.0"><RequestValidateCredentials><Credentials>'
|
||||
}
|
||||
|
||||
if credentials['UserName'] then
|
||||
xmldata = xmldata .. "<UserName>" .. credentials['UserName'] .. "</UserName>"
|
||||
xmldata[#xmldata+1] = "<UserName>" .. credentials['UserName'] .. "</UserName>"
|
||||
end
|
||||
|
||||
if credentials['Password'] then
|
||||
xmldata = xmldata .. "<Password encoding=\"cleartext\">" .. credentials['Password'] .. "</Password>"
|
||||
xmldata[#xmldata+1] = '<Password encoding="cleartext">' .. credentials['Password'] .. "</Password>"
|
||||
end
|
||||
|
||||
if credentials['Domain'] then
|
||||
xmldata = xmldata .. "<Domain type=\"NT\">" .. credentials['Domain'] .. "</Domain>"
|
||||
xmldata[#xmldata+1] = '<Domain type="NT">' .. credentials['Domain'] .. "</Domain>"
|
||||
end
|
||||
|
||||
xmldata = xmldata .. "</Credentials>"
|
||||
xmldata = xmldata .. "</RequestValidateCredentials>"
|
||||
xmldata = xmldata .. "</NFuseProtocol>\r\n"
|
||||
xmldata[#xmldata+1] = "</Credentials></RequestValidateCredentials></NFuseProtocol>\r\n"
|
||||
|
||||
return send_citrix_xml_request(host, port, xmldata)
|
||||
return send_citrix_xml_request(host, port, table.concat(xmldata))
|
||||
|
||||
end
|
||||
|
||||
@@ -491,47 +489,45 @@ function request_reconnect_session_data(host, port, params)
|
||||
params.ServerType = params.ServerType or {}
|
||||
params.ClientType = params.ClientType or {}
|
||||
|
||||
local xmldata = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
|
||||
xmldata = xmldata .. "<!DOCTYPE NFuseProtocol SYSTEM \"NFuse.dtd\">\r\n"
|
||||
xmldata = xmldata .. "<NFuseProtocol version=\"5.0\">"
|
||||
xmldata = xmldata .. "<RequestReconnectSessionData>"
|
||||
|
||||
xmldata = xmldata .. "<Credentials>"
|
||||
local xmldata = {
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>\r\n\z
|
||||
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">\r\n\z
|
||||
<NFuseProtocol version="5.0"><RequestReconnectSessionData><Credentials>'
|
||||
}
|
||||
|
||||
if Credentials.UserName then
|
||||
xmldata = xmldata .. "<UserName>" .. Credentials.UserName .. "</UserName>"
|
||||
xmldata[#xmldata+1] = "<UserName>" .. Credentials.UserName .. "</UserName>"
|
||||
end
|
||||
|
||||
if Credentials.Password then
|
||||
xmldata = xmldata .. "<Password encoding=\"cleartext\">" .. Credentials.Password .. "</Password>"
|
||||
xmldata[#xmldata+1] = '<Password encoding="cleartext">' .. Credentials.Password .. "</Password>"
|
||||
end
|
||||
|
||||
if Credentials.Domain then
|
||||
xmldata = xmldata .. "<Domain type=\"NT\">" .. Credentials.Domain .. "</Domain>"
|
||||
xmldata[#xmldata+1] = '<Domain type="NT">' .. Credentials.Domain .. "</Domain>"
|
||||
end
|
||||
|
||||
xmldata = xmldata .. "</Credentials>"
|
||||
xmldata[#xmldata+1] = "</Credentials>"
|
||||
|
||||
if params.ClientName then
|
||||
xmldata = xmldata .. "<ClientName>" .. params.ClientName .. "</ClientName>"
|
||||
xmldata[#xmldata+1] = "<ClientName>" .. params.ClientName .. "</ClientName>"
|
||||
end
|
||||
|
||||
if params.DeviceId then
|
||||
xmldata = xmldata .. "<DeviceId>" .. params.DeviceId .. "</DeviceId>"
|
||||
xmldata[#xmldata+1] = "<DeviceId>" .. params.DeviceId .. "</DeviceId>"
|
||||
end
|
||||
|
||||
for _, srvtype in pairs(params.ServerType) do
|
||||
xmldata = xmldata .. "<ServerType>" .. srvtype .. "</ServerType>"
|
||||
xmldata[#xmldata+1] = "<ServerType>" .. srvtype .. "</ServerType>"
|
||||
end
|
||||
|
||||
for _, clitype in pairs(params.ClientType) do
|
||||
xmldata = xmldata .. "<ClientType>" .. clitype .. "</ClientType>"
|
||||
xmldata[#xmldata+1] = "<ClientType>" .. clitype .. "</ClientType>"
|
||||
end
|
||||
|
||||
xmldata = xmldata .. "</RequestReconnectSessionData>"
|
||||
xmldata = xmldata .. "</NFuseProtocol>\r\n"
|
||||
xmldata[#xmldata+1] = "</RequestReconnectSessionData></NFuseProtocol>\r\n"
|
||||
|
||||
return send_citrix_xml_request(host, port, xmldata)
|
||||
return send_citrix_xml_request(host, port, table.concat(xmldata))
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -721,23 +721,23 @@ Comm = {
|
||||
}
|
||||
|
||||
-- EBCDIC/ASCII Conversion tables
|
||||
a2e_hex = "00010203372D2E2F1605250B0C0D0E0F101112133C3D322618193F271C1D1E1F"
|
||||
a2e_hex = a2e_hex .. "405A7F7B5B6C507D4D5D5C4E6B604B61F0F1F2F3F4F5F6F7F8F97A5E4C7E6E6F"
|
||||
a2e_hex = a2e_hex .. "7CC1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7D8D9E2E3E4E5E6E7E8E9ADE0BD5F6D"
|
||||
a2e_hex = a2e_hex .. "79818283848586878889919293949596979899A2A3A4A5A6A7A8A9C04FD0A107"
|
||||
a2e_hex = a2e_hex .. "202122232415061728292A2B2C090A1B30311A333435360838393A3B04143EE1"
|
||||
a2e_hex = a2e_hex .. "4142434445464748495152535455565758596263646566676869707172737475"
|
||||
a2e_hex = a2e_hex .. "767778808A8B8C8D8E8F909A9B9C9D9E9FA0AAABAC4AAEAFB0B1B2B3B4B5B6B7"
|
||||
a2e_hex = a2e_hex .. "B8B9BABBBC6ABEBFCACBCCCDCECFDADBDCDDDEDFEAEBECEDEEEFFAFBFCFDFEFF"
|
||||
a2e_hex = "00010203372D2E2F1605250B0C0D0E0F101112133C3D322618193F271C1D1E1F\z
|
||||
405A7F7B5B6C507D4D5D5C4E6B604B61F0F1F2F3F4F5F6F7F8F97A5E4C7E6E6F\z
|
||||
7CC1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7D8D9E2E3E4E5E6E7E8E9ADE0BD5F6D\z
|
||||
79818283848586878889919293949596979899A2A3A4A5A6A7A8A9C04FD0A107\z
|
||||
202122232415061728292A2B2C090A1B30311A333435360838393A3B04143EE1\z
|
||||
4142434445464748495152535455565758596263646566676869707172737475\z
|
||||
767778808A8B8C8D8E8F909A9B9C9D9E9FA0AAABAC4AAEAFB0B1B2B3B4B5B6B7\z
|
||||
B8B9BABBBC6ABEBFCACBCCCDCECFDADBDCDDDEDFEAEBECEDEEEFFAFBFCFDFEFF"
|
||||
|
||||
e2a_hex = "000102039C09867F978D8E0B0C0D0E0F101112139D8508871819928F1C1D1E1F"
|
||||
e2a_hex = e2a_hex .. "80818283840A171B88898A8B8C050607909116939495960498999A9B14159E1A"
|
||||
e2a_hex = e2a_hex .. "20A0A1A2A3A4A5A6A7A8D52E3C282B7C26A9AAABACADAEAFB0B121242A293B5E"
|
||||
e2a_hex = e2a_hex .. "2D2FB2B3B4B5B6B7B8B9E52C255F3E3FBABBBCBDBEBFC0C1C2603A2340273D22"
|
||||
e2a_hex = e2a_hex .. "C3616263646566676869C4C5C6C7C8C9CA6A6B6C6D6E6F707172CBCCCDCECFD0"
|
||||
e2a_hex = e2a_hex .. "D17E737475767778797AD2D3D45BD6D7D8D9DADBDCDDDEDFE0E1E2E3E45DE6E7"
|
||||
e2a_hex = e2a_hex .. "7B414243444546474849E8E9EAEBECED7D4A4B4C4D4E4F505152EEEFF0F1F2F3"
|
||||
e2a_hex = e2a_hex .. "5C9F535455565758595AF4F5F6F7F8F930313233343536373839FAFBFCFDFEFF"
|
||||
e2a_hex = "000102039C09867F978D8E0B0C0D0E0F101112139D8508871819928F1C1D1E1F\z
|
||||
80818283840A171B88898A8B8C050607909116939495960498999A9B14159E1A\z
|
||||
20A0A1A2A3A4A5A6A7A8D52E3C282B7C26A9AAABACADAEAFB0B121242A293B5E\z
|
||||
2D2FB2B3B4B5B6B7B8B9E52C255F3E3FBABBBCBDBEBFC0C1C2603A2340273D22\z
|
||||
C3616263646566676869C4C5C6C7C8C9CA6A6B6C6D6E6F707172CBCCCDCECFD0\z
|
||||
D17E737475767778797AD2D3D45BD6D7D8D9DADBDCDDDEDFE0E1E2E3E45DE6E7\z
|
||||
7B414243444546474849E8E9EAEBECED7D4A4B4C4D4E4F505152EEEFF0F1F2F3\z
|
||||
5C9F535455565758595AF4F5F6F7F8F930313233343536373839FAFBFCFDFEFF"
|
||||
|
||||
-- Creates the lookup tables needed for conversion
|
||||
a2e_tbl = bin.pack("H", a2e_hex)
|
||||
|
||||
@@ -448,33 +448,33 @@ JavaClass = {
|
||||
end,
|
||||
|
||||
__tostring = function( self )
|
||||
local data
|
||||
local data = {}
|
||||
if self.name ~=nil then
|
||||
data = ("%s "):format(self.name)
|
||||
data[#data+1] = ("%s "):format(self.name)
|
||||
else
|
||||
data = "???"
|
||||
data[#data+1] = "???"
|
||||
end
|
||||
if self.superClass~=nil then
|
||||
data = data .. " extends ".. tostring( self.superClass)
|
||||
data[#data+1] = " extends ".. tostring( self.superClass)
|
||||
end
|
||||
if self.ifaces ~= nil then
|
||||
data = data .. " implements " .. self.ifaces
|
||||
data[#data+1] = " implements " .. self.ifaces
|
||||
end
|
||||
if self.fields ~=nil then
|
||||
for i=1, #self.fields do
|
||||
if i == 1 then
|
||||
data = data .. "["
|
||||
data[#data+1] = "["
|
||||
end
|
||||
data = data .. tostring(self.fields[i])
|
||||
data[#data+1] = tostring(self.fields[i])
|
||||
if ( i < #self.fields ) then
|
||||
data = data .. ";"
|
||||
data[#data+1] = ";"
|
||||
else
|
||||
data = data .. "]"
|
||||
data[#data+1] = "]"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
return data
|
||||
return table.concat(data)
|
||||
end,
|
||||
toTable = function(self, customDataFormatter)
|
||||
local data = {self.name}
|
||||
@@ -571,7 +571,8 @@ JavaField = {
|
||||
table.insert(data, self.value)
|
||||
end
|
||||
else
|
||||
data = data .." = " .. tostring(self.value)
|
||||
--TODO: FIXME This is illegal, but I don't know what the intent was:
|
||||
data = data .." = " .. tostring(self.value) --FIXME
|
||||
end
|
||||
end
|
||||
return data
|
||||
@@ -592,13 +593,15 @@ JavaArray = {
|
||||
setLength = function( self, length ) self.length = length end,
|
||||
setValue = function(self, index, object) self.values[index] = object end,
|
||||
__tostring=function(self)
|
||||
local data = ("Array: %s [%d] = {"):format(tostring(self.class), self.length)
|
||||
local data = {
|
||||
("Array: %s [%d] = {"):format(tostring(self.class), self.length)
|
||||
}
|
||||
|
||||
for i=1, #self.values do
|
||||
data = data .. self.values[i]..","
|
||||
data[#data+1] = self.values[i]..","
|
||||
end
|
||||
data = data .."}"
|
||||
return data
|
||||
data[#data+1] = "}"
|
||||
return table.concat(data)
|
||||
end,
|
||||
toTable = function(self)
|
||||
local title = ("Array: %s [%d] = {"):format(tostring(self.class), self.length)
|
||||
|
||||
@@ -325,10 +325,12 @@ Comm = {
|
||||
packet = packet .. bin.pack( "IIII", 0, 0, 0, 0 )
|
||||
elseif auth.type == Portmap.AuthType.UNIX then
|
||||
packet = packet .. Util.marshall_int32(auth.type)
|
||||
local blob = Util.marshall_int32(nmap.clock()) --time
|
||||
blob = blob .. Util.marshall_vopaque(auth.hostname or 'localhost')
|
||||
blob = blob .. Util.marshall_int32(auth.uid or 0)
|
||||
blob = blob .. Util.marshall_int32(auth.gid or 0)
|
||||
local blob = (
|
||||
Util.marshall_int32(nmap.clock()) --time
|
||||
.. Util.marshall_vopaque(auth.hostname or 'localhost')
|
||||
.. Util.marshall_int32(auth.uid or 0)
|
||||
.. Util.marshall_int32(auth.gid or 0)
|
||||
)
|
||||
if auth.gids then --len prefix gid list
|
||||
blob = blob .. Util.marshall_int32(#auth.gids)
|
||||
for _,gid in ipairs(auth.gids) do
|
||||
@@ -337,8 +339,9 @@ Comm = {
|
||||
else
|
||||
blob = blob .. Util.marshall_int32(0)
|
||||
end
|
||||
packet = packet .. Util.marshall_vopaque(blob)
|
||||
packet = packet .. bin.pack( "II", 0, 0 ) --AUTH_NULL verf
|
||||
packet = (packet .. Util.marshall_vopaque(blob)
|
||||
.. bin.pack( "II", 0, 0 ) --AUTH_NULL verf
|
||||
)
|
||||
else
|
||||
return false, "Comm.CreateHeader: invalid authentication type specified"
|
||||
end
|
||||
@@ -2981,10 +2984,7 @@ Util =
|
||||
-- @param mode number containing the ACL mode
|
||||
-- @return string containing the ACL characters
|
||||
FpermToString = function(mode)
|
||||
local tmpacl, acl = {}, ""
|
||||
for i = 1, 9 do
|
||||
tmpacl[i] = "-"
|
||||
end
|
||||
local tmpacl = { "-", "-", "-", "-", "-", "-", "-", "-", "-" }
|
||||
|
||||
for user,_ in pairs(Util.Fperm) do
|
||||
local t = Util.Fperm[user]
|
||||
@@ -3009,11 +3009,7 @@ Util =
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1,#tmpacl do
|
||||
acl = acl .. tmpacl[i]
|
||||
end
|
||||
|
||||
return acl
|
||||
return table.concat(tmpacl)
|
||||
end,
|
||||
|
||||
--- Converts the NFS file attributes to a string.
|
||||
@@ -3096,11 +3092,7 @@ Util =
|
||||
end,
|
||||
|
||||
marshall_opaque = function(data)
|
||||
local opaque = bin.pack(">A", data)
|
||||
for i = 1, Util.CalcFillBytes(data:len()) do
|
||||
opaque = opaque .. string.char(0x00)
|
||||
end
|
||||
return opaque
|
||||
return bin.pack(">A", data) .. string.rep("\0", Util.CalcFillBytes(data:len()))
|
||||
end,
|
||||
|
||||
unmarshall_opaque = function(len, data, pos)
|
||||
@@ -3108,13 +3100,11 @@ Util =
|
||||
end,
|
||||
|
||||
marshall_vopaque = function(data)
|
||||
local opaque, l
|
||||
l = data:len()
|
||||
opaque = Util.marshall_uint32(l) .. bin.pack(">A", data)
|
||||
for i = 1, Util.CalcFillBytes(l) do
|
||||
opaque = opaque .. string.char(0x00)
|
||||
end
|
||||
return opaque
|
||||
local l = data:len()
|
||||
return (
|
||||
Util.marshall_uint32(l) .. bin.pack(">A", data) ..
|
||||
string.rep("\0", Util.CalcFillBytes(l))
|
||||
)
|
||||
end,
|
||||
|
||||
unmarshall_vopaque = function(len, data, pos)
|
||||
|
||||
@@ -94,14 +94,13 @@ Comm = {
|
||||
--
|
||||
-- @return status true on success, false on failure
|
||||
sendRequest = function( self )
|
||||
local payload = strbuf.new()
|
||||
|
||||
-- for details about the UPnP message format, see http://upnp.org/resources/documents.asp
|
||||
payload = payload .. "M-SEARCH * HTTP/1.1\r\n"
|
||||
payload = payload .. "Host:239.255.255.250:1900\r\n"
|
||||
payload = payload .. "ST:upnp:rootdevice\r\n"
|
||||
payload = payload .. "Man:\"ssdp:discover\"\r\n"
|
||||
payload = payload .. "MX:3\r\n\r\n"
|
||||
local payload = 'M-SEARCH * HTTP/1.1\r\n\z
|
||||
Host:239.255.255.250:1900\r\n\z
|
||||
ST:upnp:rootdevice\r\n\z
|
||||
Man:"ssdp:discover"\r\n\z
|
||||
MX:3\r\n\r\n'
|
||||
|
||||
local status, err
|
||||
|
||||
|
||||
@@ -290,29 +290,27 @@ end
|
||||
-- @return The corresponding path string
|
||||
-----------------------------------------------------------------------------
|
||||
function build_path(parsed, unsafe)
|
||||
local path = ""
|
||||
local path = {}
|
||||
if parsed.is_absolute then path[#path+1] = "/" end
|
||||
local n = #parsed
|
||||
if unsafe then
|
||||
for i = 1, n-1 do
|
||||
path = path .. parsed[i]
|
||||
path = path .. "/"
|
||||
path[#path+1] = parsed[i] .. "/"
|
||||
end
|
||||
if n > 0 then
|
||||
path = path .. parsed[n]
|
||||
if parsed.is_directory then path = path .. "/" end
|
||||
path[#path+1] = parsed[n]
|
||||
if parsed.is_directory then path[#path+1] = "/" end
|
||||
end
|
||||
else
|
||||
for i = 1, n-1 do
|
||||
path = path .. protect_segment(parsed[i])
|
||||
path = path .. "/"
|
||||
path[#path+1] = protect_segment(parsed[i]) .. "/"
|
||||
end
|
||||
if n > 0 then
|
||||
path = path .. protect_segment(parsed[n])
|
||||
if parsed.is_directory then path = path .. "/" end
|
||||
path[#path+1] = protect_segment(parsed[n])
|
||||
if parsed.is_directory then path[#path+1] = "/" end
|
||||
end
|
||||
end
|
||||
if parsed.is_absolute then path = "/" .. path end
|
||||
return path
|
||||
return table.concat(path)
|
||||
end
|
||||
|
||||
---
|
||||
|
||||
@@ -13,6 +13,7 @@ local bin = require "bin"
|
||||
local match = require "match"
|
||||
local nmap = require "nmap"
|
||||
local package = require "package"
|
||||
local string = require "string"
|
||||
local table = require "table"
|
||||
_ENV = stdnse.module("versant", stdnse.seeall)
|
||||
|
||||
@@ -60,22 +61,22 @@ Versant = {
|
||||
ver = ver or Versant.VERSION
|
||||
arg = arg or ""
|
||||
|
||||
local data = bin.pack("H", "000100000000000000020002000000010000000000000000000000000000000000010000")
|
||||
data = data .. cmd .. "\0" .. user .. "\0" .. ver .. "\0"
|
||||
local data = bin.pack("Hzzz",
|
||||
"000100000000000000020002000000010000000000000000000000000000000000010000",
|
||||
cmd,
|
||||
user,
|
||||
ver
|
||||
)
|
||||
-- align to even 4 bytes
|
||||
if ( #data % 4 ~= 0 ) then
|
||||
for i=1, ( 4 - (#data % 4)) do
|
||||
data = data .. "\0"
|
||||
end
|
||||
end
|
||||
data = data .. string.rep("\0", 4 - ((#data % 4) or 0))
|
||||
|
||||
data = data .. bin.pack("H", "0000000b000001000000000000000000")
|
||||
data = data .. ("%s:%d\0"):format(self.host.ip, self.port.number)
|
||||
data = data .. "\0\0\0\0\0\0\0\0\0\0" .. arg
|
||||
data = data .. bin.pack("Hzxxxxxxxxxxz",
|
||||
"0000000b000001000000000000000000",
|
||||
("%s:%d"):format(self.host.ip, self.port.number),
|
||||
arg
|
||||
)
|
||||
|
||||
while ( #data < 2048 ) do
|
||||
data = data .. "\0"
|
||||
end
|
||||
data = data .. string.rep("\0", 2048 - #data)
|
||||
|
||||
local status, err = self.socket:send(data)
|
||||
if ( not(status) ) then
|
||||
@@ -254,12 +255,10 @@ Versant.OBE = {
|
||||
-- <code>lib_path</code> - the library directory
|
||||
-- <code>hostname</code> - the database host name
|
||||
getVODInfo = function(self)
|
||||
local data = bin.pack("H", "1002005d00000000000100000000000d000000000000000000000000")
|
||||
data = data .. "-noprint -i "
|
||||
|
||||
while( #data < 256 ) do
|
||||
data = data .. "\0"
|
||||
end
|
||||
local data = bin.pack("Hz",
|
||||
"1002005d00000000000100000000000d000000000000000000000000", --28
|
||||
"-noprint -i " --12 + 1 (for null)
|
||||
) .. string.rep("\0", 215) -- 256 - (28 + 12 + 1)
|
||||
|
||||
self.socket:send(data)
|
||||
local status, data = self.socket:receive_buf(match.numbytes(256), true)
|
||||
|
||||
Reference in New Issue
Block a user