How to use the triton.CALLBACK.GET_CONCRETE_MEMORY_VALUE function in triton

To help you get started, we’ve selected a few triton examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JonathanSalwan / Triton / src / testers / unittests / test_callback.py View on Github external
def test_method_callback_removal(self):
        # regression test for #809
        import sys
        self.Triton = TritonContext()
        self.Triton.setArchitecture(ARCH.X86_64)
        cb = self.method_callback.__func__
        cb_initial_refcnt = sys.getrefcount(cb)
        self.Triton.addCallback(self.method_callback, CALLBACK.GET_CONCRETE_MEMORY_VALUE)
        self.Triton.removeCallback(self.method_callback, CALLBACK.GET_CONCRETE_MEMORY_VALUE)
        self.assertTrue(cb_initial_refcnt == sys.getrefcount(cb))
github JonathanSalwan / Triton / src / testers / unittests / test_callback.py View on Github external
def test_get_concrete_memory_value(self):
        global flag
        self.Triton = TritonContext()
        self.Triton.setArchitecture(ARCH.X86_64)

        flag = False
        self.Triton.addCallback(self.cb_flag, CALLBACK.GET_CONCRETE_MEMORY_VALUE)
        # movabs rax, qword ptr [0x1000]
        self.Triton.processing(Instruction(b"\x48\xa1\x00\x10\x00\x00\x00\x00\x00\x00"))
        self.assertTrue(flag)

        flag = False
        self.Triton.removeCallback(self.cb_flag, CALLBACK.GET_CONCRETE_MEMORY_VALUE)
        # movabs rax, qword ptr [0x1000]
        self.Triton.processing(Instruction(b"\x48\xa1\x00\x10\x00\x00\x00\x00\x00\x00"))
        self.assertFalse(flag)
github JonathanSalwan / Triton / src / examples / pin / callback_concrete_needs.py View on Github external
print('Processing instruction at', inst, '\n')
    return

def reg_hit(ctxt, reg):
    print('Need concrete register value:', reg)
    return

def mem_hit(ctxt, mem):
    print('Need concrete memory value:', mem)
    return

if __name__ == '__main__':
    # Start JIT at the entry point
    startAnalysisFromEntry()

    getTritonContext().addCallback(mem_hit, CALLBACK.GET_CONCRETE_MEMORY_VALUE)
    getTritonContext().addCallback(reg_hit, CALLBACK.GET_CONCRETE_REGISTER_VALUE)

    # Add callback
    insertCall(mycb, INSERT_POINT.BEFORE)

    # Run Program
    runProgram()
github radareorg / radare2-extras / pimp / pimp.py View on Github external
def reset(self):
        triton.resetEngines()
        triton.clearPathConstraints()
        triton.setArchitecture(self.arch)

        triton.enableMode(triton.MODE.ALIGNED_MEMORY, True)
        triton.enableMode(triton.MODE.ONLY_ON_SYMBOLIZED, True)

        triton.addCallback(self.memoryCaching,
                           triton.CALLBACK.GET_CONCRETE_MEMORY_VALUE)
        triton.addCallback(self.constantFolding,
                           triton.CALLBACK.SYMBOLIC_SIMPLIFICATION)

        for r in self.regs:
            if r in self.triton_regs:
                triton.setConcreteRegisterValue(
                    triton.Register(self.triton_regs[r], self.regs[r] & ((1 << self.triton_regs[r].getBitSize()) - 1))
                )

        for m in cache:
            self.write_mem(m['start'], m["data"])

        for address in self.inputs:
                self.inputs[address] = triton.convertMemoryToSymbolicVariable(
                    triton.MemoryAccess(
                        address,
github kamou / pimp / pimp.py View on Github external
def reset(self):
        self.triton.reset()
        self.triton.clearPathConstraints()
        self.triton.setArchitecture(self.arch)

        self.triton.enableMode(triton.MODE.ALIGNED_MEMORY, True)
        self.triton.enableMode(triton.MODE.ONLY_ON_SYMBOLIZED, True)

        self.triton.addCallback(self.memoryCaching,
                           triton.CALLBACK.GET_CONCRETE_MEMORY_VALUE)
        self.triton.addCallback(self.constantFolding,
                           triton.CALLBACK.SYMBOLIC_SIMPLIFICATION)

        for r in self.triton_regs:
            if r in self.regs:
                self.triton.setConcreteRegisterValue(
                    self.triton_regs[r], self.regs[r] & 0xffffffffffffffff
                )

        for m in cache:
            self.write_mem(m['start'], m["data"])

        for address in self.inputs:
                self.inputs[address] = self.triton.convertMemoryToSymbolicVariable(
                    triton.MemoryAccess(
                        address,
github JonathanSalwan / Triton / src / examples / python / ctf-writeups / defcon-2016-baby-re / solve.py View on Github external
def initialize():

    Triton = TritonContext()
    # Define the target architecture
    Triton.setArchitecture(ARCH.X86_64)

    # Define symbolic optimizations
    Triton.enableMode(MODE.ALIGNED_MEMORY, True)
    Triton.enableMode(MODE.ONLY_ON_SYMBOLIZED, True)

    # Define internal callbacks.
    Triton.addCallback(memoryCaching,   CALLBACK.GET_CONCRETE_MEMORY_VALUE)
    Triton.addCallback(constantFolding, CALLBACK.SYMBOLIC_SIMPLIFICATION)

    # Load the meory dump
    load_dump(Triton, os.path.join(os.path.dirname(__file__), "baby-re.dump"))

    # Symbolize user inputs
    symbolizeInputs(Triton)

    return Triton