mirror of
https://github.com/nmap/nmap.git
synced 2025-12-18 13:39:02 +00:00
Converts FromBytes routine from bin.unpack to string.unpack for internal consistency
This commit is contained in:
@@ -1681,7 +1681,11 @@ PreLoginPacket =
|
|||||||
while true do
|
while true do
|
||||||
|
|
||||||
local optionType, optionPos, optionLength, optionData, expectedOptionLength, _
|
local optionType, optionPos, optionLength, optionData, expectedOptionLength, _
|
||||||
pos, optionType = bin.unpack("C", bytes, pos)
|
if pos > #bytes then
|
||||||
|
stdnse.debug2("%s: Could not extract optionType.", "MSSQL" )
|
||||||
|
return false, "Invalid pre-login response"
|
||||||
|
end
|
||||||
|
optionType, pos = ("B"):unpack(bytes, pos)
|
||||||
if ( optionType == PreLoginPacket.OPTION_TYPE.Terminator ) then
|
if ( optionType == PreLoginPacket.OPTION_TYPE.Terminator ) then
|
||||||
status = true
|
status = true
|
||||||
break
|
break
|
||||||
@@ -1692,11 +1696,11 @@ PreLoginPacket =
|
|||||||
expectedOptionLength = -1
|
expectedOptionLength = -1
|
||||||
end
|
end
|
||||||
|
|
||||||
pos, optionPos, optionLength = bin.unpack(">SS", bytes, pos)
|
if pos + 4 > #bytes + 1 then
|
||||||
if not (optionPos and optionLength) then
|
|
||||||
stdnse.debug2("%s: Could not unpack optionPos and optionLength.", "MSSQL" )
|
stdnse.debug2("%s: Could not unpack optionPos and optionLength.", "MSSQL" )
|
||||||
return false, "Invalid pre-login response"
|
return false, "Invalid pre-login response"
|
||||||
end
|
end
|
||||||
|
optionPos, optionLength, pos = (">I2I2"):unpack(bytes, pos)
|
||||||
|
|
||||||
optionPos = optionPos + 1 -- convert from 0-based index to 1-based index
|
optionPos = optionPos + 1 -- convert from 0-based index to 1-based index
|
||||||
if ( (optionPos + optionLength) > (#bytes + 1) ) then
|
if ( (optionPos + optionLength) > (#bytes + 1) ) then
|
||||||
@@ -1723,13 +1727,13 @@ PreLoginPacket =
|
|||||||
version:SetVersion( major, minor, build, subBuild, "SSNetLib" )
|
version:SetVersion( major, minor, build, subBuild, "SSNetLib" )
|
||||||
preLoginPacket.versionInfo = version
|
preLoginPacket.versionInfo = version
|
||||||
elseif ( optionType == PreLoginPacket.OPTION_TYPE.Encryption ) then
|
elseif ( optionType == PreLoginPacket.OPTION_TYPE.Encryption ) then
|
||||||
preLoginPacket:SetRequestEncryption( bin.unpack( "C", optionData ) )
|
preLoginPacket:SetRequestEncryption( ("B"):unpack(optionData) )
|
||||||
elseif ( optionType == PreLoginPacket.OPTION_TYPE.InstOpt ) then
|
elseif ( optionType == PreLoginPacket.OPTION_TYPE.InstOpt ) then
|
||||||
preLoginPacket:SetInstanceName( bin.unpack( "z", optionData ) )
|
preLoginPacket:SetInstanceName( ("z"):unpack(optionData) )
|
||||||
elseif ( optionType == PreLoginPacket.OPTION_TYPE.ThreadId ) then
|
elseif ( optionType == PreLoginPacket.OPTION_TYPE.ThreadId ) then
|
||||||
-- Do nothing. According to the TDS spec, this option is empty when sent from the server
|
-- Do nothing. According to the TDS spec, this option is empty when sent from the server
|
||||||
elseif ( optionType == PreLoginPacket.OPTION_TYPE.MARS ) then
|
elseif ( optionType == PreLoginPacket.OPTION_TYPE.MARS ) then
|
||||||
preLoginPacket:SetRequestMars( bin.unpack( "C", optionData ) )
|
preLoginPacket:SetRequestMars( ("B"):unpack(optionData) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user