当前位置: 首页>>代码示例>>Python>>正文


Python Instruction.getOperands方法代码示例

本文整理汇总了Python中triton.Instruction.getOperands方法的典型用法代码示例。如果您正苦于以下问题:Python Instruction.getOperands方法的具体用法?Python Instruction.getOperands怎么用?Python Instruction.getOperands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在triton.Instruction的用法示例。


在下文中一共展示了Instruction.getOperands方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_7

# 需要导入模块: from triton import Instruction [as 别名]
# 或者: from triton.Instruction import getOperands [as 别名]
    def test_7(self):
        ctx = TritonContext()
        ctx.setArchitecture(ARCH.X86_64)
        ctx.enableMode(MODE.ONLY_ON_SYMBOLIZED, True)
        ctx.setConcreteRegisterValue(ctx.registers.rax, 0x1337)

        inst = Instruction("\x48\x8b\x18") # mov rbx, qword ptr [rax]
        self.assertTrue(ctx.processing(inst))
        self.assertTrue(checkAstIntegrity(inst))

        self.assertEqual(inst.getOperands()[1].getAddress(), 0x1337)
        self.assertIsNone(inst.getOperands()[1].getLeaAst())
开发者ID:AmesianX,项目名称:Triton,代码行数:14,代码来源:test_only_symbolized_mode.py

示例2: test_pop_esp

# 需要导入模块: from triton import Instruction [as 别名]
# 或者: from triton.Instruction import getOperands [as 别名]
    def test_pop_esp(self):
        """Check pop on esp processing."""
        setArchitecture(ARCH.X86)

        # mov esp, 0x19fe00
        inst1 = Instruction('\xBC\x00\xFE\x19\x00')
        # mov dword ptr [esp], 0x11111111
        inst2 = Instruction('\xC7\x04\x24\x11\x11\x11\x11')
        # pop dword ptr [esp]
        inst3 = Instruction('\x8F\x04\x24')
        processing(inst1)
        processing(inst2)
        processing(inst3)

        self.assertEqual(inst3.getOperands()[0].getAddress(), 0x19fe04, "esp has been poped")
        self.assertEqual(inst3.getOperands()[0].getConcreteValue(), 0x11111111, "new value is still 0x11111111")
        self.assertEqual(inst3.getStoreAccess()[0][0].getAddress(), 0x19fe04, "inst3 set the value in 0x19fe04")
        self.assertEqual(inst3.getStoreAccess()[0][1].evaluate(), 0x11111111, "And this value is 0x11111111")
开发者ID:Manouchehri,项目名称:Triton,代码行数:20,代码来源:test_instruction.py

示例3: test_load_ds

# 需要导入模块: from triton import Instruction [as 别名]
# 或者: from triton.Instruction import getOperands [as 别名]
    def test_load_ds(self):
        """Check load from ds segment."""
        setArchitecture(ARCH.X86)

        inst = Instruction()
        # mov ax, ds:word_40213C
        inst.setOpcodes("\x66\xA1\x3C\x21\x40\x00")
        processing(inst)

        self.assertEqual(inst.getOperands()[1].getAddress(), 0x40213C)
        self.assertEqual(inst.getOperands()[1].getBitSize(), 16)
开发者ID:Manouchehri,项目名称:Triton,代码行数:13,代码来源:test_instruction.py

示例4: test_pop

# 需要导入模块: from triton import Instruction [as 别名]
# 或者: from triton.Instruction import getOperands [as 别名]
    def test_pop(self):
        """Check the pop instruction processing."""
        setArchitecture(ARCH.X86)

        # mov esp, 0x19fe00
        inst1 = Instruction('\xBC\x00\xFE\x19\x00')
        # mov edi, 0x19fe00
        inst2 = Instruction('\xBF\x00\xFE\x19\x00')
        # mov dword ptr [esp], 0x11111111
        inst3 = Instruction('\xC7\x04\x24\x11\x11\x11\x11')
        # pop dword ptr [edi]
        inst4 = Instruction('\x8F\x07')
        processing(inst1)
        processing(inst2)
        processing(inst3)
        processing(inst4)

        self.assertEqual(inst4.getOperands()[0].getAddress(), 0x19fe00, "poping edi doesn't change it")
        self.assertEqual(inst4.getOperands()[0].getConcreteValue(), 0x11111111, "pointed value in edi is the previously pointed value by esp")
        self.assertEqual(inst4.getStoreAccess()[0][0].getAddress(), 0x19fe00, "inst4 store the new value in 0x19fe00 (edi value)")
        self.assertEqual(inst4.getStoreAccess()[0][1].evaluate(), 0x11111111, "The stored value is 0x11111111")
开发者ID:Manouchehri,项目名称:Triton,代码行数:23,代码来源:test_instruction.py

示例5: TestInstruction

