advanced array of bytes searching
Question: I have a binary file and i have to track a "dynamic array of bytes" in this
file , this array is something like:

d0 30 60 XX 5d 48

Where XX can be any HEX value

I need to find all the occurences of this array in the binary file , i mean
all the array of bytes that starts with D0 30 60 (hex) , followed by "XX"
(random hex byte) , followed by 5D 48 (hex).

is there any tool or a python script that can do that ?


Answer: You can use this :

    
    
    import re
    fil = open("myfile.txt")
    txt = fil.read()
    mo = re.match(r'd0 3d0 30 60 ([0-9a-f][0-9a-f]) 5d 48',txt,re.M)
    

I have not much used [regex in
python](http://www.tutorialspoint.com/python/python_reg_expressions.htm)
earlier. I used regex in Php etc so have alook at that link.

Edit : Might be better,

    
    
    f = open('test.txt', 'r')
    s = re.findall(r'd0 3d0 30 60 ([0-9a-f][0-9a-f]) 5d 48',f.read())
    

