From 0b7dc8034925c3548168f0bebfa55183ed40dc1e Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 14 Dec 2021 22:35:57 +0000 Subject: [PATCH] Fix TDS7 password encoding. Fixes #2388. --- CHANGELOG | 3 +++ nselib/mssql.lua | 47 +++++++++++++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d04ca6187..fbdd2b54f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ #Nmap Changelog ($Id$); -*-text-*- +o [GH#2388] Fix TDS7 password encoding for mssql.lua, which had been assuming + ASCII input even though other parts of the library had been passing it Unicode. + o [GH#2402] Replace deprecated CPEs for IIS with their updated identifier, cpe:/a:microsoft:internet_information_services [Esa Jokinen] diff --git a/nselib/mssql.lua b/nselib/mssql.lua index f1be0ecfb..fe5946b1d 100644 --- a/nselib/mssql.lua +++ b/nselib/mssql.lua @@ -2004,7 +2004,7 @@ LoginPacket = local u_library = unicode.utf8to16(self.library) local u_locale = unicode.utf8to16(self.locale) local u_database = unicode.utf8to16(self.database) - local u_username, u_password + local u_username, uc_password self.length = offset + #u_client + #u_app + #u_server + #u_library + #u_database @@ -2014,8 +2014,8 @@ LoginPacket = self.options_2 = self.options_2 + 0x80 else u_username = unicode.utf8to16(self.username) - u_password = unicode.utf8to16(self.password) - self.length = self.length + #u_username + #u_password + uc_password = Auth.TDS7CryptPass(self.password, unicode.utf8_dec) + self.length = self.length + #u_username + #uc_password end data = { @@ -2032,8 +2032,8 @@ LoginPacket = data[#data+1] = string.pack("> 4 ) & 0x0F0F + local m2= ( c << 4 ) & 0xF0F0 + return string.pack("> 4 ) & 0x0F0F - local m2= ( c << 4 ) & 0xF0F0 - return string.pack("