Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def lift(self):
"""
Lifts executable code to REIL
Output: generator of REIL instructions
"""
with open(self.filename,"r") as f:
f.seek(self.text_start)
content = f.read(self.text_size)
if self.get_class() == 1:
return lift.translate(content,0)
else:
return lift.translate(content,0,x86_64 = True)
def fetch_instruction(s, x86_64=False):
ip = s.ip
s.trace.append(ip)
if ip not in _translation_cache:
bs = []
for i in range(0, 128):
try:
bs.append(s.memory.read_byte(s, ip + i))
except IndexError():
break
bs = ''.join(map(lambda x: chr(x.value), bs))
for i in x86.translate(bs, ip, x86_64):
_translation_cache[i.address] = i
if ip not in _translation_cache:
raise InvalidExecution(s, ip)
i = _translation_cache[ip]
s.ip += i.size
if x86_64:
s.registers['rip'] = bv.Constant(64, s.ip)
return i
def lift(self):
"""
Lifts executable code to REIL
Output: generator of REIL instructions
"""
with open(self.filename,"r") as f:
f.seek(self.text_start)
content = f.read(self.text_size)
if self.get_class() == 1:
return lift.translate(content,0)
else:
return lift.translate(content,0,x86_64 = True)