Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SET_CONCRETE_MEMORY_VALUE callback invoked when performing symbolic memory read in MEMORY_ARRAY mode #1352

Open
0x9047 opened this issue Aug 21, 2024 · 0 comments

Comments

@0x9047
Copy link
Contributor

0x9047 commented Aug 21, 2024

import triton


def test_concrete_memory_handler_not_called_in_symbolic_rw():
    def handler(ctx, memory_access, *args):
        assert not memory_access.getLeaAst().isSymbolized()

    ctx = triton.TritonContext(triton.ARCH.AARCH64)
    ctx.setMode(triton.MODE.MEMORY_ARRAY, True)
    ctx.symbolizeRegister(ctx.registers.sp)
    ctx.setMode(triton.MODE.SYMBOLIZE_LOAD, True)
    ctx.setMode(triton.MODE.SYMBOLIZE_STORE, True)
    ctx.addCallback(triton.CALLBACK.GET_CONCRETE_MEMORY_VALUE, handler)
    ctx.addCallback(triton.CALLBACK.SET_CONCRETE_MEMORY_VALUE, handler)

    inst = triton.Instruction(0, bytes.fromhex("E00300F9"))  # str x0, [sp, #0]
    ctx.processing(inst)

Output

ctx = <TritonContext object at 0x10214b570>, memory_access = [@0x0]:64 bv[63..0], args = (0,), @py_assert1 = <built-in method getLeaAst of MemoryAccess object at 0x1024e59d0>
@py_assert3 = (bvadd (bvadd ref!0 (bvmul (_ bv0 64) (_ bv0 64))) (_ bv0 64)), @py_assert5 = <built-in method isSymbolized of AstNode object at 0x1024e5a10>

    def handler(ctx, memory_access, *args):
>       assert not memory_access.getLeaAst().isSymbolized()
E       assert not True
E        +  where True = <built-in method isSymbolized of AstNode object at 0x1024e5a10>()
E        +    where <built-in method isSymbolized of AstNode object at 0x1024e5a10> = (bvadd (bvadd ref!0 (bvmul (_ bv0 64) (_ bv0 64))) (_ bv0 64)).isSymbolized
E        +      where (bvadd (bvadd ref!0 (bvmul (_ bv0 64) (_ bv0 64))) (_ bv0 64)) = <built-in method getLeaAst of MemoryAccess object at 0x1024e59d0>()
E        +        where <built-in method getLeaAst of MemoryAccess object at 0x1024e59d0> = [@0x0]:64 bv[63..0].getLeaAst`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant