redballoonsecurity / ofrak

OFRAK: unpack, modify, and repack binaries.
https://ofrak.com
Other
1.85k stars 127 forks source link

PE file complex block extraction not working with Angr #331

Open whyitfor opened 1 year ago

whyitfor commented 1 year ago

What is the problem? (Here is where you provide a complete Traceback.) CodeRegion unpacker is not finding code regions for Pe files with Angr backend.

Please provide some information about your environment. At minimum we would like the following information on your platform and Python environment: Use ofrak and ofrak-angr.

If you've discovered it, what is the root cause of the problem? With this file: https://github.com/redballoonsecurity/ofrak/blob/master/ofrak_core/test_ofrak/components/assets/kernel32.dll

This line is filtering out all functions angr finds: https://github.com/redballoonsecurity/ofrak/blob/master/disassemblers/ofrak_angr/ofrak_angr/components/blocks/unpackers.py#L69

The issue seems to be that region_vaddr is Range(0x1000, 0x9ba7d) and none of the complex blocks found have a virtual address in that range.

How often does the issue happen?

What are the steps to reproduce the issue? See above

How would you implement this fix? Figure out whether CodeRegion virtual addresses are valid. There is likely a mismatch between the CodeRegion and function virtual addresses that needs to be resolved.