From b1372f11985907abe04509b906abf7b0e96f6c5a Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Fri, 16 Aug 2019 12:28:12 -0400 Subject: [PATCH 01/35] try printing out some backend message stuff --- lib/vertica/connection.rb | 2 ++ lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/vertica/connection.rb b/lib/vertica/connection.rb index fce3f78..43f2dd2 100644 --- a/lib/vertica/connection.rb +++ b/lib/vertica/connection.rb @@ -269,6 +269,7 @@ def write_message(message) # @private def read_message type, size = read_bytes(5).unpack('aN') + puts "type is #{type}" raise Vertica::Error::MessageError.new("Bad message size: #{size}.") unless size >= 4 message = Vertica::Protocol::BackendMessage.factory(type, read_bytes(size - 4)) puts "<= #{message.inspect}" if options.fetch(:debug) @@ -289,6 +290,7 @@ def process_message(message) when Vertica::Protocol::NoticeResponse @notice_handler.call(message) if @notice_handler when Vertica::Protocol::BackendKeyData + puts message.pid, message.key @backend_pid = message.pid @backend_key = message.key when Vertica::Protocol::ParameterStatus diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 8753d20..93b116f 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.3" + VERSION = "1.0.4" end From 99efb99df05d5c510b395c5165112eb75ecb8a9f Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Fri, 16 Aug 2019 14:23:19 -0400 Subject: [PATCH 02/35] print out received codes --- lib/vertica/protocol/backend/authentication.rb | 1 + lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index 367ea30..a3d2fa4 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -19,6 +19,7 @@ class Authentication < BackendMessage def initialize(data) @code, other = data.unpack('Na*') + puts "codes we received #{@code}, #{other}" case @code when CRYPT_PASSWORD, MD5_PASSWORD then @salt = other when GSS_CONTINUE then @auth_data = other diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 93b116f..401cb8d 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.4" + VERSION = "1.0.5" end From c2e4a1b3f841d43c41699e1c12e8482d85cc7b83 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 12:40:26 -0400 Subject: [PATCH 03/35] bump protocol version --- lib/vertica.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vertica.rb b/lib/vertica.rb index 7a53fe8..a97f1d0 100644 --- a/lib/vertica.rb +++ b/lib/vertica.rb @@ -10,7 +10,7 @@ module Vertica # The protocol version (3.0.0) implemented in this library. - PROTOCOL_VERSION = 3 << 16 + PROTOCOL_VERSION = 3 << 16 | 5 # Opens a new connection to a Vertica database. # @param (see Vertica::Connection#initialize) From cb4e50759f740e76ec4e24dd8045e4b7492f98ae Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 12:41:37 -0400 Subject: [PATCH 04/35] bump version --- lib/vertica/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 401cb8d..b07a638 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.5" + VERSION = "1.0.6" end From ca2d4961940ebdf03152dbf76489240460857cb8 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 13:11:19 -0400 Subject: [PATCH 05/35] ok some cargo culting --- lib/vertica/protocol/backend/authentication.rb | 18 ++++++++++++++++-- lib/vertica/version.rb | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index a3d2fa4..dec3601 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -4,6 +4,7 @@ class Authentication < BackendMessage message_id 'R' OK = 0 + KERBEROS_V4 = 1 KERBEROS_V5 = 2 CLEARTEXT_PASSWORD = 3 CRYPT_PASSWORD = 4 @@ -11,18 +12,31 @@ class Authentication < BackendMessage SCM_CREDENTIAL = 6 GSS = 7 GSS_CONTINUE = 8 - SSPI = 9 + CHANGE_PASSWORD = 9 + PASSWORD_CHANGED = 10 + PASSWORD_GRACE = 11 + HASH = 65536 + HASH_MD5 = 65536 + 5 + HASH_SHA512 = 65536+512 attr_reader :code attr_reader :salt + attr_reader :userSalt attr_reader :auth_data def initialize(data) @code, other = data.unpack('Na*') puts "codes we received #{@code}, #{other}" case @code - when CRYPT_PASSWORD, MD5_PASSWORD then @salt = other + when CRYPT_PASSWORD then @salt = other + when MD5_PASSWORD, HASH_MD5 then @salt = other[4..other.size] when GSS_CONTINUE then @auth_data = other + when HASH, HASH_MD5 + @salt = other[4..other.size] + @userSaltLen = other[4..7].unpack('!I')[0] + puts "user salt length is #{@userSaltLen}" + @userSalt = other[8..other.size].unpack("!#{@userSaltLen}s")[0] + puts "user salt is #{@userSalt}" end end end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index b07a638..d19a028 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.6" + VERSION = "1.0.7" end From 60a977aee0054815aa2481ed9a242e08022aadec Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 13:13:18 -0400 Subject: [PATCH 06/35] ruby doesn't like addition there? --- lib/vertica/protocol/backend/authentication.rb | 4 ++-- lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index dec3601..4ef479e 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -16,8 +16,8 @@ class Authentication < BackendMessage PASSWORD_CHANGED = 10 PASSWORD_GRACE = 11 HASH = 65536 - HASH_MD5 = 65536 + 5 - HASH_SHA512 = 65536+512 + HASH_MD5 = 65541 + HASH_SHA512 = 66048 attr_reader :code attr_reader :salt diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index d19a028..5f9567f 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.7" + VERSION = "1.0.8" end From eb321f265a840339722ed39f476a766a7c544573 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 13:19:14 -0400 Subject: [PATCH 07/35] start to bring the front end into line --- lib/vertica/protocol/backend/authentication.rb | 4 ++-- lib/vertica/protocol/frontend/password.rb | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index 4ef479e..5874014 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -16,8 +16,8 @@ class Authentication < BackendMessage PASSWORD_CHANGED = 10 PASSWORD_GRACE = 11 HASH = 65536 - HASH_MD5 = 65541 - HASH_SHA512 = 66048 + HASH_MD5 = 65536+5 + HASH_SHA512 = 65536+512 attr_reader :code attr_reader :salt diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index b6b21de..bf19f2b 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -14,7 +14,10 @@ def encoded_password @password when Vertica::Protocol::Authentication::CRYPT_PASSWORD @password.crypt(@salt) - when Vertica::Protocol::Authentication::MD5_PASSWORD + when Vertica::Protocol::Authentication::MD5_PASSWORD, \ + Vertica::Protocol::Authentication::HASH_MD5, \ + Vertica::Protocol::Authentication::HASH, \ + Vertica::Protocol::Authentication::HASH_SHA512 require 'digest/md5' @password = Digest::MD5.hexdigest("#{@password}#{@user}") @password = Digest::MD5.hexdigest("#{@password}#{@salt}") From ae9d4781325fb0fdd88a12f6b88a39b286da83da Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 13:19:36 -0400 Subject: [PATCH 08/35] bump version --- lib/vertica/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 5f9567f..e93fa75 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.8" + VERSION = "1.0.9" end From 1622c3b32a4c7c36b996fd53a4eede704257fe7a Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 15:46:07 -0400 Subject: [PATCH 09/35] teach password.rb to use sha512 --- lib/vertica/protocol/frontend/password.rb | 14 +++++++++----- lib/vertica/version.rb | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index bf19f2b..eb9d37e 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -5,7 +5,7 @@ class Password < FrontendMessage def initialize(password, auth_method: Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD, salt: nil, user: nil) @password = password - @auth_method, @salt, @user = auth_method, salt, user + @auth_method, @salt, @user, @userSalt = auth_method, salt, user, userSalt end def encoded_password @@ -14,14 +14,18 @@ def encoded_password @password when Vertica::Protocol::Authentication::CRYPT_PASSWORD @password.crypt(@salt) - when Vertica::Protocol::Authentication::MD5_PASSWORD, \ - Vertica::Protocol::Authentication::HASH_MD5, \ - Vertica::Protocol::Authentication::HASH, \ - Vertica::Protocol::Authentication::HASH_SHA512 + when Vertica::Protocol::Authentication::MD5_PASSWORD \ + Vertica::Protocol::Authentication::HASH_MD5 require 'digest/md5' @password = Digest::MD5.hexdigest("#{@password}#{@user}") @password = Digest::MD5.hexdigest("#{@password}#{@salt}") @password = "md5#{@password}" + when Vertica::Protocol::Authentication::HASH, \ + Vertica::Protocol::Authentication::HASH_SHA512 + require 'digest/sha512' + @password = Digest::SHA512.hexdigest("#{@password}#{@userSalt}") + @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") + @password = "sha512#{@password}" else raise ArgumentError.new("unsupported authentication method: #{@auth_method}") end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index e93fa75..f8cdcf7 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.9" + VERSION = "1.0.10" end From 7de2023db80c038bcd3352f6f7e6b9cf87b94de2 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 15:47:31 -0400 Subject: [PATCH 10/35] lost a comma --- lib/vertica/protocol/frontend/password.rb | 2 +- lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index eb9d37e..1ba3d72 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -14,7 +14,7 @@ def encoded_password @password when Vertica::Protocol::Authentication::CRYPT_PASSWORD @password.crypt(@salt) - when Vertica::Protocol::Authentication::MD5_PASSWORD \ + when Vertica::Protocol::Authentication::MD5_PASSWORD, \ Vertica::Protocol::Authentication::HASH_MD5 require 'digest/md5' @password = Digest::MD5.hexdigest("#{@password}#{@user}") diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index f8cdcf7..71aca83 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.10" + VERSION = "1.0.11" end From 157fde3905adb3fb1f3b169672df415d721ca49f Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 15:50:24 -0400 Subject: [PATCH 11/35] pass the user salt along --- lib/vertica/connection.rb | 2 +- lib/vertica/protocol/frontend/password.rb | 2 +- lib/vertica/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vertica/connection.rb b/lib/vertica/connection.rb index 43f2dd2..4f25408 100644 --- a/lib/vertica/connection.rb +++ b/lib/vertica/connection.rb @@ -394,7 +394,7 @@ def startup_connection case message = read_message when Vertica::Protocol::Authentication if message.code != Vertica::Protocol::Authentication::OK - write_message(Vertica::Protocol::Password.new(@options[:password], auth_method: message.code, user: @options[:username], salt: message.salt)) + write_message(Vertica::Protocol::Password.new(@options[:password], auth_method: message.code, user: @options[:username], salt: message.salt, userSalt: message.userSalt)) end else process_message(message) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index 1ba3d72..c1cb0a4 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -3,7 +3,7 @@ module Protocol class Password < FrontendMessage message_id 'p' - def initialize(password, auth_method: Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD, salt: nil, user: nil) + def initialize(password, auth_method: Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD, salt: nil, user: nil, userSalt: nil) @password = password @auth_method, @salt, @user, @userSalt = auth_method, salt, user, userSalt end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 71aca83..dacae62 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.11" + VERSION = "1.0.12" end From 0800ecd7de618b7b7955024714d77281a6677a5c Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 26 Aug 2019 15:52:56 -0400 Subject: [PATCH 12/35] try just requiring digest --- lib/vertica/protocol/frontend/password.rb | 2 +- lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index c1cb0a4..6ae81d1 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -22,7 +22,7 @@ def encoded_password @password = "md5#{@password}" when Vertica::Protocol::Authentication::HASH, \ Vertica::Protocol::Authentication::HASH_SHA512 - require 'digest/sha512' + require 'digest' @password = Digest::SHA512.hexdigest("#{@password}#{@userSalt}") @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") @password = "sha512#{@password}" diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index dacae62..4675207 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.12" + VERSION = "1.0.13" end From 7d28e471f356745155f0d0884ce6d79ff3bdb2d6 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Tue, 27 Aug 2019 13:58:55 -0400 Subject: [PATCH 13/35] maybe ruby and python agree? --- lib/vertica/protocol/backend/authentication.rb | 2 +- lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index 5874014..a828369 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -33,7 +33,7 @@ def initialize(data) when GSS_CONTINUE then @auth_data = other when HASH, HASH_MD5 @salt = other[4..other.size] - @userSaltLen = other[4..7].unpack('!I')[0] + @userSaltLen = other[4..8].unpack('!I')[0] puts "user salt length is #{@userSaltLen}" @userSalt = other[8..other.size].unpack("!#{@userSaltLen}s")[0] puts "user salt is #{@userSalt}" diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 4675207..55e7c9e 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.13" + VERSION = "1.0.14" end From 2897edaa850c608cb5975de92e3ae6f5c4c113f2 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Tue, 27 Aug 2019 14:00:00 -0400 Subject: [PATCH 14/35] add the pw configuration? --- vagrant/configure_vertica_passwords.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 vagrant/configure_vertica_passwords.sql diff --git a/vagrant/configure_vertica_passwords.sql b/vagrant/configure_vertica_passwords.sql new file mode 100644 index 0000000..5c24769 --- /dev/null +++ b/vagrant/configure_vertica_passwords.sql @@ -0,0 +1,5 @@ +select SET_CONFIG_PARAMETER('SecurityAlgorithm', 'SHA512'); +CREATE AUTHENTICATION default_network METHOD 'hash' HOST '0.0.0.0/0'; +CREATE AUTHENTICATION default_local METHOD 'hash' LOCAL; +GRANT AUTHENTICATION default_network to public; +GRANT AUTHENTICATION default_local to public; From 3f2d2421c7251dd9f641010daea6d16758fd4884 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Tue, 27 Aug 2019 15:05:30 -0400 Subject: [PATCH 15/35] i didn't use the right names --- lib/vertica/protocol/backend/authentication.rb | 4 ++-- lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index a828369..10daf85 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -31,9 +31,9 @@ def initialize(data) when CRYPT_PASSWORD then @salt = other when MD5_PASSWORD, HASH_MD5 then @salt = other[4..other.size] when GSS_CONTINUE then @auth_data = other - when HASH, HASH_MD5 + when HASH, HASH_SHA512 @salt = other[4..other.size] - @userSaltLen = other[4..8].unpack('!I')[0] + @userSaltLen = other[4..7].unpack('!I')[0] puts "user salt length is #{@userSaltLen}" @userSalt = other[8..other.size].unpack("!#{@userSaltLen}s")[0] puts "user salt is #{@userSalt}" diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 55e7c9e..9f9e9ef 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.14" + VERSION = "1.0.15" end From bc24f8f2e4ac57b5bee842eebd3a5861456015c2 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Tue, 27 Aug 2019 15:10:07 -0400 Subject: [PATCH 16/35] check the user salt length --- lib/vertica/protocol/backend/authentication.rb | 5 ++++- lib/vertica/version.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index 10daf85..f723d1c 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -32,9 +32,12 @@ def initialize(data) when MD5_PASSWORD, HASH_MD5 then @salt = other[4..other.size] when GSS_CONTINUE then @auth_data = other when HASH, HASH_SHA512 - @salt = other[4..other.size] + @salt = other[0..3] @userSaltLen = other[4..7].unpack('!I')[0] puts "user salt length is #{@userSaltLen}" + if @userSaltLen != 16 + puts "user salt length isn't 16, raise error" + end @userSalt = other[8..other.size].unpack("!#{@userSaltLen}s")[0] puts "user salt is #{@userSalt}" end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 9f9e9ef..8a21efd 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.15" + VERSION = "1.0.16" end From c8242cf4733a89d1a8565bab07af8cec1093fd03 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Tue, 27 Aug 2019 15:21:35 -0400 Subject: [PATCH 17/35] apparently we use different packing symbols --- lib/vertica/protocol/backend/authentication.rb | 4 ++-- lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index f723d1c..af6e949 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -29,11 +29,11 @@ def initialize(data) puts "codes we received #{@code}, #{other}" case @code when CRYPT_PASSWORD then @salt = other - when MD5_PASSWORD, HASH_MD5 then @salt = other[4..other.size] + when MD5_PASSWORD, HASH_MD5 then @salt = other[0..3] when GSS_CONTINUE then @auth_data = other when HASH, HASH_SHA512 @salt = other[0..3] - @userSaltLen = other[4..7].unpack('!I')[0] + @userSaltLen = other[4..7].unpack('n').first puts "user salt length is #{@userSaltLen}" if @userSaltLen != 16 puts "user salt length isn't 16, raise error" diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 8a21efd..2a4915d 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.16" + VERSION = "1.0.17" end From 4971e093ecd2ba337fbcf4034122b499c8338a02 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Tue, 27 Aug 2019 15:27:08 -0400 Subject: [PATCH 18/35] try and unpack the second place with stuff --- lib/vertica/protocol/backend/authentication.rb | 2 +- lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index af6e949..a7012e9 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -38,7 +38,7 @@ def initialize(data) if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end - @userSalt = other[8..other.size].unpack("!#{@userSaltLen}s")[0] + @userSalt = other[8..other.size].unpack('Na*').first puts "user salt is #{@userSalt}" end end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 2a4915d..78f62fb 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.17" + VERSION = "1.0.18" end From 89f8a2374ce6300419fd82fd383acb73161e25b5 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Tue, 27 Aug 2019 15:33:05 -0400 Subject: [PATCH 19/35] try ranges? --- lib/vertica/protocol/backend/authentication.rb | 8 ++++---- lib/vertica/version.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index a7012e9..0882cdd 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -29,16 +29,16 @@ def initialize(data) puts "codes we received #{@code}, #{other}" case @code when CRYPT_PASSWORD then @salt = other - when MD5_PASSWORD, HASH_MD5 then @salt = other[0..3] + when MD5_PASSWORD, HASH_MD5 then @salt = other[0...4] when GSS_CONTINUE then @auth_data = other when HASH, HASH_SHA512 - @salt = other[0..3] - @userSaltLen = other[4..7].unpack('n').first + @salt = other[0...4] + @userSaltLen = other[4...8].unpack('n').first puts "user salt length is #{@userSaltLen}" if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end - @userSalt = other[8..other.size].unpack('Na*').first + @userSalt = other[8...other.size].unpack('Na*').first puts "user salt is #{@userSalt}" end end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 78f62fb..3a36087 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.18" + VERSION = "1.0.19" end From 4528717400b9c436e99c87f52814123570ea1426 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 28 Aug 2019 13:42:54 -0400 Subject: [PATCH 20/35] some brute forcing --- lib/vertica/protocol/backend/authentication.rb | 4 ++++ lib/vertica/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index 0882cdd..da55ea9 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -35,6 +35,10 @@ def initialize(data) @salt = other[0...4] @userSaltLen = other[4...8].unpack('n').first puts "user salt length is #{@userSaltLen}" + for i in 5..12 do + puts "trying other range #{i}" + puts "#{other[4...i].unpack('n').first}" + end if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 3a36087..27c53cb 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.19" + VERSION = "1.0.20" end From 2f3971fc02142d89774703458d321cd508ed8fb8 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 28 Aug 2019 13:45:42 -0400 Subject: [PATCH 21/35] don't think i know much about ruby string substitution --- lib/vertica/protocol/backend/authentication.rb | 3 ++- lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index da55ea9..aa74a32 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -37,7 +37,8 @@ def initialize(data) puts "user salt length is #{@userSaltLen}" for i in 5..12 do puts "trying other range #{i}" - puts "#{other[4...i].unpack('n').first}" + thisSalt = other[4...i].unpack('n').first + puts "#{thisSalt}" end if @userSaltLen != 16 puts "user salt length isn't 16, raise error" diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 27c53cb..ee71629 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.20" + VERSION = "1.0.21" end From 809da493836ccb56d2f0ca9e1d0c8649eede920f Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 28 Aug 2019 14:11:47 -0400 Subject: [PATCH 22/35] try just hardcoding the encoding --- lib/vertica/protocol/backend/authentication.rb | 2 +- lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index aa74a32..30fc139 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -43,7 +43,7 @@ def initialize(data) if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end - @userSalt = other[8...other.size].unpack('Na*').first + @userSalt = other[8...other.size].unpack('n').first puts "user salt is #{@userSalt}" end end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index ee71629..86afac6 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.21" + VERSION = "1.0.22" end From 7d792b610c13ae134fc0024ce3ae42738c0e0cdf Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 28 Aug 2019 14:13:04 -0400 Subject: [PATCH 23/35] try adding some more transparency --- lib/vertica/protocol/backend/authentication.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index 30fc139..0dcc66d 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -35,15 +35,12 @@ def initialize(data) @salt = other[0...4] @userSaltLen = other[4...8].unpack('n').first puts "user salt length is #{@userSaltLen}" - for i in 5..12 do - puts "trying other range #{i}" - thisSalt = other[4...i].unpack('n').first - puts "#{thisSalt}" - end if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end - @userSalt = other[8...other.size].unpack('n').first + userSaltArray = other[8...other.size].unpack('n') + puts "user salt array is #{userSaltArray}" + @userSalt = userSaltArray.first puts "user salt is #{@userSalt}" end end From c9d32b3567b79e88b857bde4663b05be45638529 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 28 Aug 2019 14:21:41 -0400 Subject: [PATCH 24/35] try printing more out --- lib/vertica/protocol/frontend/password.rb | 1 + lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index 6ae81d1..370df2e 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -23,6 +23,7 @@ def encoded_password when Vertica::Protocol::Authentication::HASH, \ Vertica::Protocol::Authentication::HASH_SHA512 require 'digest' + puts "#{@userSalt} is the user salt in the password file" @password = Digest::SHA512.hexdigest("#{@password}#{@userSalt}") @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") @password = "sha512#{@password}" diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 86afac6..69b79a5 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.22" + VERSION = "1.0.23" end From 6bb1acc382e5892d2d4313aa50f3f1d8135827b9 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 28 Aug 2019 14:33:32 -0400 Subject: [PATCH 25/35] print out manual hash --- lib/vertica/protocol/frontend/password.rb | 5 +++++ lib/vertica/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index 370df2e..c231914 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -27,6 +27,11 @@ def encoded_password @password = Digest::SHA512.hexdigest("#{@password}#{@userSalt}") @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") @password = "sha512#{@password}" + expected_password = Digest::SHA512.hexdigest("#{@userSalt}") + expected_password = Digest::SHA512.hexdigest("#{expected_password}#{@salt}") + expected_password = "sha512#{@expected_password}" + puts " password is #{@password}" + puts "expected password is #{@expected_password}" else raise ArgumentError.new("unsupported authentication method: #{@auth_method}") end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 69b79a5..d8b5e09 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.23" + VERSION = "1.0.24" end From b4cc4e97c2ea9cd2701eedfbd0628753fe5c4f6a Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 28 Aug 2019 14:35:58 -0400 Subject: [PATCH 26/35] ok.... --- lib/vertica/protocol/frontend/password.rb | 6 +++--- lib/vertica/version.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index c231914..1244f77 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -27,9 +27,9 @@ def encoded_password @password = Digest::SHA512.hexdigest("#{@password}#{@userSalt}") @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") @password = "sha512#{@password}" - expected_password = Digest::SHA512.hexdigest("#{@userSalt}") - expected_password = Digest::SHA512.hexdigest("#{expected_password}#{@salt}") - expected_password = "sha512#{@expected_password}" + @expected_password = Digest::SHA512.hexdigest("#{@userSalt}") + @expected_password = Digest::SHA512.hexdigest("#{@expected_password}#{@salt}") + @expected_password = "sha512#{@expected_password}" puts " password is #{@password}" puts "expected password is #{@expected_password}" else diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index d8b5e09..2ddcdd2 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.24" + VERSION = "1.0.25" end From 97b0c3b1eb03eed98f25fcd42a048e99a35ab64c Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 28 Aug 2019 14:38:49 -0400 Subject: [PATCH 27/35] encode the prefix as bytes --- lib/vertica/protocol/frontend/password.rb | 8 ++------ lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index 1244f77..e916078 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -26,12 +26,8 @@ def encoded_password puts "#{@userSalt} is the user salt in the password file" @password = Digest::SHA512.hexdigest("#{@password}#{@userSalt}") @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") - @password = "sha512#{@password}" - @expected_password = Digest::SHA512.hexdigest("#{@userSalt}") - @expected_password = Digest::SHA512.hexdigest("#{@expected_password}#{@salt}") - @expected_password = "sha512#{@expected_password}" - puts " password is #{@password}" - puts "expected password is #{@expected_password}" + prefix = "sha512".bytes + @password = "#{prefix}#{@password}" else raise ArgumentError.new("unsupported authentication method: #{@auth_method}") end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 2ddcdd2..4b22e4e 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.25" + VERSION = "1.0.26" end From 83133136a639fa6666137b7427826b0ac7b77d59 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Thu, 29 Aug 2019 11:16:24 -0400 Subject: [PATCH 28/35] try some inspection --- lib/vertica/protocol/backend/authentication.rb | 5 ++++- lib/vertica/version.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index 0dcc66d..a15625a 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -33,13 +33,16 @@ def initialize(data) when GSS_CONTINUE then @auth_data = other when HASH, HASH_SHA512 @salt = other[0...4] + puts "#{other[4...8]}" + puts "#{other[4...8].unpack('n')}" @userSaltLen = other[4...8].unpack('n').first puts "user salt length is #{@userSaltLen}" if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end + puts "#{other[8...other.size]}" + puts "#{other[8...other.size].unpack('n')}" userSaltArray = other[8...other.size].unpack('n') - puts "user salt array is #{userSaltArray}" @userSalt = userSaltArray.first puts "user salt is #{@userSalt}" end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 4b22e4e..50dbcdb 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.26" + VERSION = "1.0.27" end From eeb31cb865ae4ef03c2b5583186462a182c5b866 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Thu, 29 Aug 2019 11:28:14 -0400 Subject: [PATCH 29/35] am i unpacking right? --- lib/vertica/protocol/backend/authentication.rb | 8 ++------ lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index a15625a..b1bebe0 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -33,16 +33,12 @@ def initialize(data) when GSS_CONTINUE then @auth_data = other when HASH, HASH_SHA512 @salt = other[0...4] - puts "#{other[4...8]}" - puts "#{other[4...8].unpack('n')}" - @userSaltLen = other[4...8].unpack('n').first + @userSaltLen = other[4...8].unpack('I>').first puts "user salt length is #{@userSaltLen}" if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end - puts "#{other[8...other.size]}" - puts "#{other[8...other.size].unpack('n')}" - userSaltArray = other[8...other.size].unpack('n') + userSaltArray = other[8...other.size].unpack('I>') @userSalt = userSaltArray.first puts "user salt is #{@userSalt}" end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 50dbcdb..a161ca5 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.27" + VERSION = "1.0.28" end From 636b8d47990f75376e9fce29e505685fc3df7641 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Thu, 29 Aug 2019 11:36:59 -0400 Subject: [PATCH 30/35] maybe this for the salt? --- lib/vertica/protocol/backend/authentication.rb | 2 +- lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index b1bebe0..d387cdb 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -38,7 +38,7 @@ def initialize(data) if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end - userSaltArray = other[8...other.size].unpack('I>') + userSaltArray = other[8...other.size].unpack('a*') @userSalt = userSaltArray.first puts "user salt is #{@userSalt}" end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index a161ca5..7c94758 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.28" + VERSION = "1.0.29" end From 02db95c8ed87cc10b28836bba88c8fabca177cc9 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Thu, 29 Aug 2019 12:55:02 -0400 Subject: [PATCH 31/35] print out hashes for comparison --- lib/vertica/protocol/frontend/password.rb | 2 ++ lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index e916078..449c10c 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -25,7 +25,9 @@ def encoded_password require 'digest' puts "#{@userSalt} is the user salt in the password file" @password = Digest::SHA512.hexdigest("#{@password}#{@userSalt}") + puts "@password after user salt is \n#{@password}" @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") + puts "@password after salt is \n#{@password}" prefix = "sha512".bytes @password = "#{prefix}#{@password}" else diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 7c94758..2fcf67f 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.29" + VERSION = "1.0.30" end From f9aef865b2da083530edcef7cd0ea35760ef23f4 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Thu, 29 Aug 2019 15:04:47 -0400 Subject: [PATCH 32/35] try concating the strings --- lib/vertica/protocol/frontend/password.rb | 5 +++-- lib/vertica/version.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index 449c10c..2adef7b 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -19,7 +19,8 @@ def encoded_password require 'digest/md5' @password = Digest::MD5.hexdigest("#{@password}#{@user}") @password = Digest::MD5.hexdigest("#{@password}#{@salt}") - @password = "md5#{@password}" + prefix = "md5".bytes + @password = "#{prefix}#{@password}" when Vertica::Protocol::Authentication::HASH, \ Vertica::Protocol::Authentication::HASH_SHA512 require 'digest' @@ -29,7 +30,7 @@ def encoded_password @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") puts "@password after salt is \n#{@password}" prefix = "sha512".bytes - @password = "#{prefix}#{@password}" + @password = prefix + @password else raise ArgumentError.new("unsupported authentication method: #{@auth_method}") end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 2fcf67f..5c45b72 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.30" + VERSION = "1.0.31" end From 7d01d765e52c1c5bbc4c07c02e675d48da063613 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Thu, 29 Aug 2019 15:28:57 -0400 Subject: [PATCH 33/35] use byte concat instead of array --- lib/vertica/protocol/frontend/password.rb | 2 +- lib/vertica/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index 2adef7b..543039a 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -30,7 +30,7 @@ def encoded_password @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") puts "@password after salt is \n#{@password}" prefix = "sha512".bytes - @password = prefix + @password + @password = prefix << @password else raise ArgumentError.new("unsupported authentication method: #{@auth_method}") end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 5c45b72..7f3338a 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.31" + VERSION = "1.0.32" end From 2525b02d8ca6882ca99e1e2c1f71574c2368a1bb Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Thu, 29 Aug 2019 15:36:43 -0400 Subject: [PATCH 34/35] regular string --- lib/vertica/protocol/frontend/password.rb | 4 ++-- lib/vertica/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index 543039a..d86ca0f 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -29,8 +29,8 @@ def encoded_password puts "@password after user salt is \n#{@password}" @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") puts "@password after salt is \n#{@password}" - prefix = "sha512".bytes - @password = prefix << @password + prefix = "sha512" + @password = "#{prefix}#{@password}" else raise ArgumentError.new("unsupported authentication method: #{@auth_method}") end diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 7f3338a..85d6b6d 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.32" + VERSION = "1.0.33" end From ffa2f7932dacf7a0f0c83fc2555a62e2c7917e64 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Thu, 29 Aug 2019 15:40:41 -0400 Subject: [PATCH 35/35] remove unneded print statements --- lib/vertica/connection.rb | 2 -- lib/vertica/protocol/backend/authentication.rb | 3 --- lib/vertica/protocol/frontend/password.rb | 3 --- lib/vertica/version.rb | 2 +- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/vertica/connection.rb b/lib/vertica/connection.rb index 4f25408..4f785de 100644 --- a/lib/vertica/connection.rb +++ b/lib/vertica/connection.rb @@ -269,7 +269,6 @@ def write_message(message) # @private def read_message type, size = read_bytes(5).unpack('aN') - puts "type is #{type}" raise Vertica::Error::MessageError.new("Bad message size: #{size}.") unless size >= 4 message = Vertica::Protocol::BackendMessage.factory(type, read_bytes(size - 4)) puts "<= #{message.inspect}" if options.fetch(:debug) @@ -290,7 +289,6 @@ def process_message(message) when Vertica::Protocol::NoticeResponse @notice_handler.call(message) if @notice_handler when Vertica::Protocol::BackendKeyData - puts message.pid, message.key @backend_pid = message.pid @backend_key = message.key when Vertica::Protocol::ParameterStatus diff --git a/lib/vertica/protocol/backend/authentication.rb b/lib/vertica/protocol/backend/authentication.rb index d387cdb..036cf02 100644 --- a/lib/vertica/protocol/backend/authentication.rb +++ b/lib/vertica/protocol/backend/authentication.rb @@ -26,7 +26,6 @@ class Authentication < BackendMessage def initialize(data) @code, other = data.unpack('Na*') - puts "codes we received #{@code}, #{other}" case @code when CRYPT_PASSWORD then @salt = other when MD5_PASSWORD, HASH_MD5 then @salt = other[0...4] @@ -34,13 +33,11 @@ def initialize(data) when HASH, HASH_SHA512 @salt = other[0...4] @userSaltLen = other[4...8].unpack('I>').first - puts "user salt length is #{@userSaltLen}" if @userSaltLen != 16 puts "user salt length isn't 16, raise error" end userSaltArray = other[8...other.size].unpack('a*') @userSalt = userSaltArray.first - puts "user salt is #{@userSalt}" end end end diff --git a/lib/vertica/protocol/frontend/password.rb b/lib/vertica/protocol/frontend/password.rb index d86ca0f..d4a4658 100644 --- a/lib/vertica/protocol/frontend/password.rb +++ b/lib/vertica/protocol/frontend/password.rb @@ -24,11 +24,8 @@ def encoded_password when Vertica::Protocol::Authentication::HASH, \ Vertica::Protocol::Authentication::HASH_SHA512 require 'digest' - puts "#{@userSalt} is the user salt in the password file" @password = Digest::SHA512.hexdigest("#{@password}#{@userSalt}") - puts "@password after user salt is \n#{@password}" @password = Digest::SHA512.hexdigest("#{@password}#{@salt}") - puts "@password after salt is \n#{@password}" prefix = "sha512" @password = "#{prefix}#{@password}" else diff --git a/lib/vertica/version.rb b/lib/vertica/version.rb index 85d6b6d..ce243ad 100644 --- a/lib/vertica/version.rb +++ b/lib/vertica/version.rb @@ -1,5 +1,5 @@ module Vertica # The version of the package. We adhere to semantic versioning. # To release a new version, update this constant, commit to master, and run `rake release` - VERSION = "1.0.33" + VERSION = "1.0.34" end