Parent

Class/Module Index [+]

Quicksearch

Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Type::PlatformUtil::UnitTest

Constants

X86_32
X86_32_NULL_POINTER
X86_32_POINTERS

memread value of win x86 pointer mapped to target unpack value

X86_64
X86_64_NULL_POINTER
X86_64_POINTERS

Public Instance Methods

test_is_null_pointer() click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb.ut.rb, line 83
def test_is_null_pointer
        [X86_32, X86_64].each do |platform|
                assert(PointerUtil.is_null_pointer?(nil, platform), 'nil should be a null pointer')
                assert(PointerUtil.is_null_pointer?(0, platform), 'numeric 0 should be a null pointer')
        end

        assert_equal(true, PointerUtil.is_null_pointer?(X86_32_NULL_POINTER, X86_32),
                'is_null_pointer? should return true for packed 32-bit null pointers')

        assert_equal(true, PointerUtil.is_null_pointer?(X86_64_NULL_POINTER, X86_64),
                'is_null_pointer? should return true for packed 64-bit null pointers')

end
test_is_pointer_type() click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb.ut.rb, line 105
def test_is_pointer_type
        assert_equal(true, PointerUtil.is_pointer_type?(:pointer),
                'pointer_type should return true for the symbol :pointer')

        assert_equal(true, PointerUtil.is_pointer_type?('LPVOID'),
                'pointer_type should return true if string begins with LP')

        assert_equal(true, PointerUtil.is_pointer_type?('PDWORD'),
                'pointer_type should return true if string begins with P')

        assert_equal(false, PointerUtil.is_pointer_type?('LOLZ'),
                'pointer_type should return false if not a pointer type')

end
test_pack_pointer() click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb.ut.rb, line 45
def test_pack_pointer
        X86_64_POINTERS.invert.each_pair do |unpacked, packed|
                assert_equal(packed, PointerUtil.pack_pointer(unpacked.to_i, X86_64),
                        "pack_pointer should pack 64-bit numberic pointers")
        end

        X86_32_POINTERS.invert.each_pair do |unpacked, packed|
                assert_equal(packed, PointerUtil.pack_pointer(unpacked.to_i, X86_32),
                        "pack_pointer should pack 32-bit numberic pointers")
        end

        assert_equal(X86_64_NULL_POINTER, PointerUtil.pack_pointer(nil, X86_64),
                'pack_pointer should pack "nil" as a null pointer for x86_64')

        assert_equal(X86_32_NULL_POINTER, PointerUtil.pack_pointer(nil, X86_32),
                'pack_pointer should pack "nil" as a null pointer for x86_32')

        assert_equal(X86_64_NULL_POINTER, PointerUtil.pack_pointer(0, X86_64),
                'pack_pointer should pack numeric 0 as a null pointer for x86_64')

        assert_equal(X86_32_NULL_POINTER, PointerUtil.pack_pointer(0, X86_32),
                'pack_pointer should pack numeric 9 as a null pointer for x86_32')
end
test_pointer_size() click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb.ut.rb, line 97
def test_pointer_size
        assert_equal(8, PointerUtil.pointer_size(X86_64),
                'pointer_size should report X86_64 arch as 8 (bytes)')

        assert_equal(4, PointerUtil.pointer_size(X86_32),
                'pointer_size should report X86_32 arch as 4 (bytes)')
end
test_unpack_pointer() click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/type/pointer_util.rb.ut.rb, line 69
def test_unpack_pointer
        X86_64_POINTERS.each_pair do |packed, unpacked|
                assert_equal(unpacked, PointerUtil.unpack_pointer(packed, X86_64),
                        "unpack_pointer should unpack 64-bit pointers")
        end

        X86_32_POINTERS.each_pair do |packed, unpacked|
                assert_equal(unpacked, PointerUtil.unpack_pointer(packed, X86_32),
                        "unpack_pointer should unpack 32-bit pointers")
        end


end

[Validate]

Generated with the Darkfish Rdoc Generator 2.