We've known for some time already that Amazon's AZW files are actually Mobi files, but Amazon didn't share Kindle's Mobi PID which would allow one to buy encrypted Mobi books for Kindle.
Well, I've discovered the algorithm used to generate the PID and was able to use it on Fictionwise, but there was another catch. AZW files have a flag set in the DRM info which is not present in books bought from other vendors. After fixing that, I could read the book on Kindle.
Linked archive includes two Python scripts.
kindlepid.py generates Mobi PID from Kindle serial number. You can then add this PID at a Mobipocket vendor site and redownload books with Kindle's PID enabled. It's possible that some vendors will refuse this PID, as it has an asterisk in place of the traditional dollar sign (Fictionwise works fine).
kindlefix.py "fixes" a Mobi book so that it can be read on Kindle. It should already include Kindle's PID (which you need to specify too). The script will output the fixed book with .azw extension.
Kindle Mobipocket tools 0.1
Mirror
Yet another reverse engineering blog
Wednesday, December 12, 2007
Mobipocket books on Kindle
Labels:
amazon,
drm,
kindle,
mobipocket
Subscribe to:
Post Comments (Atom)
45 comments:
Any familiarity with eReader's encryption? I don't want to do anything illegal -- but I'd like to re-convert the books I already own so I can read them on a Kindle (not that I own one yet ... but I would, if this were do-able!) eReader dot com encrypts to one's credit card which is a great incentive to not share the files! They have a free reader for the palm (and other pda's) and for a mac and a pc. But not yet for a Kindle... here's hoping!
I do plan to look into eReader stuff but not sure when I will get to it.
If you do decide to tackle eReader format, please output it to some format that can easily be converted to LRF.
Regardless what you do or do not, I look forward to more of your posts about reverse engineering. It has always been a topic that facinated me even though it is somewhat esoteric and I would not know where to start with understanding such things.
Keep it coming!
Can it easily go the other way around?
So Kindle format can be read on devices that can read MobiPocket DRM files?
wow, good job! I think that this makes a lot of sense if one already owns the books in another format.
Thanks! This forced to figure out how to run Python scripts in XP. You CAN teach an old dog new tricks.
I would also love to see an eReader conversion! I'd be happy with a conversion to html or even txt.
My wife has over 500 books from eReader.com. She would would love to be able to transfer her library from eReader to the Kindle. My guess is there are quite a number of people who would want this as well.
(getting on knees)
Please consider putting this project on the front burner. It would be a wonderful Xmas present.
Thank you so much.
Readers wife in Wisconsin.
If you can change the Kindle ID in a .mobi file, doesn't this mean you can also hack .azw native files with alternative Kindle IDs and enable *any* Amazon title to be viewed on *any* Kindle?
Of course, Amazon has its Big Brother clause -- they will catch you, exile you for a digital eternity, and turn you in to the copyright cops.
mobipocket.com strips the * from the personal ID so you can't register a Kindle with them. I went ahead and DL'd just in case but indeed the PID's don't match up.
Very cool! Now we just need a way to share books with someone else that has a Kindle...
I tried the Mobipocket tools according to the included readme file and got: (1) PID doesn't match this file on a Mobipocket file and (2)unknown encryption type on Fictionwise file.
Has anyone else tried the tools?
Hello,
Thanks Igor for the hack. I tried the PID generated at ebooks.com, but they do not accept the PID. Is there anyway to get rid of the "*" and still have them process? My goal is to be able to download books from my local library. Let us know Igor and again thanks.
kenmo: did you try a MultiFormat book? Those don't have encryption and can be read on Kindle without conversion.
TestUser: no, the PID should include the asterisk, otherwise the Kindle won't be able to decrypt the book.
Hi Igor,
It worked! Your're awesome. The only odd thing is the title in the Kindle shows as a degree symbol followed by 1/4. Any ideas why that happened? Thanks again!
The only problem I'm having is that the titles don't show up on my Kindle, just the authors. Doesn't matter if the file is in internal memory or on the SD card.
But still, great work!
could simeone post a walk through for the script I cant seem to get it to work.
also where can I find the hack for the sony ereader to enable me to read all my peanut press books, is there a link? many thanks for your help
mobipocket deletes the * from the PID. Any fix on that?
This hack is cool but not really needed. Since the kindle has a HTML browser, just convert a PDF to html, then host it on a website. From the kindle, go to that address.
You cannot just 'transfer' your PDFs as HTML and have them magically appear on Kindle.
First thing is that Kindle does not support HTML tables. So if your HTML content contains tables... rip em out.
Next thing is that images will not appear in your HTML. All that will appear is the labels associated with the HTML image tags.
Also, when you email a PDF to your Kindle, you'll receive it (and of course be charged 10 cents) but the formatting is all screwed up. The PDF contains no images, the fonts and formatting (with tables or without) are all out of what. Combine that with the fact that the TOC doesn't work, makes the PDF virtually useless.
i'd love to hear how i can use MobiPocket to import a PDF, create TOCs, include embedded images and then transfer the finished MOBI file (as a book) to Kindle.
Please...
I'd like to return to Network Geek's comment from December: has anyone got a hack to convert Kindle files to Mobipocket format? As far as I have been able to find up to now, Amazon has way more interesting books than Mobipocket (about twice as many, and lots more that go beyond the standard doofus level), so the Kindle to Mobipocket conversion sounds more interesting to me. I already have an Iliad, which I actually bought primarily to read and mark pdf files for work, and see no reason to buy a Kindle on top of that -- the idea is to reduce the amount of gadgets I have to lug around! Besides, you can't even buy a Kindle over here yet.
My apologies, as this is probably the most basic question on earth - what do I do with these scripts? I'm using Vista and double-clicked on kindlefix.py after downloading, but got a message that it doesn't know which file to use (and neither do I.)
Any help would be greatly appreciated.
I've installed a Python interpreter into both my mac and my windows computers. But I don't know the first thing about how and where to run these scripts. Shouldn't the script be generating the PID at the end of it? I keep getting
"Usage: kindlepid.py Kindle Serial Number"
No PID is generated. How should I be running this script? Sorry - I used to be on top of the programming languages, but I've not touched them in about 10 years.
How to make Igor's script work:
http://www.mobileread.com/forums/showthread.php?t=18310
Here's a python program that removes the protection on mobipocket books:
http://pastebin.com/m40582493
Anonymous said:
"Here's a python program that removes the protection on mobipocket books:
http://pastebin.com/m40582493"
Forgive my ignorance, but what do I do with what is on that page?
Thanks!
OK, ignore my last, I either a) figured it out, or b) got lucky.
I was trying to get a French-English dictionary I had purchased from BooksonBoard into a format that the Kindle would open, and use as a dictionary.
Here's what I *think* works.
1. Determine the PID number of your Kindle, then enter that as a Device for "OD" format books at BooksonBoard.
2. Purchase and download the book in "OD" format. (Not sure what that signifies, but I found that the "PX" format doesn't cooperate.)
3. Download the Python script from http://pastebin.com/m40582493 and save it as SomeName.py.
4. In a command window (I'm using XP), type SomeName.py downloadedfile.prc newfilename.prc KINDLEID
5. Using the USB cable, copy newnamefile.prc to the Kindle.
(Note: "SomeName" can be any name you want to give the Python script file. "downloadedfile.prc" is the name of the file bought from BooksonBoard, and "newnamefile.prc" is the name you want to give the converted file.)
In my case, I purchased the Oxford Pocket French-English Dictionary. I was able to select it as the "default dictionary" for the Kindle, so when I read the French books I downloaded from manybooks.net, I can "look up" unfamiliar words.
And now, I have a question for you all: some months ago, I purchased an e-book from BooksonBoard, for my Palm T/X. It is in PRC format. The book is no longer available for purchase or download. Is there anyway that I can convert that book so it is readable on the Kindle?
Thanks.
I have not tried it, but the "pastebin" python script (which should best be named mobidedrm.py) would typically be used with a non-Kindle PID (i.e. any PID you have associated with the purchased MOBI book). What it apparently does is convert a DRMed MOBI/PRC to a DRM-free MOBI/PRC. This is then readable on the Kindle, or the Cybook Gen3, or the iLiad, or with FBReader, or with MobiPocket Reader software on any device.
In the special case of a dictionary, it sounds like Igor's DRM-preserving script was not enough for the Kindle and you needed a DRM-free version.
Here's a script to convert eReader.com books to HTML:
http://pastebin.com/m1f7a4d4f
New version of the script to convert eReader.com books to HTML:
http://pastebin.com/m7e5598d3
With thanks to Anonymous... the file I have is a *.prc file. The scripts you mentioned appear to work only with *.pdb files. Am I doing something wrong? Is there a solution for *.prc format?
Thanks!
"Determine the PID number of your Kindle"
ummm, how do I do that? I take it that's different from my Kindle serial number?
>"Determine the PID number of your Kindle"
ummm, how do I do that? I take it that's different from my Kindle serial number?>
Yes, the PID is different from the serial number. Check the initial post in this thread for a link to a Python script that will use the serial number to determine what the PID is.
I wasn't sure if I understood that first post. Thanks. I've never done any programming -- not sure that I'm ready to take this on. On the other hand it seems crazy to repurchase books from one Amazon subsidiary from yet another.
I called Kindle support and the tech guy said to look around the Mobipocket site and I would find something that would "turn my frown into a smile." I assume he meant this thread....but who knows.
Anyway, thanks for the help.
That wasn't that hard. I got my Kindle ID using Igor's script, and redownloaded a couple of books with the new ID. Unfortunately, nearly all my books are from Mobipocket. When I ran the kindlefix on them I got:
Encryption: 2
Mobi publication type:2
Mobi format version 4
PID doesn't match this file.
So there's really no way to convert books from Mobipocket? That's a bummer.
"So there's really no way to convert books from Mobipocket? That's a bummer."
That should have read "from mobipocket.com" Sorry for goof.
Is there a way to convert a PRC file to be readable by the Kindle? I have a PRC file which is no longer available or downloadable (a banned book!) and I would like to be able to read it on the Kindle rather than my Palm T/X...
I got the pastebin script to work fine and I can read my book using that method.
When I used the scripts in the original blog everything appears to work and it creates the .azw file but when I move it to the Kindle the Kindle tells me it can not open it. The title also changes to a bunch of spaces and a capital L. Not sure how to debug the issue?
I was able to run Igor's scripts on a G4 PowerBook (Mac). When I put the .azw file on the Kindle, I see it (with the screwed up title but correct author name). And the scripts said they found the correct PID. But when I try to open it, I get:
"The selected item could not be opened. Please use your computer to visit Amazon.com and clock on "ManageYourKinlde" on the "Your Acoount" page for help in solving this issue."
So, do I HAVE to run this on Intel hardware? Could I have the wrong PID since I created it on the Mac, too?
For those with ereader files: there's a python script called "ereader2html" out there (I think on the libprs500 site) that converts encrypted ereader files to html. Doesn't work on all of them, but it works on many.
-----
Anyway, my problem is converting an encrypted .prc Mobipocket file (from Fictionwise). I got my PID and downloaded the file with it. I get a weird error message at the end when I run the script:
kindlefix.py:60: FutureWarning: hex/oct constants > sys.maxint will return positive values in Python 2.4 and up
if off1==0xFFFFFFFF or off1==0:
The Kindleizer v0.1. Copyright (c) 2007 Igor Skochinsky
Encryption: 2
Mobi publication type: 2
Mobi format version: 4
Traceback (most recent call last):
File "kindlefix.py", line 156, in ?
sys.exit(main(fname, sys.argv[2]))
File "kindlefix.py", line 133, in main
new_rec0 = find_key(rec0, pid)
File "kindlefix.py", line 67, in find_key
temp_key = PC1(keyvec1, pid.ljust(16,'\0'), False)
TypeError: ljust() takes exactly 1 argument (2 given)
Anyone know what this means?
Found the problem. I was using Python 2.3 on the Mac. It needed python 2.4 or higher to correctly interpret the bin/hex PID conversion.
Emma,
I am using Version 2.5.2 on the Mac and keep getting a syntax error. Any suggestions
The eReader conversion scripts seem to be gone - is there any possibility that someone can repost them?
http://pastebin.com/m1f7a4d4f
and/or
http://pastebin.com/m7e5598d3
Thanks!
Anyone that wants to avoid installing python, somebody compiled these and some other MOBI related scripts to standard Windows EXE files.
http://www.demonoid.com/files/details/1479930
Post a Comment