title: Python carving a file from a large set of bytes
body: <p>I am working with python 3 and can not figure out a way to get this to work. I am trying to create a tool for my hex editor that can look at a large set of bytes and search for the headers and footers of .pdf files, etc. I know the .pdf header is 25 50 44 46 2D 31 2E and the footer is 25 25 45 4F 46 in hexadecimal. So my questions is, is there a way to search through a large set of bytes find the header and footer copy all the bytes in between, use them to create a new file that I can then open with, in this case something like adobe reader, and view it as any other .pdf? Any help would be greatly appreciated.</p>