Skip to content

Instantly share code, notes, and snippets.

@extremecoders-re
Created March 9, 2016 06:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save extremecoders-re/07b102ca4434cc08161d to your computer and use it in GitHub Desktop.
Save extremecoders-re/07b102ca4434cc08161d to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from z3 import *
# Declare a 32 bit verctor representing register eax
reg_eax = BitVec('eax', 32)
# add eax, 0xDEADBEEF
eax = reg_eax + 0xDEADBEEF
# xor eax, 0x1337
eax = eax ^ 0x1337
# shr eax, 0x3
eax = eax >> 0x3
# Create a solver instance
s = Solver()
# Add the constraint
s.add(eax == 0x31337)
# Check if satisfied
if s.check() == sat:
# Print value
print hex(s.model()[reg_eax].as_long())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment