Sha256: d466521fcb0fde34a2272ebffc764b2075fcabfc83aca01fa774fbde257b4a7b

Contents?: true

Size: 1.68 KB

Versions: 43

Compression:

Stored size: 1.68 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))

require 'rex/test'
require 'rex/exceptions'
require 'rex/proto/dcerpc/ndr'

class Rex::Proto::DCERPC::NDR::UnitTest < Test::Unit::TestCase

	Klass = Rex::Proto::DCERPC::NDR

	def test_align
		assert_equal(0, Klass.align('').length, 'align 0')
		assert_equal(3, Klass.align('f').length, 'align 1')
		assert_equal(2, Klass.align('fo').length, 'align 2')
		assert_equal(1, Klass.align('foo').length, 'align 3')
		assert_equal(0, Klass.align('fooo').length, 'align 4')
		assert_equal(3, Klass.align('foooo').length, 'align 5')
	end

	def test_numbers
		assert_equal("\x0a\x00\x00\x00", Klass.long(10), 'long')
		assert_equal("\x0a\x00", Klass.short(10), 'short')
		assert_equal("\x0a", Klass.byte(10), 'byte')
	end

	def test_conformant_array
		assert_equal("\x05\x00\x00\x00aaaaa", Klass.UniConformantArray('aaaaa').slice(0,9), 'UniConformantArray')
		assert_equal(12, Klass.UniConformantArray('aaaaa').length, 'UniConformantArray length')
	end
	
	def test_conformant_string
		assert_equal("\x06\x00\x00\x00" + "\x00\x00\x00\x00" + "\x06\x00\x00\x00" "a\x00a\x00a\x00a\x00a\x00\x00\x00", Klass.UnicodeConformantVaryingString('aaaaa').slice(0,4+4+4+12), 'UniConformantVaryingString')
		assert_equal(24, Klass.UnicodeConformantVaryingString('aaaaa').length, 'UniConformantVaryingString length')
	
		assert_equal("\x02\x00\x00\x00" + "\x00\x00\x00\x00" + "\x02\x00\x00\x00" "aa\x00\x00", Klass.UnicodeConformantVaryingStringPreBuilt('aa' + "\x00\x00"), 'UniConformantVaryingStringPreBuilt')
		assert_equal(16, Klass.UnicodeConformantVaryingStringPreBuilt('aa' + "\x00\x00").length, 'UniConformantVaryingStringPreBuilt length')
	end

end

Version data entries

43 entries across 43 versions & 1 rubygems

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