1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Use string.gsub instead of looped concat to modify strings

This commit is contained in:
dmiller
2015-02-27 14:55:29 +00:00
parent d16772a8a8
commit e275a96c72
5 changed files with 23 additions and 42 deletions

View File

@@ -3064,15 +3064,13 @@ Auth = {
-- @return string containing the encrypted password
TDS7CryptPass = function(password)
local xormask = 0x5a5a
local result = ""
for i=1, password:len() do
local c = bit.bxor( string.byte( password:sub( i, i ) ), xormask )
return password:gsub(".", function(i)
local c = bit.bxor( string.byte( i ), xormask )
local m1= bit.band( bit.rshift( c, 4 ), 0x0F0F )
local m2= bit.band( bit.lshift( c, 4 ), 0xF0F0 )
result = result .. bin.pack("S", bit.bor( m1, m2 ) )
end
return result
return bin.pack("S", bit.bor( m1, m2 ) )
end)
end,
LmResponse = function( password, nonce )