# 需要导入模块: from triton import Instruction [as 别名]
# 或者: from triton.Instruction import getOperands [as 别名]
class TestInstruction(unittest.TestCase):

    """Testing the Instruction class."""

    def setUp(self):
        """Define and process the instruction to test."""
        self.Triton = TritonContext()
        self.Triton.setArchitecture(ARCH.X86_64)
        self.inst = Instruction()
        self.inst.setOpcode("\x48\x01\xd8")  # add rax, rbx
        self.inst.setAddress(0x400000)
        self.Triton.setConcreteRegisterValue(self.Triton.registers.rax, 0x1122334455667788)
        self.Triton.setConcreteRegisterValue(self.Triton.registers.rbx, 0x8877665544332211)
        self.Triton.processing(self.inst)

    def test_address(self):
        """Check instruction current and next address."""
        self.assertEqual(self.inst.getAddress(), 0x400000)
        self.assertEqual(self.inst.getNextAddress(), 0x400003)

    def test_memory(self):
        """Check memory access."""
        self.assertListEqual(self.inst.getLoadAccess(), [])
        self.assertListEqual(self.inst.getStoreAccess(), [])
        self.assertFalse(self.inst.isMemoryWrite())
        self.assertFalse(self.inst.isMemoryRead())

    def test_registers(self):
        """Check register access."""
        self.assertEqual(len(self.inst.getReadRegisters()), 2, "access RAX and RBX")
        self.assertEqual(len(self.inst.getWrittenRegisters()), 8, "write in RAX, RIP, AF, XF, OF, PF, SF and ZF")

    def test_taints(self):
        """Check taints attributes."""
        self.assertFalse(self.inst.isTainted())

    def test_prefix(self):
        """Check prefix data."""
        self.assertFalse(self.inst.isPrefixed())
        self.assertEqual(self.inst.getPrefix(), PREFIX.INVALID)

    def test_control_flow(self):
        """Check control flow flags."""
        self.assertFalse(self.inst.isControlFlow(), "It is not a jmp, ret or call")
        self.assertFalse(self.inst.isBranch(), "It is not a jmp")

    def test_condition(self):
        """Check condition flags."""
        self.assertFalse(self.inst.isConditionTaken())

    def test_opcode(self):
        """Check opcode informations."""
        self.assertEqual(self.inst.getOpcode(), "\x48\x01\xd8")
        self.assertEqual(self.inst.getType(), OPCODE.ADD)

    def test_thread(self):
        """Check threads information."""
        self.assertEqual(self.inst.getThreadId(), 0)

    def test_operand(self):
        """Check operand information."""
        self.assertEqual(len(self.inst.getOperands()), 2)
        self.assertEqual(self.inst.getOperands()[0].getName(), "rax")
        self.assertEqual(self.inst.getOperands()[1].getName(), "rbx")
        with self.assertRaises(Exception):
            self.inst.getOperands()[2]

    def test_symbolic(self):
        """Check symbolic information."""
        self.assertEqual(len(self.inst.getSymbolicExpressions()), 8)

    def test_size(self):
        """Check size information."""
        self.assertEqual(self.inst.getSize(), 3)

    def test_disassembly(self):
        """Check disassembly equivalent."""
        self.assertEqual(self.inst.getDisassembly(), "add rax, rbx")
开发者ID:AmesianX,项目名称:Triton,代码行数:80,代码来源:test_instruction.py

示例6:

# 需要导入模块: from triton import Instruction [as 别名]
# 或者: from triton.Instruction import getOperands [as 别名]
        # Setup opcode
        inst.setOpcode(opcode)

        # Setup Address
        inst.setAddress(addr)

        # Process everything
        Triton.processing(inst)

        # Display instruction
        print inst
        print '    ---------------'
        print '    Is memory read :', inst.isMemoryRead()
        print '    Is memory write:', inst.isMemoryWrite()
        print '    ---------------'
        for op in inst.getOperands():
            print '    Operand:', op
            if op.getType() == OPERAND.MEM:
                print '    - segment :', op.getSegmentRegister()
                print '    - base    :', op.getBaseRegister()
                print '    - index   :', op.getIndexRegister()
                print '    - scale   :', op.getScale()
                print '    - disp    :', op.getDisplacement()
            print '    ---------------'

        print

    sys.exit(0)

开发者ID:AmesianX,项目名称:Triton,代码行数:30,代码来源:disass.py

示例7: hex

# 需要导入模块: from triton import Instruction [as 别名]
# 或者: from triton.Instruction import getOperands [as 别名]
        # Process everything
        Triton.processing(inst)

        # Display instruction
        print inst

        # Display symbolic expressions
        for expr in inst.getSymbolicExpressions():
            print '\t', expr

        print


    print 'Display emulated information'
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    write = inst.getOperands()[0].getAddress()
    print 'Instruction :', inst.getDisassembly()
    print 'Write at    :', hex(write)
    print 'Content     :', hex(Triton.getConcreteMemoryValue(MemoryAccess(write+4, CPUSIZE.DWORD)))
    print 'RAX value   :', hex(Triton.getConcreteRegisterValue(Triton.registers.rax))
    print 'RSI value   :', hex(Triton.getConcreteRegisterValue(Triton.registers.rsi))
    print 'RDI value   :', hex(Triton.getConcreteRegisterValue(Triton.registers.rdi))


    print
    print 'Symbolic registers information'
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    for k, v in Triton.getSymbolicRegisters().items():
        print Triton.getRegister(k), v

    print
开发者ID:ispras,项目名称:Triton,代码行数:33,代码来源:symbolic_emulation_1.py


注:本文中的triton.Instruction.getOperands方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。