pe-carv.py - Python PE Carver
pe-carv.py is script can be used to carve out portable executable files from a data stream. It relies on pefile by Ero Carrera to parse the portable executable file format and calculate the file size. Since the script relies on the portable executable file format, data that is appended to the end of the file (overlay) will not be carved out. The algorithm of the script is simple. Search for the strings of the MZ header in a data stream, if found read from the address to the end of the file, then pass the buffer to pefile. If no exceptions are thrown by pefile then we have a valid portable executable file. If an error occurs, search for the next MZ header and then start the process again.
read more.........http://hooked-on-mnemonics.blogspot.com/2013/01/pe-carvpy.html