Yet another reverse engineering blog

Wednesday, December 12, 2007

Mobipocket books on Kindle

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 0.2
Mirror

140 comments:

Anonymous said...

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!

igorsk said...

I do plan to look into eReader stuff but not sure when I will get to it.

JSWolf said...

If you do decide to tackle eReader format, please output it to some format that can easily be converted to LRF.

Anonymous said...

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!

Gudbergur said...

Can it easily go the other way around?

So Kindle format can be read on devices that can read MobiPocket DRM files?

Kaiser, advisor said...

wow, good job! I think that this makes a lot of sense if one already owns the books in another format.

R said...

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.

Anonymous said...

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.

Anonymous said...

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.

Anonymous said...

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.

Network Geek said...

Very cool! Now we just need a way to share books with someone else that has a Kindle...

kenmo said...

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?

TestUser said...

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.

Igor Skochinsky said...

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.

TestUser said...

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!

R said...

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!

3goldens said...

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

Frank J Garcia - CTitanic said...

mobipocket deletes the * from the PID. Any fix on that?

Anonymous said...

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.

John Trevisani said...

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...

Anonymous said...

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.

Anonymous said...

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.

Anonymous said...

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.

Anonymous said...

How to make Igor's script work:

http://www.mobileread.com/forums/showthread.php?t=18310

Anonymous said...

Here's a python program that removes the protection on mobipocket books:
http://pastebin.com/m40582493

Charles Meyrick said...

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!

Charles Meyrick said...

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.

Charles Meyrick said...

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.

AlanW said...

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.

Anonymous said...

Here's a script to convert eReader.com books to HTML:

http://pastebin.com/m1f7a4d4f

Anonymous said...

New version of the script to convert eReader.com books to HTML:

http://pastebin.com/m7e5598d3

Charles Meyrick said...

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!

Anonymous said...

"Determine the PID number of your Kindle"
ummm, how do I do that? I take it that's different from my Kindle serial number?

Charles Meyrick said...

>"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.

Anonymous said...

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.

Anonymous said...

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.

Anonymous said...

"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.

Charles Meyrick said...

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...

John Newton said...
This comment has been removed by the author.
Anonymous said...

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?

Emma Crookshanks said...

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?

Emma Crookshanks said...

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.

Anonymous said...

Emma,
I am using Version 2.5.2 on the Mac and keep getting a syntax error. Any suggestions

Anonymous said...

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!

Anonymous said...

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

Anonymous said...

the .exe files from the post above also conveniently include a virus. don't download.

Anonymous said...

I used my Kindle PID to download an ebook from Books On Board, used the scripts to convert the file to .azw, and got the same results as anonymous when trying to open the book on the Kindle:

"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."

That Amazon doesn't allow creation / reading other vendors' titles non the Kindle goes beyond annoying.

jfrey said...

I got this working yesterday, but when I view the book on the Kindle the title is messed up. It is just random characters, but I can read the book. If I put the pre-kindlefix prc file on the Kindle the title is okay, but I can't read it because the Kindle doesn't think I have permission to.

This is not a show stopper, but it is mildly annoying. Has anyone else had this problem?

Anonymous said...

I have successfully used Igor's scripts for the past 4 months to read library books on my Kindle; now, suddenly, I am unable to read them and receive the same error message:

"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."

Contacting Amazon was useless; Amy, the Kindle tech I spoke with, said all books have to be bought from Amazon, which I know isn't true.

Has there been a change to the script or the Kindle that's causing this problem?

ed said...

Instructions for running Igors script on a Mac are less than clear. I am not an expert. I have installed python. Added the following to my path /usr/bin/python.

When I type the following command "kindlepid.py [serial number of kindle]". I get the following result. "kindlepid.py command not found"

Can anyone throw me a bone? what have I missed?

Anonymous said...

Any updates on converting books from Mobipocket.com?
Thanks

Anonymous said...

I also followed all of the directions and I was able to convert the file to .azw. However, when I try and open it on the Kindle I get the following error message, "The selected item could not be opened. Please use your computer to visit Amazon.com and click on "manage your kindle" on the "your account" page for help in solving this issue." I noticed that others seem to be getting the same error message. Any thoughts?

