Skip to content

Commit

Permalink
clean up the signature and the repr/str mess
Browse files Browse the repository at this point in the history
  • Loading branch information
trolldbois committed Aug 10, 2017
1 parent 02e66aa commit 2205fc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 3 additions & 0 deletions haystack/reverse/heuristics/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def _make_original_type_name(self):

def _rename_similar_records(self, process_context, heap_context, chains):
""" Fix the name of each structure to a generic word/type name """
# order chains by size of records
# which produce nearly a stable resolution system.
chains.sort(key=lambda x: len(x))
for chain in chains:
name = self._make_original_type_name()
log.debug('\t[-] fix type of chain size:%d with name:%s %s' % (len(chain), name, chain))
Expand Down
13 changes: 4 additions & 9 deletions test/haystack/reverse/heuristics/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,13 @@ def test_doublelink(self):
_record = _context.get_record_for_address(address)
print("Before:")
print(_record.to_string())
self.assertEqual(_record.name, "struct_ccd00")
rev.reverse_context(_context)
_record = _context.get_record_for_address(address)
print("After:")
print(_record.to_string())

name_root = _record.name.split('_')[0]
process_context = self.memory_handler.get_reverse_context()
brothers_type = process_context.get_reversed_type(name_root)
instances = brothers_type.get_instances()
print("Brothers:")
for addr, bro in instances.items():
print(bro.to_string())
self.assertEqual(_record.name, "mewingrazzes_ccd00")
# TODO FIX LIST_ENTRY type
pass

def test_otherlink(self):
Expand All @@ -77,7 +72,7 @@ def test_otherlink(self):
logging.basicConfig(level=logging.INFO)
# logging.getLogger("reversers").setLevel(logging.DEBUG)
# logging.getLogger("reversers").setLevel(logging.DEBUG)
logging.getLogger("signature").setLevel(logging.DEBUG)
# logging.getLogger("signature").setLevel(logging.DEBUG)
# logging.getLogger("test_reversers").setLevel(logging.DEBUG)
# logging.getLogger("structure").setLevel(logging.DEBUG)
# logging.getLogger("dsa").setLevel(logging.DEBUG)
Expand Down

0 comments on commit 2205fc6

Please sign in to comment.