I am creating prototypes for a specific file editor, and I am having trouble parsing my hex files and finding a specific template. Here is my code (using the Bitstring library):
from bitstring import BitArray, BitStream, Bit f = open('d:\BB.bin', "rb") s = BitArray(f) f1 = s.find('0x000015354444444343434344444444434343434444444400F700F0') >>> print(f1) (15232,)
This part is fine - but I wonder what output 15232 refers to. (In my file, the actual template is at 770h ).
My main problem is finding this type of template, but with only the first three bytes ( 0x000015 ) and the last ( 0xf700f0 ): I am only interested in getting the middle part.
I tried different solutions, but no luck, any ideas?
f1 = s.find('0x000001''(.*)''F700F0') f1 = s.find('0x000001''0x.''0xF700F0')
source share