title: Taking a hex file and extracting data
body: <p>I basically have a file that I wish search for a specific hex value (header), once this is found, read everything from that hex value location (header) until a specific hex value (footer) is found</p>
  
  <p>I have some starting code:</p>
  
  <pre><code>import binascii
  
  holdhd = ""
  holdft = ""
  header = "03AABBCC"
  footer = "FF00FFAA"
  
  with open ('hexfile', 'rb') as file:    
      bytes = file.read()
      a = binascii.hexlify(bytes)     
      while header in a:      
          holdhd = header     
          print holdhd
  </code></pre>
  
  <p>This will print out the header I wish to find successfully (there are multiple headers in the file), however I am unsure on how to proceed with reading the file from this point and print out everything until the <code>footer</code> is found.</p>
  
  <p>Thanks in advance</p>