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
SMT Array #806
Comments
Note for myself. I still have to do:
Below a poc: ## Result:
## {0: SymVar_0:64 = 0x100}
from triton import *
ctx = TritonContext()
ctx.setArchitecture(ARCH.X86_64)
ctx.enableMode(MODE.SYMBOLIC_LOAD, True)
ctx.enableMode(MODE.SYMBOLIC_STORE, True)
ctx.enableMode(MODE.AST_OPTIMIZATIONS, True)
code = [
b"\x48\xc7\xc7\x00\x01\x00\x00", # mov rdi, 0x100
b"\x48\x89\xf1", # mov rcx, rsi
b"\x48\xc7\xc0\x03\x00\x00\x00", # mov rax, 3
b"\x48\x89\x07", # mov [rdi], rax
b"\x48\x8b\x11", # mov rdx, [rcx]
]
ctx.convertRegisterToSymbolicVariable(ctx.registers.rsi)
for op in code:
inst = Instruction(op)
ctx.processing(inst)
print(inst)
for se in inst.getSymbolicExpressions():
print('\t %s' %(str(se)))
print()
ast = ctx.getAstContext()
rdx = ctx.getSymbolicRegister(ctx.registers.rdx).getAst()
m = ctx.getModel(rdx == 0x3)
print(m) |
Could be easy to add concretization policies on a static IR (#473) |
Hey Jonathan! Any update on this issue? Thanks! |
@JonathanSalwan, could you write some points that you discovered during brainstorming? Will SMT Array affect a memory model? SMT Array are useful for reversing and verification stuff (I personally verified ROP gadgets with them). However, I consider them too slow for DSE. |
No.
100% agree with that.
For the moment, I'm only adding
So, I will not modify >>> from triton import *
>>> ctx = TritonContext(ARCH.X86_64)
>>> ast = ctx.getAstContext()
>>> var = ast.variable(ctx.newSymbolicVariable(64, 'index'))
>>> mem = ast.array(64) # 64 is the indexing size of the array
>>> # Storing 0xcc at a symbolic index + 1
>>> mem = ast.store(mem, var + 1, ast.bv(0xcc, 8))
>>> # Selecting a node at a constant address 0xdead
>>> node = ast.select(mem, 0xdead)
>>> # Asking a model to get the 0xcc constant.
>>> model = ctx.getModel(node == 0xcc)
>>> print(model)
{0: index:64 = 0xdeac} We can also lift >>> print(ctx.liftToLLVM(node))
; ModuleID = 'tritonModule'
source_filename = "tritonModule"
define i8 @__triton(i64 %SymVar_0) {
entry:
%0 = add i64 %SymVar_0, 1
%1 = inttoptr i64 %0 to i8*
store i8 -52, i8* %1, align 1
%2 = load i8, i8* inttoptr (i64 57005 to i8*), align 1
ret i8 %2
} Or lifting them to z3 and back: >>> z3n = ast.tritonToZ3(node)
>>> print(z3n)
Store(K(BitVec(64), 0), SymVar_0 + 1, 204)[57005]
>>> ast.z3ToTriton(z3n)
(select (store Memory (bvadd index (_ bv1 64)) (_ bv204 8)) (_ bv57005 64)) That's all for the moment. (1): Once the support of the ABV logic will be reliable (as axiomatic nodes) we can start brainstorming all together about how we can support it during a DSE. For example, if we add options to symbolize LOAD, to symbolize STORE or both. How we will declare arrays, do we symbolize stack, symbolize heap, all memory? Its cells size, 8, 16, 32 or 64 bits? etc. |
#723
The text was updated successfully, but these errors were encountered: