本文整理汇总了Python中triton.TritonContext.enableSymbolicEngine方法的典型用法代码示例。如果您正苦于以下问题:Python TritonContext.enableSymbolicEngine方法的具体用法?Python TritonContext.enableSymbolicEngine怎么用?Python TritonContext.enableSymbolicEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类triton.TritonContext
的用法示例。
在下文中一共展示了TritonContext.enableSymbolicEngine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestSymbolicEngineDisable
# 需要导入模块: from triton import TritonContext [as 别名]
# 或者: from triton.TritonContext import enableSymbolicEngine [as 别名]
class TestSymbolicEngineDisable(BaseTestSimulation, unittest.TestCase):
"""Testing the emulation with the symbolic engine disabled."""
def setUp(self):
"""Define the arch and modes."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.Triton.enableSymbolicEngine(False)
super(TestSymbolicEngineDisable, self).setUp()
@unittest.skip("Not possible")
def test_seed_coverage(self):
pass
@unittest.skip("Not possible")
def test_defcamp_2015(self):
pass
示例2: TestSymbolic
# 需要导入模块: from triton import TritonContext [as 别名]
# 或者: from triton.TritonContext import enableSymbolicEngine [as 别名]
class TestSymbolic(unittest.TestCase):
"""Testing the symbolic engine."""
def setUp(self):
"""Define the arch."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.astCtxt = self.Triton.getAstContext()
def test_backup(self):
"""
Check Symbolics value are saved when engine is disable.
* Also check reseting a disable symbolic engines doesn't crash.
"""
inst = Instruction()
# update RAX
inst.setOpcode("\x48\xFF\xC0")
self.Triton.processing(inst)
self.assertEqual(self.Triton.getSymbolicRegisterValue(self.Triton.registers.rax), 1)
# This call triton::api.backupSymbolicEngine()
self.Triton.enableSymbolicEngine(False)
inst = Instruction()
# update RAX again
inst.setOpcode("\x48\xFF\xC0")
self.Triton.processing(inst)
self.assertEqual(self.Triton.getConcreteRegisterValue(self.Triton.registers.rax), 2, "concrete value is updated")
self.assertEqual(self.Triton.getSymbolicRegisterValue(self.Triton.registers.rax), 1)
self.assertEqual(self.Triton.getSymbolicRegisterValue(self.Triton.registers.rax), 1, "Symbolic value is not update")
# Try to reset engine after a backup to test if the bug #385 is fixed.
self.Triton.resetEngines()
def test_bind_expr_to_memory(self):
"""Check symbolic expression binded to memory can be retrieve."""
# Bind expr1 to 0x100
expr1 = self.Triton.newSymbolicExpression(self.astCtxt.bv(0x11, 8))
mem = MemoryAccess(0x100, CPUSIZE.BYTE)
self.Triton.assignSymbolicExpressionToMemory(expr1, mem)
# Get expr from memory
expr2 = self.Triton.getSymbolicExpressionFromId(self.Triton.getSymbolicMemoryId(0x100))
self.assertEqual(expr1.getAst().evaluate(), expr2.getAst().evaluate())
def test_bind_expr_to_multi_memory(self):
"""Check symbolic expression binded to multiple memory location."""
# Bind expr to multi memory location (0x100, 0x101, 0x102, 0x103)
expr1 = self.Triton.newSymbolicExpression(self.astCtxt.bv(0x11223344, 32))
mem = MemoryAccess(0x100, CPUSIZE.DWORD)
self.Triton.assignSymbolicExpressionToMemory(expr1, mem)
# Check we can get back the same values
expr2 = self.Triton.getSymbolicExpressionFromId(self.Triton.getSymbolicMemoryId(0x100))
expr3 = self.Triton.getSymbolicExpressionFromId(self.Triton.getSymbolicMemoryId(0x101))
expr4 = self.Triton.getSymbolicExpressionFromId(self.Triton.getSymbolicMemoryId(0x102))
expr5 = self.Triton.getSymbolicExpressionFromId(self.Triton.getSymbolicMemoryId(0x103))
self.assertEqual(expr2.getAst().evaluate(), 0x44)
self.assertEqual(expr3.getAst().evaluate(), 0x33)
self.assertEqual(expr4.getAst().evaluate(), 0x22)
self.assertEqual(expr5.getAst().evaluate(), 0x11)
self.assertEqual(self.Triton.getSymbolicMemoryValue(mem), 0x11223344)
def test_bind_expr_to_register(self):
"""Check symbolic expression binded to register."""
expr1 = self.Triton.newSymbolicExpression(self.astCtxt.bv(0x11223344, 64))
self.Triton.assignSymbolicExpressionToRegister(expr1, self.Triton.registers.rax)
self.assertEqual(self.Triton.getSymbolicRegisterValue(self.Triton.registers.rax), 0x11223344)
expr1 = self.Triton.newSymbolicExpression(self.astCtxt.bv(0x11223344, 32))
with self.assertRaises(Exception):
# Incorrect size
self.Triton.assignSymbolicExpressionToRegister(expr1, self.Triton.registers.rax)