Class: RubySMB::Dcerpc::Samr::SamprEncryptedUserPassword
- Inherits:
-
Ndr::NdrStruct
- Object
- BinData::Record
- Ndr::NdrStruct
- RubySMB::Dcerpc::Samr::SamprEncryptedUserPassword
- Defined in:
- lib/ruby_smb/dcerpc/samr.rb
Overview
Direct Known Subclasses
Class Method Summary collapse
Methods inherited from Ndr::NdrStruct
#initialize_shared_instance, method_missing, validate_conformant_array
Class Method Details
.encrypt_password(password, old_password_nt) ⇒ Object
395 396 397 398 399 400 401 402 403 404 |
# File 'lib/ruby_smb/dcerpc/samr.rb', line 395 def self.encrypt_password(password, old_password_nt) # see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/5fe3c4c4-e71b-440d-b2fd-8448bfaf6e04 password = password.encode('UTF-16LE').force_encoding('ASCII-8BIT') buffer = password.rjust(512, "\x00") + [ password.length ].pack('V') cipher = OpenSSL::Cipher.new('RC4').tap do |cipher| cipher.encrypt cipher.key = old_password_nt end cipher.update(buffer) end |