Sha256: e6f79ea31f6f0cf2de02f00801b3343ffd3737601d2f98a6d2e4e7e9f6573032

Contents?: true

Size: 822 Bytes

Versions: 15

Compression:

Stored size: 822 Bytes

Contents

# -*- coding: binary -*-
require 'rex/text'

module Rex
module Proto
module SMB
class Crypt

  @@loaded_openssl = false

  begin
    require 'openssl'
    @@loaded_openssl = true
  rescue ::Exception
  end

  # Return a signed SMB packet
  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

  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

end
end
end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
rex-2.0.13 lib/rex/proto/smb/crypt.rb
rex-2.0.12 lib/rex/proto/smb/crypt.rb
rex-2.0.11 lib/rex/proto/smb/crypt.rb
rex-2.0.10 lib/rex/proto/smb/crypt.rb
rex-2.0.9 lib/rex/proto/smb/crypt.rb
rex-2.0.8 lib/rex/proto/smb/crypt.rb
rex-2.0.7 lib/rex/proto/smb/crypt.rb
rex-2.0.5 lib/rex/proto/smb/crypt.rb
rex-2.0.4 lib/rex/proto/smb/crypt.rb
dstruct-0.0.1 lib/rex/proto/smb/crypt.rb
rex-2.0.3 lib/rex/proto/smb/crypt.rb
librex-0.0.999 lib/rex/proto/smb/crypt.rb
rex-2.0.2 lib/rex/proto/smb/crypt.rb
librex-0.0.71 lib/rex/proto/smb/crypt.rb
librex-0.0.70 lib/rex/proto/smb/crypt.rb