metasploit-framework/lib/metasm/tests/arc.rb

27 lines
1011 B
Ruby
Raw Normal View History

2014-02-19 19:13:08 +00:00
# This file is part of Metasm, the Ruby assembly manipulation suite
# Copyright (C) 2006-2009 Yoann GUILLOT
#
# Licence is LGPL, see LICENCE in the top-level directory
require 'test/unit'
require 'metasm'
class TestArc < Test::Unit::TestCase
2014-02-19 20:01:20 +00:00
def test_arc_dec
hex_stream = "\x0A\x23\x80\x0F\x80\x0\x60\x0D" # mov r3, 0x800D60
hex_stream += "\x40\x83" # ld_s r2, [r3, 0]
2014-02-19 19:13:08 +00:00
2014-02-19 20:01:20 +00:00
dasm = Metasm::Shellcode.disassemble(Metasm::ARC.new, hex_stream)
assert_equal(2, dasm.decoded.length)
2014-02-19 19:13:08 +00:00
2014-02-19 20:01:20 +00:00
assert_equal('mov', dasm.decoded[0].instruction.opname)
assert_equal('r3', dasm.decoded[0].instruction.args[0].to_s)
assert_equal(0x800d60, dasm.decoded[0].instruction.args[1].reduce)
2014-02-19 19:13:08 +00:00
2014-02-19 20:01:20 +00:00
assert_equal('ld_s', dasm.decoded[8].instruction.opname)
assert_equal('r2', dasm.decoded[8].instruction.args[0].to_s)
assert_equal('r3', dasm.decoded[8].instruction.args[1].base.to_s)
assert_equal(0, dasm.decoded[8].instruction.args[1].disp.reduce)
end
2014-02-19 19:13:08 +00:00
end