Sha256: d7c4407b29b2d93853f3ca97eb1106c67ba19aafd56232f9a666b37c4d829f03

Contents?: true

Size: 766 Bytes

Versions: 38

Compression:

Stored size: 766 Bytes

Contents

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

38 entries across 38 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/proto/smb/crypt.rb
librex-0.0.63 lib/rex/proto/smb/crypt.rb
librex-0.0.54 lib/rex/proto/smb/crypt.rb
librex-0.0.53 lib/rex/proto/smb/crypt.rb
librex-0.0.52 lib/rex/proto/smb/crypt.rb
librex-0.0.51 lib/rex/proto/smb/crypt.rb
librex-0.0.50 lib/rex/proto/smb/crypt.rb
librex-0.0.49 lib/rex/proto/smb/crypt.rb
librex-0.0.48 lib/rex/proto/smb/crypt.rb
librex-0.0.47 lib/rex/proto/smb/crypt.rb
librex-0.0.46 lib/rex/proto/smb/crypt.rb
librex-0.0.44 lib/rex/proto/smb/crypt.rb
librex-0.0.43 lib/rex/proto/smb/crypt.rb
librex-0.0.42 lib/rex/proto/smb/crypt.rb
librex-0.0.41 lib/rex/proto/smb/crypt.rb
librex-0.0.40 lib/rex/proto/smb/crypt.rb
librex-0.0.39 lib/rex/proto/smb/crypt.rb
librex-0.0.38 lib/rex/proto/smb/crypt.rb
librex-0.0.37 lib/rex/proto/smb/crypt.rb
librex-0.0.36 lib/rex/proto/smb/crypt.rb