Class: Rex::Proto::SMB::Crypt
- Inherits:
-
Object
- Object
- Rex::Proto::SMB::Crypt
- Defined in:
- lib/rex/proto/smb/crypt.rb
Constant Summary collapse
- @@loaded_openssl =
false
Class Method Summary collapse
- .is_signature_correct?(mackey, sequence_counter, data) ⇒ Boolean
-
.sign_smb_packet(mackey, sequence_counter, data) ⇒ Object
Return a signed SMB packet.
Class Method Details
.is_signature_correct?(mackey, sequence_counter, data) ⇒ Boolean
28 29 30 31 32 |
# File 'lib/rex/proto/smb/crypt.rb', line 28 def self.is_signature_correct?(mackey, sequence_counter, data) signature1 = data[18,8] signature2 = sign_smb_packet(mackey, sequence_counter, data.dup)[18,8] return signature1 == signature2 end |
.sign_smb_packet(mackey, sequence_counter, data) ⇒ Object
Return a signed SMB packet
18 19 20 21 22 23 24 25 26 |
# File 'lib/rex/proto/smb/crypt.rb', line 18 def self.sign_smb_packet(mackey, sequence_counter, data) raise RuntimeError, "No OpenSSL support" if not @@loaded_openssl seq = Rex::Text::pack_int64le(sequence_counter) netbios_hdr = data.slice!(0,4) data[14,8] = seq signature = OpenSSL::Digest::MD5.digest(mackey + data)[0,8] data[14,8] = signature netbios_hdr + data end |