Replace jitter.run boolean by jitter.running

This commit is contained in:
Romain Lesteven 2021-05-05 11:02:33 +02:00
parent acfb6e552b
commit e0abd462ce
21 changed files with 28 additions and 28 deletions

View file

@ -223,7 +223,7 @@ Create a sentinelle to catch the return of the shellcode:
```Python
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
jitter.pc = 0
return True

View file

@ -31,7 +31,7 @@ parser.add_argument("addr",
machine = Machine("mips32l")
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
jitter.pc = 0
return True

View file

@ -20,4 +20,4 @@ log_func.setLevel(logging.ERROR)
# Run
sb.run()
assert(sb.jitter.run is False)
assert(sb.jitter.running is False)

View file

@ -15,4 +15,4 @@ sb = Sandbox_Win_x86_32(loc_db, options.filename, options, globals())
# Run
sb.run()
assert(sb.jitter.run is False)
assert(sb.jitter.running is False)

View file

@ -16,4 +16,4 @@ sb = Sandbox_Win_x86_64(loc_db, options.filename, options, globals())
# Run
sb.run()
assert(sb.jitter.run is False)
assert(sb.jitter.running is False)

View file

@ -59,4 +59,4 @@ sb.jitter.add_breakpoint(win_api_x86_32_seh.return_from_exception, return_from_s
# Run
sb.run()
assert(sb.jitter.run is False)
assert(sb.jitter.running is False)

View file

@ -58,5 +58,5 @@ start_time = time.time()
sb.run()
stop_time = time.time()
assert sb.jitter.run is False
assert sb.jitter.running is False
print("Instr speed: %02.f / sec" % (instr_count / (stop_time - start_time)))

View file

@ -84,7 +84,7 @@ def stop(jitter):
logging.info('OEP reached')
# Stop execution
jitter.run = False
jitter.running = False
return False
# Set callbacks

View file

@ -13,7 +13,7 @@ parser.add_argument("-j", "--jitter",
args = parser.parse_args()
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
jitter.pc = 0
return True

View file

@ -34,7 +34,7 @@ SYSCALL = {
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
jitter.pc = 0
return True

View file

@ -64,7 +64,7 @@ jitter.push_uint32_t(0)
# Handle return
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
return False
ret_addr = 0x1337beef
@ -108,7 +108,7 @@ while todo:
# Restore state, while keeping already found solutions
dse.restore_snapshot(snapshot, keep_known_solutions=True)
# Reinit jitter (reset jitter.run, etc.)
# Reinit jitter (reset jitter.running, etc.)
jitter.init_run(run_addr)
# Set the argument value in the jitter context
@ -140,4 +140,3 @@ print(
len(reaches)
)
)

View file

@ -25,7 +25,7 @@ class Sandbox(object):
@staticmethod
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
return False
@classmethod

View file

@ -212,6 +212,7 @@ class Jitter(object):
self.arch = lifter.arch
self.attrib = lifter.attrib
arch_name = lifter.arch.name # (lifter.arch.name, lifter.attrib)
self.running = False
try:
if arch_name == "x86":
@ -418,7 +419,7 @@ class Jitter(object):
"""
self.run_iterator = self.runiter_once(pc)
self.pc = pc
self.run = True
self.running = True
def continue_run(self, step=False, trace=False):
"""PRE: init_run.
@ -430,7 +431,7 @@ class Jitter(object):
if trace:
self.set_trace_log()
while self.run:
while self.running:
try:
return next(self.run_iterator)
except StopIteration:

View file

@ -291,7 +291,7 @@ def sys_generic_exit_group(jitter, linux_env):
# Stub
log.debug("Exit with status code %d", status)
jitter.run = False
jitter.running = False
def sys_generic_read(jitter, linux_env):

View file

@ -141,4 +141,4 @@ sb.jitter.vm.add_memory_page(0x7fff0000 + 0x14, PAGE_READ | PAGE_WRITE, b"AAAA")
# Run
sb.run(addr)
assert(sb.jitter.run is False)
assert(sb.jitter.running is False)

View file

@ -137,4 +137,4 @@ sb.jitter.vm.add_memory_page(0x7fff0000 + 0x28, PAGE_READ | PAGE_WRITE, b"AAAAAA
# Run
sb.run(addr)
assert(sb.jitter.run is False)
assert(sb.jitter.running is False)

View file

@ -5,7 +5,7 @@ from miasm.analysis.machine import Machine
from miasm.core.locationdb import LocationDB
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
jitter.pc = 0
return True

View file

@ -25,7 +25,7 @@ run_addr = 0x40000000
loc_db = LocationDB()
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
jitter.pc = 0
return True
@ -50,7 +50,7 @@ myjit = init_jitter(loc_db)
myjit.init_run(run_addr)
myjit.continue_run()
assert myjit.run is False
assert myjit.running is False
assert myjit.cpu.EAX == 0x0
## Let's specify a max_exec_per_call
@ -74,7 +74,7 @@ myjit.init_run(run_addr)
myjit.exec_cb = cb
myjit.continue_run()
assert myjit.run is True
assert myjit.running is True
# Use a '>=' because it's a 'max_...'
assert myjit.cpu.EAX >= 0xA
@ -94,7 +94,7 @@ myjit.init_run(run_addr)
myjit.exec_cb = cb
myjit.continue_run()
assert myjit.run is False
assert myjit.running is False
assert myjit.cpu.EAX == 0x00
## main(2) + (loop_main(3))*(0x10) + loop_end(1) + 0x1337beef (1)
assert counter == 52

View file

@ -21,7 +21,7 @@ myjit.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data)
# Sentinelle called on terminate
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
jitter.pc = 0
return True
@ -33,7 +33,7 @@ myjit.init_run(run_addr)
myjit.continue_run()
# Check end
assert myjit.run is False
assert myjit.running is False
# Check resulting state / accessors
assert myjit.cpu.EAX == 0

View file

@ -6,7 +6,7 @@ from miasm.core.locationdb import LocationDB
def code_sentinelle(jitter):
jitter.run = False
jitter.running = False
jitter.pc = 0
return True

View file

@ -36,4 +36,4 @@ sb = sandbox(loc_db, options.filename, options, globals())
# Run
sb.run()
assert(sb.jitter.run is False)
assert(sb.jitter.running is False)