Kindle unpack (originally called Mobi unpack), also known as Mobi decode, is a python script that creates MOBI or AZW (Amazon Kindle) source files from the compiled database. The filenames used in the source file are not necessarily the same as those that were originally used to create the database as this information is not preserved in the database but an unpacked set of files should be able to be used to recreate the same database using standard mobi or Kindle generating tools.
For KF8 files and combined Mobipocket and KF8 files built by KindleGen, it also can produce separated mobipocket and KF8 files, and also the original source files if those are included in the eBook. In addition, for KF8 files it can produce an 'ePub', although if the HTML isn't compliant with ePub standards, the 'ePub' won't be either.
For Amazon's .azw4 files, it will extract the PDF that's been wrapped up in Amazon's .azw4 file format.
A Calibre plugin version of the scripts is available in this thread.
Note: This script only works with Python version 2.X
Comments and Reviews
I use this tool for clipping images when conducting academic research. Instead of clipping distorted or low-resolution images from a screenshot, this tool allows me to clip the original, high-resolution, undistorted image included in the book. I also use this tool to extract the original PDF ebook, with bookmarks preserved, from proprietary AZW4 ebooks; that way, I can read my ebooks on any device and using any PDF viewer instead of being confined to Amazon's Kindle Fire or Kindle App.
Since this program does not work on DeDRMed books, I frequently use this program in conjunction with Apprentice Alf's DeDRM Tools to deDRM my books first. I've never had a problem running KindleUnpack and extracting original source materials on books deDRMed with Apprentice Alf's DeDRM Tools.
Don't forget that this program (and Apprentice Alf's DeDRM Tools) also comes with a Calibre plugin!