Skip to content

Commit 474fe24

Browse files
Lots of fixs, features and improvements
[Bindings] New ast attribute into the SymExpression class (Based on #94) [Bindings] New class SmtAstAbstractNode (Based on #94) [Bindings] New getFullExpression(node) function (Based on #94) [Bindings] New smt2lib string function (Based on #94) [Bindings] Remove the display syntax function [Bindings] Remove the expression attribute from the SymExpression class (Based on #94) [Bindings] Remove the getBacktrackedSymExpr function (Based on #94 and #95) [Bindings] Remove the saveTrace feature [Bindings] Remove the simplify syntax function [Bindings] Update the Sx and Zx functions takes the sizeExt as first argument [Bindings] Update the create{Reg,Sym,Expr}ToSymVar() functions take a varSize as bits granularity (#125) [Bindings] Update the extract function takes now only one convention [Core] Replace the string manipulation to an AST for all SMT expressions (#94) [Semantics] Modification of the PF expression (#124) [SymEngine] Mofification of the SymbolicExpression class (Based on #94) [SymEngine] Reduce the time of the SMT reconstruction (#95) [SymExpression] Remove the dst attribute (Based on #94) [SymExpression] Remove the source attribute (Based on #94)
1 parent c0f81c2 commit 474fe24

157 files changed

Lines changed: 6341 additions & 4618 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.build_number

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
628
1+
633

examples/callback_after.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def my_callback_after(instruction):
152152
print '%#x: %s' %(instruction.address, instruction.assembly)
153153

154154
for se in instruction.symbolicExpressions:
155-
print '\t -> %s %s' %(se.expression, (('; ' + se.comment) if se.comment is not None else ''))
155+
print '\t -> #%d = %s %s' %(se.id, se.ast, (('; ' + se.comment) if se.comment is not None else ''))
156156

157157
print
158158

examples/callback_before.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# TID (0) 0x400597 mov ecx, eax
2323
# TID (0) 0x400599 mov rdx, qword ptr [rip+0x200aa0]
2424
# TID (0) 0x4005a0 mov eax, dword ptr [rbp-0x4]
25-
# TID (0) 0x4005a3 cdqe
25+
# TID (0) 0x4005a3 cdqe
2626
# TID (0) 0x4005a5 add rax, rdx
2727
# TID (0) 0x4005a8 movzx eax, byte ptr [rax]
2828
# TID (0) 0x4005ab movsx eax, al

examples/callback_signals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def signals(threadId, sig):
5858
for reg, data in regs.items():
5959
value = data['concreteValue']
6060
seid = data['symbolicExpr']
61-
print '%s:\t%#016x\t%s' %(getRegName(reg), value, (getSymExpr(seid).expression if seid != IDREF.MISC.UNSET else 'UNSET'))
61+
print '%s:\t%#016x\t%s' %(getRegName(reg), value, (getSymExpr(seid).ast if seid != IDREF.MISC.UNSET else 'UNSET'))
6262
return
6363

6464

examples/crackme_hash_collision.py

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,45 +51,29 @@ def cafter(instruction):
5151
# RAX points on the user password
5252
if instruction.address == 0x400572:
5353
rsiId = getRegSymbolicID(IDREF.REG.RSI)
54-
convertExprToSymVar(rsiId, 8)
54+
convertExprToSymVar(rsiId, 64)
5555

5656
# mov eax,DWORD PTR [rbp-0x4]
5757
# RAX must be equal to 0xad6d to win
5858
if instruction.address == 0x4005c5:
5959
print '[+] Please wait, computing in progress...'
6060
raxId = getRegSymbolicID(IDREF.REG.RAX)
61-
raxExpr = getBacktrackedSymExpr(raxId)
62-
expr = str()
61+
raxExpr = getFullExpression(getSymExpr(raxId).ast)
6362

6463
# We want printable characters
65-
# (assert (bvsgt SymVar_0 96)
66-
# (assert (bvslt SymVar_0 123)
67-
expr += smt2lib.smtAssert(smt2lib.bvugt('SymVar_0', smt2lib.bv(96, 64)))
68-
expr += smt2lib.smtAssert(smt2lib.bvult('SymVar_0', smt2lib.bv(123, 64)))
69-
70-
# (assert (bvsgt SymVar_1 96)
71-
# (assert (bvslt SymVar_1 123)
72-
expr += smt2lib.smtAssert(smt2lib.bvugt('SymVar_1', smt2lib.bv(96, 64)))
73-
expr += smt2lib.smtAssert(smt2lib.bvult('SymVar_1', smt2lib.bv(123, 64)))
74-
75-
# (assert (bvsgt SymVar_2 96)
76-
# (assert (bvslt SymVar_2 123)
77-
expr += smt2lib.smtAssert(smt2lib.bvugt('SymVar_2', smt2lib.bv(96, 64)))
78-
expr += smt2lib.smtAssert(smt2lib.bvult('SymVar_2', smt2lib.bv(123, 64)))
79-
80-
# (assert (bvsgt SymVar_3 96)
81-
# (assert (bvslt SymVar_3 123)
82-
expr += smt2lib.smtAssert(smt2lib.bvugt('SymVar_3', smt2lib.bv(96, 64)))
83-
expr += smt2lib.smtAssert(smt2lib.bvult('SymVar_3', smt2lib.bv(123, 64)))
84-
85-
# (assert (bvsgt SymVar_4 96)
86-
# (assert (bvslt SymVar_4 123)
87-
expr += smt2lib.smtAssert(smt2lib.bvugt('SymVar_4', smt2lib.bv(96, 64)))
88-
expr += smt2lib.smtAssert(smt2lib.bvult('SymVar_4', smt2lib.bv(123, 64)))
89-
90-
# We want the collision
91-
# (assert (= rax 0xad6d)
92-
expr += smt2lib.smtAssert(smt2lib.equal(raxExpr, smt2lib.bv(0xad6d, 64)))
64+
expr = smt2lib.compound([
65+
smt2lib.smtAssert(smt2lib.bvugt(smt2lib.string('SymVar_0'), smt2lib.bv(96, 64))),
66+
smt2lib.smtAssert(smt2lib.bvult(smt2lib.string('SymVar_0'), smt2lib.bv(123, 64))),
67+
smt2lib.smtAssert(smt2lib.bvugt(smt2lib.string('SymVar_1'), smt2lib.bv(96, 64))),
68+
smt2lib.smtAssert(smt2lib.bvult(smt2lib.string('SymVar_1'), smt2lib.bv(123, 64))),
69+
smt2lib.smtAssert(smt2lib.bvugt(smt2lib.string('SymVar_2'), smt2lib.bv(96, 64))),
70+
smt2lib.smtAssert(smt2lib.bvult(smt2lib.string('SymVar_2'), smt2lib.bv(123, 64))),
71+
smt2lib.smtAssert(smt2lib.bvugt(smt2lib.string('SymVar_3'), smt2lib.bv(96, 64))),
72+
smt2lib.smtAssert(smt2lib.bvult(smt2lib.string('SymVar_3'), smt2lib.bv(123, 64))),
73+
smt2lib.smtAssert(smt2lib.bvugt(smt2lib.string('SymVar_4'), smt2lib.bv(96, 64))),
74+
smt2lib.smtAssert(smt2lib.bvult(smt2lib.string('SymVar_4'), smt2lib.bv(123, 64))),
75+
smt2lib.smtAssert(smt2lib.equal(raxExpr, smt2lib.bv(0xad6d, 64))) # collision: (assert (= rax 0xad6d)
76+
])
9377

9478
# Get max 20 different models
9579
models = getModels(expr, 20)

examples/get_model.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/inject_model_with_snapshot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ def cafter(instruction):
4545

4646
# 0x40058b: movzx eax, byte ptr [rax]
4747
if instruction.address == 0x40058b:
48-
convertRegToSymVar(IDREF.REG.RAX, 4)
48+
convertRegToSymVar(IDREF.REG.RAX, 32)
4949

5050
# 0x4005ae: cmp ecx, eax
5151
if instruction.address == 0x4005ae:
5252
zfId = getRegSymbolicID(IDREF.FLAG.ZF)
53-
zfExpr = getBacktrackedSymExpr(zfId)
53+
zfExpr = getFullExpression(getSymExpr(zfId).ast)
5454
expr = smt2lib.smtAssert(smt2lib.equal(zfExpr, smt2lib.bvtrue())) # (assert (= zf True))
5555
models = getModel(expr)
5656
global password

examples/taint_runtime_memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def cafter(instruction):
1919
print '%#x: %s' %(instruction.address, instruction.assembly)
2020
for se in instruction.symbolicExpressions:
2121
if se.isTainted == True:
22-
print '\t -> %s%s%s' %(GREEN, se.expression, ENDC)
22+
print '\t -> %s%s%s' %(GREEN, se.ast, ENDC)
2323
else:
24-
print '\t -> %s' %(se.expression)
24+
print '\t -> %s' %(se.ast)
2525
print
2626

2727

0 commit comments

Comments
 (0)