Anonymous said...

Reading the serial number on my kindle I see something like:
A# ##A##A# #### #### (note the spaces)

A= CapLetter
#= digit

Should the serial number passed to kindlepid include the spaces? I tried it each way with different results.

cellardoor said...

so kindlefix.py allows conversion of mobi->azw format -- has anyone come up with an azw->mobi conversion process?

Jim said...

OK Have tried to run and window closes so I cannot read the pid. What am I doing wrong. Thanks

Emma Crookshanks said...

Ed: You have to type "python kindelpid.py" to run the script.

Anonymous: the serial # should be without spaces.

Emma Crookshanks said...

Jim: You have to run the script in some way to keep the results on screen. Command-line usually works for this. Instead of double-clicking it, open a terminal window (or MS-DOS prompt if you're on windows) and type the command. It'll either be
python kindlepid.py [Serial#]
or
kindlepid.py [Serieal#]

depending on the system you're using. I can't help more with non-Mac/Linux systems,I'm afraid, but if you remember your DOS stuff, it should work.

CCRGMac said...

My Kindle scroll wheel died. It will scroll up and down but won't click. I was OK while I was in my book (War and Peace) as I could still page forward and back, but I tried a reset and now I'm stuck in my Home Screen.

It's 2-3 weeks for my replacement so I'm asking the old hands and the hackers if you can think of a way to get back into my book. Has anyone come across an ALT+? shortcut or any other way to open a book without clicking? I can enter a search but I can't click to submit. Back button doesn't work as the reset wiped its little memory.

Peter said...

Has anyone had success converting NYPL sourced mobipocket books to the kindle? I am able to convert to *.azw format, but the kindle refuses to read them. All of this in Windows XP. running python 2.6.

Marion said...

To read a Mobipocket book with DRM on a Kindle and have the author and title show up (reliably), you have to perform two steps. The first one makes sure the title and author show up on the Kindle. The second allows you to read the book on the Kindle.

Insert Author and Title for Mobipocket books with DRM for use on Kindle:

You need to have Mobi2Mobi_GUI.exe on your system.

1. Start Mobi2Mobi_GUI.exe
2. Load the mobipocket file - typically has a .prc extension.
3. On Author Line, enter "Last Name, First Name" or "Author1 last, first; Author2 last, first; …" Click the check box to right of line.
4. In EXTH section, select UPDATEDTITLE for EXTH TYPE, enter the title under EXTH DATA. Click the check box to the right of line.
5. Click on "Convert"
6. A new file is generated with a .mobi extension; (or overwritten if the original file had a .mobi extension).

(For those who don't like the GUI interface, there is also a command line version of mobi2mobi.)

To enable the Kindle to read the mobipocket file, use the fabulous kindlefix.py script as described in this post (Thanks much Igor)

This generates a new file with the .azw extension. This is what you copy to the Kindle via USB into the documents folder.

Marion said...

I have been using kindlefix.py for several months to download Library Mobipocket files to my Kindle. We got a second Kindle, added the new PID to the library PID list (they allow for up to 3 PIDs). Now the second Kindle works with kindlefix.py but the first Kindle does not.

Is there a solution to this? (Yes - I will remove the second Kindle PID from the library site, but I wondered if that was the only solution.)

Thanks.

Anonymous said...

Public Library accepts the "*" for the mobipocket PID? Mine doesn't so this won't work.

ザイツェヴ said...

I wish there was a way to display Russian text files at least (preferably in UTF-8).
-- Pete

Victor said...

I tried everything. Buy Mobipocket secured from Fictionwise, got PID for my Kindle correctly. Used Python 2.5 to get PID. Put all Python scripts including Igor's, run the scripts still got error message. Would anyone response who can get the scripts worked? Thanks.

Amanda said...

Are there any instructions out there for how to do this for people who have no clue about computer programming? I tried all of the links mentioned in the comments but they are all still too confusing to me. I need very literal step by step instructions for what to do with all of these scripts. I downloaded python and the scripts, I have my serial number, but what do you do with these, where to I input the information and how does it transfer to the kindle? I have all the tools but no clue how to use them. If anyone has this I'd be interested...I just to do this in order to download books from my local library.

Anonymous said...

Those of you running the script in Python for Windows and getting syntax errors need to use an older version of the Python executable. 2.3.5 runs the scripts just fine. You must go to the command prompt, then type the command as it shows in the help file. It really cant get any easier.

Marcin Kuk said...

Hello

I have a problem with public Mobi files. I want to read it with FBReader on Linux but I don't know a PID which a should use.

Please help me.

Anonymous said...

I've been trying to run the .py files, and got past step one with the 3.0 install by changing the print statements to uses of the print() function; same for a few other 3.0 things. However, I can't get to run the second file no matter what i do. I've now uninstalled version 3.0 and installed a few later ones, including ones mentioned in this blog, but all to no avail. I'm getting the following error messages:

Encryption: 2
Mobi publication type: 2
Mobi format version: 6
Traceback (most recent call last):
File "C:\Users\Owner\Documents\Downloads\kindlefix.py", line 156, in ?
sys.exit(main(fname, sys.argv[2]))
File "C:\Users\Owner\Documents\Downloads\kindlefix.py", line 133, in main
new_rec0 = find_key(rec0, pid)
File "C:\Users\Owner\Documents\Downloads\kindlefix.py", line 67, in find_key
temp_key = PC1(keyvec1, pid.ljust(16,'\0'), False)
TypeError: ljust() takes exactly 1 argument (2 given)

any thoughts anyone? HELP please...

thanks

Tina said...

My question isn't necessarily about finding the PID for my Kindle (least I don't think so). I have quite a few .prc files I have purchase that have the metadata messed up so that the title doesn't show properly or the author is missing.

I have been able to successfully correct most of them, however I have about 20 or so that I have been unable to correct and be able to open, apparently because of the DRM. I have tried Mobi2Mobi (when I had access to a PC) and I have tried Calibre (for my Mac).

Does anyone know how I can fix this problem (using a Mac)? Calibre says that the DRM has to be removed.

Richard said...

This is awesome! Used your first Python script to generate a mobi pid, then used that to download a book from my library (Northern California Digital Library) then used the second python script to create the .amz file. Plugged in my Kindle 2, copied file, and now I can read the book. It's a dream come true. Only question - where is your "Donate Now" button?

Anonymous said...

I just downloaded the script and generated a PID from my Kindle serial number. Tried it on Fictionwise.

Unfortunately, it appears that they have "fixed" their system, it will not accept the Kindle PID. Durn it anyway.

Rob N said...

B101XXXX is a valid Kindle v1 serial number. I just removed the first 1, and it was able to load a book

Rebecca said...

I keep getting sytax error on the serial # from my kindle 1. Using Python 2.6 as suggested. Any clues? It's really the first time I've tried anything like this, but I'm very good at following directions.

Anonymous said...

Here's the thing. I HAVE a Bookeen Cybook Gen3. It already reads mobi ebooks. There are three novels that I really want to read - but due to Amazon's stupid policies - are only available in Kindle format. Is it possible to generate a 'Kindle PID' that will be acceptable for purchasing the Kindle format ebooks without shelling out (for me a very difficult concept as I'm on a fixed, disability, low income) to buy a Kindle?

Derek Benner

Auray said...

Has anyone tried this very recently with Mobipocket DRM's? On one site I read that the script doesn't work anymore. Yet on Mobiread at Amazon's request (an advertiser) they dropped certain details, so maybe it still does. I made istake many have done: tried a sample title on Mobipocket, marvelled at how well it integrated with Kindle, then blew 15 euros on something that won't work. Also, any recent Mac tips? When I try python kindlefix.py [my serial number] I get this:
"/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python: can't open file 'kindlefix.py': [Errno 2] No such file or directory", which suggests to my meager understanding that I'm not yet running the scripts from the right place.

Rae Carruth's Trunk said...

I'm trying to generate the PID with my serial number (16 digits on the back of my Kindle 1) and it keeps saying it is a not valid serial number. Can anyone help?

Karen said...

Great site! Have new Kindle 2. Recently downloaded Mobipocket books to my PC running XL. Can I do something to the Mobi books so I can upload and read them on the Kindle? You all have been discussing programming changes I assume are done on your computer while the Kindle is connected with the USB connector. I failed COBOL in 1986, need exceptionally simple directions. Thank you so much...I have hope!

Anonymous said...

I've been converting files to Kindle from online publishers, but I've never had a problem until now. I bought a .prc book, but it requires a PID - like everyone's problem.
Several people here (but maybe too long ago) mentioned that they needed the directions for "dummies." Being one myself, I found a nice link for those of us.
Right now I'm using this link along with the following:
http://nyquil.org/archives/1128-Converting-Kindle-Books-a-painful-process-that-works-for-reading-Kindle-books-without-a-Kindle.html

For non-programmers, it is easy to follow. So far....

Anonymous said...

Mine is the comment above. Now I'm stuck. I can't generate a PID. I tried kindlepid.py for both the current and the older version -2.3.5 - suggested above.
Help!

Anonymous said...

I just bought a CD with thousands of E-Books on it, supposedly for the Kindle. The files are in .prc format. How do I get them to the Kindle and read them?

Anonymous said...

The above comment (about the Kindle) is mine. Please send any advice to ernielane@verizon.net.

Anonymous said...

It may be hard to prove copywrite infringement, but it certainly is illegal hacking of Amazon's software system.

Anonymous said...

I just attempted to find my PID on my kindle DX, and the script does not appear to work. I did have to change the path that kindlepid.py was looking for (/usr/local/bin/python), but the output I receive is as follows:

root@2-core /home/slappy/torrent $ ./kindlepid.py bb004172374596712
Mobipocket PID calculator for Amazon Kindle. Copyright (c) 2007, 2009 Igor Skochinsky
Warning: unrecognized serial number. Please recheck input.

Anonymous said...

kindlepid.py worked fine, but trying to run kindlefix.py on the .prc file gives me an error: "python: No match"

It sounds like the script was unable to find my PID inside the .prc file.

Perhaps the library is imbedding the PID into the .prc file some other way, or maybe the library won't embed a Kindle PID because it contains "*", even though it accepts the number into their system...

Any suggestions?

Anonymous said...

So is this still working? I was able to get a PID using these tools. I registered my kindle on the mobipocket.com site using that PID (they seem to remove the * though). I purchased and downloaded a book. I tried to use kindlefix.py (with the * included in the PID) but I got an error message --- PID doesn't match this file. I'm at a loss

James said...

For those of you with Macs, I have put together an AppleScript wrapper around Igor's scripts, and put the whole thing online with Google Code:

Mobi2Kindle

I hope some people besides me find this useful!

helios said...

James, I tried your Mobi2Kindle app. and it won't accept my Kindle serial number. (can't find PID). I tried the SN with spaces and without. Any ideas?

Helios

James said...

Helios, can you create an issue on the Google Code project page? http://code.google.com/p/mobi2kindle/issues/list

It would be helpful if you gave your serial number, or at least the first four digits of it. If you're not comfortable posting that to the Internet, please send me an e-mail at james (dot) m (dot) allen (at) gmail (dot) com. Thanks!

Anonymous said...

All,

The PID script still works, you just need to change the script file to accept B003 (Late K2) and B003 (KDX) serial numbers.

Change:

if serial.startswith("B001"):
print "Kindle 1 serial number detected"
elif serial.startswith("B002"):
print "Kindle 2 serial number detected"
else:
print "Warning: unrecognized serial number. Please recheck input."

To:

if serial.startswith("B001"):
print "Kindle 1 serial number detected"
elif serial.startswith("B002"):
print "Kindle 2 serial number detected"
elif serial.startswith("B003"):
print "Kindle 2 serial number detected"
elif serial.startswith("B004"):
print "Kindle DX serial number detected"
else:
print "Warning: unrecognized serial number. Please recheck input."


So just add in the two new elif.


-Meathos

James said...

Meathos, I wasn't aware of B003, so I'll be sure to add that. Apparently, B101 is a late 1st generation Kindle, and I've added that and the Kindle DX as well.

Ask Brea said...

kindlepid.py totally does not work on Vista apparently. Nothing happens, tho I know my Kindle SN if anyone wants to run it.

Anonymous said...

I notice that SN B101 did not work. So modified my kindlepid.py to read
if serial.startswith("B101"):
print "Kindle 1 serial number detected"
While this generated a serial number, I cannot open the files on my kindle. I get the "selected item could not be opened.." message. I have done this several times with my old B001* Kindle so I am familiar with the process.

Is there some other modification I do should do to fix this?

Anonymous said...

SOLUTION TO
gives me an error: "python: No match"

I was getting the same error from mobidedrm.Ver5

putting quotes around my PID solved the problem. :-D

i.e.:
python mobidedrm.py infile.azw outfile.mobi "198234*23"

voila!

david said...

hello
I have an Iphone and after having recovered the serial number and using
Kindlepid.py, I get a PID number ten digits without *; In the following Kindlefix said that this number is not valid.
How?

Anonymous said...

I have the same problem as David. the script generates a 10-digit PID from my iphone 3GS UDID that does not include an *

oldman said...

same problem, no * on iPhone decoded PID

Horia said...

Igot my Kindle2 PID but it's not accepted on Mobipocket, Ebooks.com, ebookmall.com,diesel ebooks,etc. I have around25 books bought from these stores. Is there any wayto read them on my Kindle?Thanks

Anonymous said...

Hi, I recently bought a refurbished Kindle2. I'm trying to get the PID number 'cuz I have a lot of books on Mobipocket. I have everything downloaded and reader, however, when I put in my serial number and hit get PID nothing happens. What do I do now??? Help!!! I so don't know computers well so pleeease make it easy! : )

Autumn

Anonymous said...

my bad I meant to write downloaded and READY...

Anonymous said...

Is there any way to take a Kindle file and and jailbreak it into HTML plus images? I used the new "Kindle for PC" to order a downloadable copy, and I've got Dark Reverser's scripts, but they don't work on the kindle file I got as a test.

snugglebear said...

Here's a slightly different problem, but the people in this thread sound like one of them might have a solution: I have a non-DRM mobi-format book from gutenberg on my K2. I'd like to get it into my iPod Kindle app as well, but only stuff obtained from Amazon's library gets moved over normally. I know I could install the book into some other ereader on the iPod, but I'd like to be able to sync back and forth between the two devices. Any ideas? Thanks in advance.

Anonymous said...

I am so grateful; the program for mac works like a dream, now I can read all the books I got in mobi-format!
thanks a lot!!! And in my own language!

Anonymous said...

Apparently, kindlepid.py doesn't currently work as-is with the new Kindle DX. It currently bails out with the error: "Warning: unrecognized serial number. Please recheck input." This seems to be caused by the serial number sanity check, which doesn't list a prefix for the Kindle DX.

This patch fixes the problem, insofar as it adds a check for the new Kindle DX serial number prefix, and therefore allows a PID to be returned. However, I haven't tested whether the resulting PID formed from the Kindle DX serial number is actually valid for real-world use.

Anyone else with a DX able to verify that this patch works with your Kindle?

P.S. The patch won't bump the version number. I figure that's for the author to do if he accepts the patch. :)

Anonymous said...

The new patch works with my Kindle DX, for a total statistical sample of 1. :)

Anonymous said...

http://pastebin.com/f583112a5 (patched the patch for Kindle Global (B003)

Kindle Reader said...

Either I don't understand how to use the patch ( very possible ) or it just doesn't work on my Kindle DX. I get the same message.

Anyone else having the same problem?

Anonymous said...

Is there a version of kindlefix that can be installed as a Calibre plugin?

angusyoung said...

this blog is brilliant!
question folks......can I download an encrypted pdf for my Amazon Kindle and if so do I need to convert or any software and if so which?
thanks

./angus

angusyoung said...

sorry..and also...does anyone know what a 'Adobe Digital Versions' ebook download is and can I view it on my Kindle?
thanks again
./angus

angusyoung said...

sorry Adobe Digital Editions that should be.
./a

Anonymous said...

I just got a Kindle for Christmas. The serial number starts with "B003".

I modified the kindlepid.py program to accept "B003" as a prefix.

I changed the public library's record to add my "new" MobiPocket PID. Then checked out an encrypted MobiPocket book.

After running the kindlefix.py program, I downloaded the .AZW output file to my new Kindle's Documents folder.

AND IT WORKS!

Igor, you may want to add an additional check to kindlepid.py before bailing out with an unrecognized serial number.

daddyhansen said...

Got my Kindle DX for Christmas. Had a number of MobiPocket eboos from previous devices... Used Kindlepid.py to create my PID. Created a device in Mobipocket for the Kindle DX and entered in the PID generated. Mobipocket never recognizes the device as connected though... Any ideas. I set it up as device type "other"....

Bob said...

I own Kinder International and today I discovered, that I could possibly read also DRM'ed mobopocket books. I've created PID using kindlepid.py, bought reasonable cheap mobi book (Earth by D. Brin) at Diesel eBooks, but kindlefix.py don't want to fix it:

C:\Users\Public\Knihy>c:\Python26\python.exe "c:\Program Files\bin\kindle\kindlefix.py" Brin_978030757_9780E98F7DA7.prc #######*
The Kindleizer v0.2. Copyright (c) 2007, 2009 Igor Skochinsky
Encryption: 2
Mobi publication type: 2
Mobi format version: 4
#######* -> #######4eb95aa1b#######5727c5c85
pid cksum: 26
Key records: 224-344, count: 1, flag: 00
Key record 0: check=00000043, size=48, type=1, cksum=82
Decrypted drmInfo: 67BA685C, 4C26C191, 39b81aca063fbf1dc1162b763027ff46, 8B4723EC, B3866514
Decrypted drmInfo: 67ba685c4c26c19139b81aca063fbf1dc1162b763027ff468b4723ecb3866514
PID doesn't match this file

(I've uncommendted some printouts and hidden the PID printed out.)

Frezh said...

My case is similar to Bob's, I'm runing on a Intel MAC 10.6 Python 2.6.1 :

./kindlefix.py Mobipocketfile.prc AAAAAA*AA
The Kindleizer v0.2. Copyright (c) 2007, 2009 Igor Skochinsky
Encryption: 2
Mobi publication type: 2
Mobi format version: 6
PID doesn't match this file

Thanks !

Anonymous said...

Can someone help me? I have a K2 that has a B003 serial # and I guess I'm not computer savvy enough to manage kindlepid to get the PID. I know the script needs modified but I'm having no luck and I don't get what it is I'm doing. Help!!! email me NHarres4748@msn.com

G said...

I am in the same boat. I can't seem to get the script to work for my K2 serial #. I am using Python 2.6.4. I keep getting a syntax error when I run the script. Even if I use the sample pid in Igor's readme text.

G said...
This comment has been removed by the author.
G said...

I have modified the script to recognize a B003 serial number, and I am still getting "SyntaxError: invalid syntax"

I have tried running the script on both Vista and XP, and the same thing happens. Help!

G said...

The entire error message is:

File "", line 1
kindlepid.py [serial # I typed]

SyntaxError: invalid syntax

Direct replies to: gigilaprof-at-gmail.com. Thanks!

Anonymous said...

Not sure if this is correct but I added an extra elif condition: elif serial.startswith("B003"):
print "Kindle 2 serial number detected"

and it seems to work. Will let you know

Microbe said...

Hey Igor,

would you be willing to share the algorithm to unswindle a kindle? I'd like to try to port it to PHP and see if I can make a web page wehere people can do their own files.

Sue said...

I dunno I must be crap, I can't make heads nor tails of how to edit the script. This is really frustrating as others have posted (recently) that they are stoked about getting it done.

Is there anyone who's willing to lay out the steps in clear English for people like myself who are not python programmers?

I'm running vista and did get python 2.3.5 as suggested.

Anonymous said...

Just an FYI that there is a new web-based tool for getting your PID: http://kindletools.prestonlee.com

Anonymous said...

"Just an FYI that there is a new web-based tool for getting your PID: http://kindletools.prestonlee.com"

Now that was SIMPLE!!!

Why can't the rest of the process of removing the DRM be that simple??

Surely after a couple of years we have advanced enough to design an GUI type application to do this?

Anonymous said...

What am I doing wrong??

Please help.

kindlefix.py wifeforhire4_9780061546075.prc #######*##
The Kindleizer v0.2. Copyright (c) 2007, 2009 Igor Skochinsky
Encryption: 2
Mobi publication type: 2
Mobi format version: 4
PID doesn't match this file

limecello said...

Igor, or anyone, I have the same question as http://igorsk.blogspot.com/2007/12/mobipocket-books-on-kindle.html?showComment=1216179720000#c3727839785770642300

Help please? Was it an update? Is there anyway to undo it, or get around it?

Anonymous said...

I suggest you post your question here: http://www.mobileread.com/forums/showthread.php?t=68407
You are likely to find some answers.

lelor63 said...

Anyone has a solution for iphone 3GS generated PID that does not include a * and hence is not recognized by kindlefix.py ?

Anonymous said...

Interesting -- with just the Kindle PID I downloaded an Overdrive book I checked out from my local library, and the kindlefixed azw file failed to work on my Kindle.

But when I added a Mobipocket Reader for Windows PID to my account and redownloaded and then re-kindlefixed, all was well.

In case anybody else has problems, maybe this will help.

McMama said...

So now that mobile read has deleted all the information on how to use these scripts... HOW DO WE USE THESE SCRIPTS? I've got python. Beyond that, I'm clueless.

Anonymous said...

@McMama

I just went through the same thing. After installing Python, follow the instructions on how to make Python work from the command line. It's in the first couple of paragraphs here: http://www.imladris.com/Scripts/PythonForWindows.html

Then, after that, put your scripts and mobi files in the same folder. This just makes it easier.

Then open the command prompt (sometimes it's found in Accessories, otherwise Run>Cmd.

You must use the cd command to navigate to the directory in which you've stored your mobi files and scripts

Then enter the syntax described in the readme file, for example:
python kindlefix.py bookname.prc MyPID

changing the arguments as appropriate

If the command line stuff confuses you you'll have to do some googling but that should put you in the right direction

Anonymous said...

when trying to run on Vista my downloaded versions of python can't be located even though I have a PYTHONPATH variable defined

said...

Good news, everybody! I wrote a Windows program to do this: http://j2jensen.blogspot.com/2010/05/mobipocket-to-kindle-format-converter.html

No more wrestling with Python

(It's free!)

Jessica said...

J2- you are my hero!!!! I've been trying to figure out python for the last three hours, thank you thank you thank you! I feel like I should buy you dinner or something!!

Anonymous said...

It also works for Kindle 3, but you have to change kindlepid to also accept the new serial numbers. I just also let it accept numbers that start with A008 and it worked for me.

Anonymous said...

It doesn't seem to work for the european version of Kindle 3 (B00A start), even when script is adapted to accept said version.

johndouglas said...
This comment has been removed by a blog administrator.
Anonymous said...

As Anonymous writes on September 15 2010, you can make this work for Kindle 3 (at least those serial numbers starting with B008) by editing the script.

On line 55 there is an if and an elif statement that checks for serial.startif. After the elif statement and before the else statement that follows, insert the following:

elif serial.startswith("B008"):
print "Kindle 3 serial number detected"


That's it.

FotoFlekkeren said...

Do anyone know how to add DRM to .azw files without distributing it through Amazon?

Basically, I want to distribute my own manuscript to a limited number of people, but want DRM-protection to limit the circulation. Any way of doing this?

Rider said...

Running a mac with a newly installed copy of Kindle for Mac v1.8.1 (36155)

Kindle books download and read fine.

I can find no kindle.info file in my home directory (using the command line find or spotlight)

When I try DeDRM app 3.1 from tools 4.8 it says I need a different PID. I can't find a PID anywhere.

I had an old version of DeDRM on a previous incarnation of this box (I restored my stuff from a time machine backup from another mac to this) so it might be finding that rather than using the right one, but as it looks like the new Kindle for Mac doesn't have a kindle.info file, am I out of luck?

(Same if I use Kindlebooks.pyw, Error No key found. Most likely the correct PID has not been given. Crypto type is 2)