本文整理汇总了Python中triton.TritonContext类的典型用法代码示例。如果您正苦于以下问题:Python TritonContext类的具体用法?Python TritonContext怎么用?Python TritonContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TritonContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: TestNegativeImmediate
class TestNegativeImmediate(unittest.TestCase):
"""Testing the Immediate class."""
def setUp(self):
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
def test_value(self):
"""Check immediate value with different size."""
self.imm = Immediate(-4, CPUSIZE.BYTE)
self.assertEqual(self.imm.getValue(), 0xfc)
self.imm = Immediate(-4, CPUSIZE.WORD)
self.assertEqual(self.imm.getValue(), 0xfffc)
self.imm = Immediate(-4, CPUSIZE.DWORD)
self.assertEqual(self.imm.getValue(), 0xfffffffc)
self.imm = Immediate(-4, CPUSIZE.QWORD)
self.assertEqual(self.imm.getValue(), 0xfffffffffffffffc)
self.imm = Immediate(0x7123456789abcdef, CPUSIZE.QWORD)
self.assertEqual(self.imm.getValue(), 0x7123456789abcdef)
self.imm = Immediate(0x8123456789abcdef, CPUSIZE.QWORD)
self.assertEqual(self.imm.getValue(), 0x8123456789abcdef)
开发者ID:AmesianX,项目名称:Triton,代码行数:27,代码来源:test_immediate.py
示例2: TestImmediate64
class TestImmediate64(unittest.TestCase):
"""Testing the Immediate class."""
def setUp(self):
"""Define the arch and Immediate to test."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.imm = Immediate(0x0123456789abcdef, CPUSIZE.QWORD)
def test_bit_size(self):
"""Check the bitsize."""
self.assertEqual(self.imm.getBitSize(), 64)
def test_size(self):
"""Check the size."""
self.assertEqual(self.imm.getSize(), 8)
def test_value(self):
"""Check immediate value with different size."""
self.assertEqual(self.imm.getValue(), 0x0123456789abcdef)
def test_type(self):
"""Check immadiate type."""
self.assertEqual(self.imm.getType(), OPERAND.IMM)
开发者ID:AmesianX,项目名称:Triton,代码行数:25,代码来源:test_immediate.py
示例3: TestRAXBitvector
class TestRAXBitvector(unittest.TestCase):
"""Testing the Bitvector class."""
def setUp(self):
"""Define the arch."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.bv = self.Triton.registers.rax.getBitvector()
def test_high(self):
"""Check the highest bit."""
self.assertEqual(self.bv.getHigh(), 63)
def test_low(self):
"""Check the lower bit."""
self.assertEqual(self.bv.getLow(), 0)
def test_size(self):
"""Check the vector size."""
self.assertEqual(self.bv.getVectorSize(), 64)
def test_maxValue(self):
"""Check the max value of the vector."""
self.assertEqual(self.bv.getMaxValue(), 0xffffffffffffffff)
开发者ID:AmesianX,项目名称:Triton,代码行数:25,代码来源:test_bitvector.py
示例4: TestSymbolicEngineNoOptim
class TestSymbolicEngineNoOptim(BaseTestSimulation, unittest.TestCase):
"""Testing the symbolic emulation engine without optimization."""
def setUp(self):
"""Define the arch."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
super(TestSymbolicEngineNoOptim, self).setUp()
开发者ID:ispras,项目名称:Triton,代码行数:9,代码来源:test_simulation.py
示例5: TestArchitecture
class TestArchitecture(unittest.TestCase):
"""Testing the architectures."""
def test_modify_arch(self):
"""Check we can change arch at anytime."""
self.Triton = TritonContext()
for _ in xrange(10):
self.Triton.setArchitecture(random.choice((ARCH.X86_64, ARCH.X86)))
开发者ID:AmesianX,项目名称:Triton,代码行数:9,代码来源:test_arch.py
示例6: test_taint_set_memory
def test_taint_set_memory(self):
"""Set taint memory"""
Triton = TritonContext()
Triton.setArchitecture(ARCH.X86_64)
self.assertFalse(Triton.isMemoryTainted(0x1000))
Triton.setTaintMemory(MemoryAccess(0x1000, 1), True)
self.assertTrue(Triton.isMemoryTainted(0x1000))
Triton.setTaintMemory(MemoryAccess(0x1000, 1), False)
self.assertFalse(Triton.isMemoryTainted(0x1000))
开发者ID:ispras,项目名称:Triton,代码行数:10,代码来源:test_taint.py
示例7: test_taint_set_register
def test_taint_set_register(self):
"""Set taint register"""
Triton = TritonContext()
Triton.setArchitecture(ARCH.X86_64)
self.assertFalse(Triton.isRegisterTainted(Triton.registers.rax))
Triton.setTaintRegister(Triton.registers.rax, True)
self.assertTrue(Triton.isRegisterTainted(Triton.registers.rax))
Triton.setTaintRegister(Triton.registers.rax, False)
self.assertFalse(Triton.isRegisterTainted(Triton.registers.rax))
开发者ID:ispras,项目名称:Triton,代码行数:10,代码来源:test_taint.py
示例8: TestSymbolicEngineAligned
class TestSymbolicEngineAligned(BaseTestSimulation, unittest.TestCase):
"""Testing the symbolic emulation engine with ALIGNED_MEMORY."""
def setUp(self):
"""Define the arch and modes."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.Triton.enableMode(MODE.ALIGNED_MEMORY, True)
super(TestSymbolicEngineAligned, self).setUp()
开发者ID:ispras,项目名称:Triton,代码行数:10,代码来源:test_simulation.py
示例9: TestSymbolicEngineOnlySymbolized
class TestSymbolicEngineOnlySymbolized(BaseTestSimulation, unittest.TestCase):
"""Testing the symbolic emulation engine with ONLY_ON_SYMBOLIZED."""
def setUp(self):
"""Define the arch and modes."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.Triton.enableMode(MODE.ONLY_ON_SYMBOLIZED, True)
super(TestSymbolicEngineOnlySymbolized, self).setUp()
开发者ID:ispras,项目名称:Triton,代码行数:10,代码来源:test_simulation.py
示例10: test_taint_assignement_register_immediate
def test_taint_assignement_register_immediate(self):
"""Check tainting assignment register <- immediate."""
Triton = TritonContext()
Triton.setArchitecture(ARCH.X86_64)
self.assertFalse(Triton.isRegisterTainted(Triton.registers.rax))
Triton.taintRegister(Triton.registers.rax)
self.assertTrue(Triton.isRegisterTainted(Triton.registers.rax))
Triton.taintAssignmentRegisterImmediate(Triton.registers.rax)
self.assertFalse(Triton.isRegisterTainted(Triton.registers.rax))
开发者ID:ispras,项目名称:Triton,代码行数:11,代码来源:test_taint.py
示例11: TestSymbolicVariable
class TestSymbolicVariable(unittest.TestCase):
"""Testing symbolic variable."""
def setUp(self):
"""Define the arch."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.v0 = self.Triton.newSymbolicVariable(8)
self.v1 = self.Triton.newSymbolicVariable(16)
self.v2 = self.Triton.newSymbolicVariable(32, "test com")
def test_id(self):
"""Test IDs"""
self.assertEqual(self.v0.getId(), 0)
self.assertEqual(self.v1.getId(), 1)
self.assertEqual(self.v2.getId(), 2)
def test_kind(self):
"""Test kind"""
self.assertEqual(self.v0.getKind(), SYMEXPR.UNDEF)
self.assertEqual(self.v1.getKind(), SYMEXPR.UNDEF)
self.assertEqual(self.v2.getKind(), SYMEXPR.UNDEF)
def test_name(self):
"""Test name"""
self.assertEqual(self.v0.getName(), "SymVar_0")
self.assertEqual(self.v1.getName(), "SymVar_1")
self.assertEqual(self.v2.getName(), "SymVar_2")
def test_bitsize(self):
"""Test name"""
self.assertEqual(self.v0.getBitSize(), 8)
self.assertEqual(self.v1.getBitSize(), 16)
self.assertEqual(self.v2.getBitSize(), 32)
def test_comment(self):
"""Test comment"""
self.assertEqual(self.v0.getComment(), "")
self.assertEqual(self.v1.getComment(), "")
self.assertEqual(self.v2.getComment(), "test com")
self.v0.setComment("test v0")
self.v1.setComment("test v1")
self.assertEqual(self.v0.getComment(), "test v0")
self.assertEqual(self.v1.getComment(), "test v1")
self.assertEqual(self.v2.getComment(), "test com")
def test_str(self):
"""Test variable representation"""
self.assertEqual(str(self.v0), "SymVar_0:8")
self.assertEqual(str(self.v1), "SymVar_1:16")
self.assertEqual(str(self.v2), "SymVar_2:32")
开发者ID:AmesianX,项目名称:Triton,代码行数:54,代码来源:test_symbolic_variable.py
示例12: test_3
def test_3(self):
ctx = TritonContext()
ctx.setArchitecture(ARCH.X86_64)
inst = Instruction("\x48\x8b\x18") # mov rbx, qword ptr [rax]
self.assertTrue(ctx.processing(inst))
self.assertTrue(checkAstIntegrity(inst))
self.assertEqual(len(inst.getReadRegisters()), 1)
self.assertEqual(len(inst.getWrittenRegisters()), 2)
self.assertEqual(len(inst.getLoadAccess()), 1)
self.assertEqual(len(inst.getStoreAccess()), 0)
开发者ID:AmesianX,项目名称:Triton,代码行数:12,代码来源:test_only_symbolized_mode.py
示例13: TestIR
class TestIR(unittest.TestCase):
"""Test IR."""
def emulate(self, pc):
"""
Emulate every opcode from pc.
Process instruction until the end
"""
while pc:
# Fetch opcode
opcode = self.Triton.getConcreteMemoryAreaValue(pc, 16)
# Create the Triton instruction
instruction = Instruction()
instruction.setOpcode(opcode)
instruction.setAddress(pc)
# Process
self.assertTrue(self.Triton.processing(instruction))
# Next
pc = self.Triton.getConcreteRegisterValue(self.Triton.registers.rip)
return
def load_binary(self, filename):
"""Load in memory every opcode from an elf program."""
import lief
binary = lief.parse(filename)
phdrs = binary.segments
for phdr in phdrs:
size = phdr.physical_size
vaddr = phdr.virtual_address
self.Triton.setConcreteMemoryAreaValue(vaddr, phdr.content)
def test_ir(self):
"""Load binary, setup environment and emulate the ir test suite."""
self.Triton = TritonContext()
# Set arch
self.Triton.setArchitecture(ARCH.X86_64)
# Load the binary
binary_file = os.path.join(os.path.dirname(__file__), "misc", "ir-test-suite.bin")
self.load_binary(binary_file)
# Define a fake stack
self.Triton.setConcreteRegisterValue(self.Triton.registers.rbp, 0x7fffffff)
self.Triton.setConcreteRegisterValue(self.Triton.registers.rsp, 0x6fffffff)
self.emulate(0x40065c)
return
开发者ID:AmesianX,项目名称:Triton,代码行数:53,代码来源:test_semantics.py
示例14: TestSymbolicEngineAst
class TestSymbolicEngineAst(BaseTestSimulation, unittest.TestCase):
"""Testing the symbolic engine with AST Dictionnary."""
def setUp(self):
"""Define the arch and modes."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.Triton.enableMode(MODE.AST_DICTIONARIES, True)
super(TestSymbolicEngineAst, self).setUp()
@unittest.skip("segfault")
def test_defcamp_2015(self):
pass
开发者ID:AmesianX,项目名称:Triton,代码行数:14,代码来源:test_simulation.py
示例15: TestAstDictionaries
class TestAstDictionaries(unittest.TestCase):
"""Testing the AST_DICTIONARIES."""
def setUp(self):
"""Define the arch."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.Triton.enableMode(MODE.AST_DICTIONARIES, True)
self.astCtxt = self.Triton.getAstContext()
def test_dictionaries(self):
# d is empty
d = self.Triton.getAstDictionariesStats()
for k, v in d.items():
self.assertEqual(v, 0)
bv1 = self.astCtxt.bv(1, 8)
bv2 = self.astCtxt.bv(2, 8)
d = self.Triton.getAstDictionariesStats()
self.assertEqual(d['bv'], 2)
self.assertEqual(d['decimal'], 3)
self.assertEqual(d['allocatedDictionaries'], 5)
self.assertEqual(d['allocatedNodes'], 6)
# Same allocation
bv1 = self.astCtxt.bv(1, 8)
bv2 = self.astCtxt.bv(2, 8)
d = self.Triton.getAstDictionariesStats()
self.assertEqual(d['bv'], 2)
self.assertEqual(d['decimal'], 3)
self.assertEqual(d['allocatedDictionaries'], 5)
self.assertEqual(d['allocatedNodes'], 12)
开发者ID:AmesianX,项目名称:Triton,代码行数:35,代码来源:test_ast_dictionaries.py
示例16: test_6
def test_6(self):
ctx = TritonContext()
ctx.setArchitecture(ARCH.X86_64)
ctx.enableMode(MODE.ONLY_ON_SYMBOLIZED, True)
ctx.convertRegisterToSymbolicVariable(ctx.registers.rax)
ctx.convertMemoryToSymbolicVariable(MemoryAccess(0, CPUSIZE.QWORD))
inst = Instruction("\x48\x8b\x18") # mov rbx, qword ptr [rax]
self.assertTrue(ctx.processing(inst))
self.assertTrue(checkAstIntegrity(inst))
self.assertEqual(len(inst.getReadRegisters()), 1)
self.assertEqual(len(inst.getWrittenRegisters()), 1)
self.assertEqual(len(inst.getLoadAccess()), 1)
self.assertEqual(len(inst.getStoreAccess()), 0)
开发者ID:AmesianX,项目名称:Triton,代码行数:15,代码来源:test_only_symbolized_mode.py
示例17: setUp
def setUp(self):
"""Define the arch and modes."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.Triton.enableMode(MODE.ALIGNED_MEMORY, True)
self.Triton.enableMode(MODE.ONLY_ON_SYMBOLIZED, True)
super(TestSymbolicEngineAlignedOnlySymbolized, self).setUp()
开发者ID:ispras,项目名称:Triton,代码行数:7,代码来源:test_simulation.py
示例18: setUp
def setUp(self):
"""Define the arch and modes."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.Triton.enableMode(MODE.ALIGNED_MEMORY, True)
self.Triton.enableMode(MODE.AST_DICTIONARIES, True)
super(TestSymbolicEngineAlignedAst, self).setUp()
开发者ID:AmesianX,项目名称:Triton,代码行数:7,代码来源:test_simulation.py
示例19: test_get_concrete_register_value
def test_get_concrete_register_value(self):
global flag
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
flag = False
self.Triton.addCallback(self.cb_flag, CALLBACK.GET_CONCRETE_REGISTER_VALUE)
self.Triton.processing(Instruction("\x48\x89\xd8")) # mov rax, rbx
self.assertTrue(flag)
flag = False
self.Triton.removeCallback(self.cb_flag, CALLBACK.GET_CONCRETE_REGISTER_VALUE)
self.Triton.processing(Instruction("\x48\x89\xd8")) # mov rax, rbx
self.assertFalse(flag)
# Remove all callbacks
flag = False
self.Triton.addCallback(self.cb_flag, CALLBACK.GET_CONCRETE_REGISTER_VALUE)
self.Triton.processing(Instruction("\x48\x89\xd8")) # mov rax, rbx
self.assertTrue(flag)
flag = False
self.Triton.removeAllCallbacks()
self.Triton.processing(Instruction("\x48\x89\xd8")) # mov rax, rbx
self.assertFalse(flag)
开发者ID:AmesianX,项目名称:Triton,代码行数:25,代码来源:test_callback.py
示例20: setUp
def setUp(self):
"""Define the arch."""
self.Triton = TritonContext()
self.Triton.setArchitecture(ARCH.X86_64)
self.v0 = self.Triton.newSymbolicVariable(8)
self.v1 = self.Triton.newSymbolicVariable(16)
self.v2 = self.Triton.newSymbolicVariable(32, "test com")
开发者ID:AmesianX,项目名称:Triton,代码行数:7,代码来源:test_symbolic_variable.py
注:本文中的triton.TritonContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论