Skip to content

Commit

Permalink
Prevent coloring non-traced addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Nalen98 committed Feb 13, 2024
1 parent 86acae0 commit a6b18e8
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions angryghidra_script/angryghidra.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
SYMVECTORS = []

def hook_function(state):
global SYMVECTORS
for object in EXPLORE_OPT["hooks"]:
for frame in object.items():
if frame[0] == hex(state.solver.eval(state.regs.ip)):
Expand All @@ -25,6 +26,14 @@ def hook_function(state):
break

def main(file):
global EXPLORE_OPT
global REGISTERS
global SYMVECTORS
find = None
avoid = None
blank_state = None
vectors = None

with open(file, encoding='utf-8') as json_file:
EXPLORE_OPT = json.load(json_file)

Expand Down Expand Up @@ -59,7 +68,7 @@ def main(file):

if len(argv) > 1:
state = p.factory.entry_state(args=argv)
elif "blank_state" in locals():
elif blank_state != None:
state = p.factory.blank_state(addr=blank_state)
else:
state = p.factory.entry_state()
Expand Down Expand Up @@ -110,7 +119,7 @@ def main(file):
p.hook(int(hook_address, 16), hook_function, length=hook_length)

simgr = p.factory.simulation_manager(state)
if "avoid_address" in locals():
if avoid != None:
simgr.use_technique(angr.exploration_techniques.Explorer(find=find, avoid=avoid))
else:
simgr.use_technique(angr.exploration_techniques.Explorer(find=find))
Expand All @@ -119,19 +128,26 @@ def main(file):
if simgr.found:
found_path = simgr.found[0]
win_sequence = ""
finishedTracing = False
for win_block in found_path.history.bbl_addrs.hardcopy:
win_block = p.factory.block(win_block)
addresses = win_block.instruction_addrs
for address in addresses:
win_sequence += 't:' + hex(address) + '\n'
if address == find:
# Prevent sending the rest of the block addresses that aren't desired
finishedTracing = True
break
if finishedTracing:
break
win_sequence = win_sequence[:-1]
print(win_sequence)

if len(argv) > 1:
for i in range(1, len(argv)):
print("argv[{id}] = {solution}".format(id=i, solution=found_path.solver.eval(argv[i], cast_to=bytes)))

if "vectors" in locals() and len(vectors) != 0:
if vectors != None and len(vectors) != 0:
for address, length in vectors.items():
print("{addr} = {value}".format(addr=hex(address),
value=found_path.solver.eval(found_path.memory.load(address, length),
Expand Down

0 comments on commit a6b18e8

Please sign in to comment.