Hell hath no fury like an engineer angered! This was such a good read and epitomizes hacking:
"Was it worth it? To read one book? No. To prove a point? Absolutely. To learn about SVG rendering, perceptual hashing, and font metrics? Probably yes."
Well, it would be nice to be able to use my Kindle 4 again... Thanks to KOReader, it's no longer a brick, but most of my ebooks are kept hostages at Amazon.
The Kindle DRM situation is really bad right now. It used to be possible to install the DeDRM plugin in Calibre and get decrypted KFX files from the Kindle for PC application. That hasn't been possible since early 2025. The pros can still break it but they aren't sharing with the rest of the class anymore.
> Even the maintainer of the DeDRM plugin has gone underground, refraining from issuing an official new release out of concern that Amazon will simply slap it down.
While Amazon does some shady stuff, at least _some_ of the blame here belongs on the big publishing companies.
One of the big publishers put heavy pressure on Amazon to patch DRM exploits or else they would pull all their content from the platform (or so I was told).
(I worked at Kindle 2017-2019, and was on the team that wrote the code that OP reversed engineered)
Me too. When they removed the option to download books I liberated everything I had ever bought, moved to Kavita+koreader and will never buy a kindle book again.
I jailbroke both kindles. And use koreader on them which now supports progress sync with Kavita which is amazing! So I don't really lose functionality.
Calibre loading books over wifi using KOreader made the jailbreak process worth it for me. My next will be a kobo or whatever else can run KOreader without hassle.
Since the last major jailbreak for Kindle devices was released, I've been using Koreader as well on my Scribe. I have progress syncing setup with Hardcover (Goodreads alternative) instead, however. Only downside is their recommendations don't seem to be well geared to my interests at this point, but hopefully that'll change in the future as more use the service.
May be of interest to this thread - I created a script that drives the Kindle web reader, captures screenshots, runs OCR, and creates an ePub - this wouldn't be as good as the pixelmelt solution, as it requires OCR.
I don't know what state it's in (haven't used it in years), but do apprenticealf's DeDRM tools, which has been forked to nodrm/DeDRM_tools, still handle kindle PC app downloads? Tinkering with old versions of the PC app might work even if the current version doesn't, and there's a registry hack to disable kfx downloading and get azw3 instead, which worked at some point... it's outlined in apprenticealf's DeDRM repo, at the wiki link provided at the top of the repo's README, in the short section saying it's no longer maintained.
That would provide a closer-to-original version of the ebook, rather than just a visually similar one.
That any of this is necessary at all is absurd. Hats off to anyone with the patience to bypass Amazon's DRM rather than giving up on the Amazon ebook ecosystem entirely.
The thing that killed the download -> crack DRM workflow is that Amazon removed the "download and transfer via USB" option. I haven't bought an ebook from Amazon since.
The only viable option would be to buy the book and then pirate a de-DRM'd copy.
I pay for a tool called epubor that strips DRM from kindle, kobo, Adobe, etc and converts it epub. It works with the current version if the app. It gets updates when it stops working.
Feels jank to pay for the book AND pay to free it, but that's the world we live in.
I have to say that I usually only download ebooks illegally when the DRM stops me reading them!
I only have Linux machines at my disposal and I have a PocketBook. The device is nice, but the store is truly abysmal. Often there is some adobe based DRM on books I want to buy and I never got it to work with my ereader.
I just gave up and pirate them now, unless there is a DRM free version (authors like Ruther Bregman and Cory Doctorow provide them.)
It used to be quite easy to strip DRM from kindle books, with my old kindle keybaord, so in the past I always bought a lot of ebooks from Amazon. But now I can't get them on my device anymore. A true shame, the Amazon ebook store really has all the books.
This whole situation p**es me off enough to not feel bad about pirating.
I have a Kobo... I don't remember the model name. But the thing I like best about it, is that I never had to sign into anything to use it. (There is a sign-in/create account screen, but this is easily bypassed if you know how to edit an sqlite file.) Once I have an ebook in DRM-free ePub, I just plug it into my computer, copy it over in the file manager, and then just start reading. No Calibre or any other special software needed.
Fun fact: this is one of the few situations in the US where a prosecutor could claim that this is criminal speech (though I hope and trust they would not, and if it did it would get thrown out by any court respecting the First Amendment).
Not a civil issue, like libel or fraud, but the sort of talk that can get a policeman to come and drag you off to jail. If you've ever wondered why DRM is so roundly hated by engineers of a certain age, it's because not only it dumb makework that they are required to implement, not only is it extremely irritating to discover it interfering with your own computer, but if you do effectively point out how dumb, irritating, and eminently circumventable it is, they made it against the law to even tell anyone.
For books only available through Amazon my workflow used to be buying it, downloading it with their desktop app, importing into Calibre, converting to epub and stripping DRM, then pushing it onto my Kobo.
They broke that a while ago by making their DRM even worse, so now I just pirate those books.
While Amazon does some shady stuff, at least _some_ of the blame here belongs on the big publishing companies.
One of the big publishers put heavy pressure on Amazon to patch this exploit or else they would pull all their content from the platform (or so I was told).
(I worked at Kindle 2017-2019, and was on the team that wrote the code that OP reversed engineered)
Books have got to be the least expensive form of entertainment out there. The value to cost ratio is incredible. Consider buying books to support authors and publishers. If you can't afford it, then libraries are nice too.
I personally know people who pirate books, but pay hundreds of dollars a year for streaming services or battle pass type video games. It blows my mind. Books are so cheap people!
I recently bought the complete Storm Archives series by Brandon Sanderson on ebook for $10. That's over 100 hours of entertainment. It's literally a ratio of 10 CENTS per hour of entertainment.
I know someone who wrote a (technical) book and how hard it is to get sales in the age of easy internet piracy.
I understand the desire to use the books as you please, but please remember that buying the book and downloading a pirated copy for your own use are not mutually exclusive choices.
You can still purchase the book to support the author even if you're not using the exact same file to read it. As the other commenter said, books are extremely cheap relative to the value and/or entertainment time they provide.
that's so weird.
First I decide to buy my wife an ebook reader for the new years and then Louis Rossman makes a video on Kindle DRM bait and switch. Now this and people praising Kobo. Guess I'm buying a kobo
Some books are available to buy DRM-free if you search a little - sometimes from the publisher or the Kobo store. It's also just possible to buy a book and also download a pirated copy. You're not just hurting Amazon, you're hurting the author and I don't think we want to encourage a world where no one writes books because its impossible to get paid for them.
You may not like a product or service, or think it's too expensive, but that doesn't ethically justify just getting it for free illegally. It does justify abstinence: simply not buying the product or service, while also not illegally obtaining it otherwise.
I feel your pain, As an author even I detest DRM and the lack of ability to move between ecosystems, best way is to start out on the right foot and ensure you get all your books, DRM free, and download them locally.
There are also plenty of good free books from indie authors like me (www.rodyne.com) that don't make it to Amazon. I also normally check out smashwords (www.smashwords.com) for their free books or sales, and download about 30 books - about 5 are usually worth keeping, which is about in line with Kindle books I pay for. Also worth signing up for your local library for the best-sellers, they often have partnerships to allow you to loan ebooks.
This is great work, but I’m not clear on why this qualifies as DRM at all. It sounds like the OP reverse engineered a protocol for rendering pages from a book to the web client. Sure, rotating the glyph ids every API call is annoying but it hardly qualifies as encryption or even obfuscation, just an extra mapping step the decoder needs to handle.
Sure seems like whoever at Amazon wrote this didn’t realize that it backdoors their DRM.
I don't suppose this is going to work well with their comics/graphic novels, will it?
I stopped buying ebooks from Amazon some time ago and switched completely to Kobo (and their much-more-easily-defeated DRM), but Amazon's acquisition of Comixology means they've still got by far the best collection of digital comics on the market.
It's hard-coded to the .com store, but that's trivial to change.
The main problem is that every line is treated a `<p>` element. Which means the rendering is askew. That's fine if you're reading a PDF-style document with hard-coded line breaks, but a bit annoying for a reflowable ePub.
Commas are sometimes rendered as apostrophes. Full-stops are also sometimes mid-dots.
Given that the glyph shapes never change, it might be better to "bake in" the shapes rather than manually decoding them. Didn't take too long on my laptop to do the perceptual mapping, but could speed things up for others.
Nevertheless, an excellent demonstration of how pointless DRM is.
Unrelated to this article. But somewhat related to parts of the discussion here.
One (niche) way to overcome not being able to download books from Amazon anymore is to get ebooks from a library that supports Overdrive/libby. (Some of?) Those support downloading DRM files directly from the app, which you then can run through Adobe + Calibre. Obviously, this is contingent on book availability and your ability to get a proper library card. But works for me for 90% of the books that I need.
At one point I did the same for a comic app which was getting the earliest releases of a manga I wanted to read; I still don't read Japanese but was the buyer for my translation circle. They had similar forms of obscure obfuscation; They scrambled the image into chunks, then you got a metadata that remapped it into a finished image. Raw, it looked like one of those slide puzzles.
Over the course of a couple years they updated their scrambling; First to randomize the size of the regions, then to make them triangular instead of rectangular. It was an interesting if tedious challenge to reverse engineer.
what we need is a unified search engine for non DRM bookshops so that I can just search for what I need and then be directed to whatever shop offers it at the best price or format.
My main peeve with rendering in the Kindle app is that formula-type content (often even minor stuff like x²) is rendered as images that (a) are low-resolution and (b) don’t invert in dark mode.
A second peeve is that in dark mode you can only have gray on black, not white on black.
Do the ebooks you're referring to use an image for the ² symbol, rather than css, unicode, or mathjax-generated mathml? A lot of old math books that have been converted from scans do that, for instance, because their OCR was okay at regular text but not good at superscripts, subscripts, or other mathematical symbols.
[+] [-] emptybits|4 months ago|reply
"Was it worth it? To read one book? No. To prove a point? Absolutely. To learn about SVG rendering, perceptual hashing, and font metrics? Probably yes."
[+] [-] bityard|4 months ago|reply
"Wait, you work in tech, why would you ever work on your own car when you can clearly pay someone else to do it???"
Because I like to learn things.
[+] [-] Frenchgeek|4 months ago|reply
[+] [-] phoronixrly|4 months ago|reply
[+] [-] bariumbitmap|4 months ago|reply
> Even the maintainer of the DeDRM plugin has gone underground, refraining from issuing an official new release out of concern that Amazon will simply slap it down.
https://www.mobileread.com/forums/showthread.php?p=4516384#p...
> This works for most Kindle books currently, but Amazon is cracking down hard on the workarounds lately. So free any books you need to asap.
https://github.com/apprenticeharper/DeDRM_tools/discussions/...
[+] [-] professorseth|4 months ago|reply
One of the big publishers put heavy pressure on Amazon to patch DRM exploits or else they would pull all their content from the platform (or so I was told).
(I worked at Kindle 2017-2019, and was on the team that wrote the code that OP reversed engineered)
[+] [-] thrdbndndn|4 months ago|reply
[+] [-] boredhedgehog|4 months ago|reply
[+] [-] UltraSane|4 months ago|reply
[+] [-] wkat4242|4 months ago|reply
I jailbroke both kindles. And use koreader on them which now supports progress sync with Kavita which is amazing! So I don't really lose functionality.
[+] [-] mikkupikku|4 months ago|reply
[+] [-] aidenn0|4 months ago|reply
[+] [-] bmlzootown|4 months ago|reply
[+] [-] cirelli94|4 months ago|reply
[+] [-] raudette|4 months ago|reply
Overview: https://www.hotelexistence.ca/remove-drm-with-kindleocrer/ (there's a sample conversion at the bottom, so you can see if it works "good enough" for your purposes)
Script: https://github.com/raudette/kindleOCRer
In action: https://youtu.be/3-07wMCKlkw
[+] [-] harshreality|4 months ago|reply
That would provide a closer-to-original version of the ebook, rather than just a visually similar one.
That any of this is necessary at all is absurd. Hats off to anyone with the patience to bypass Amazon's DRM rather than giving up on the Amazon ebook ecosystem entirely.
[+] [-] ashton314|4 months ago|reply
The only viable option would be to buy the book and then pirate a de-DRM'd copy.
[+] [-] Uvix|4 months ago|reply
[+] [-] mapontosevenths|4 months ago|reply
Feels jank to pay for the book AND pay to free it, but that's the world we live in.
[+] [-] digianarchist|4 months ago|reply
[+] [-] teekert|4 months ago|reply
I only have Linux machines at my disposal and I have a PocketBook. The device is nice, but the store is truly abysmal. Often there is some adobe based DRM on books I want to buy and I never got it to work with my ereader.
I just gave up and pirate them now, unless there is a DRM free version (authors like Ruther Bregman and Cory Doctorow provide them.)
It used to be quite easy to strip DRM from kindle books, with my old kindle keybaord, so in the past I always bought a lot of ebooks from Amazon. But now I can't get them on my device anymore. A true shame, the Amazon ebook store really has all the books.
This whole situation p**es me off enough to not feel bad about pirating.
[+] [-] Arch-TK|4 months ago|reply
[+] [-] bityard|4 months ago|reply
[+] [-] dannyobrien|4 months ago|reply
Not a civil issue, like libel or fraud, but the sort of talk that can get a policeman to come and drag you off to jail. If you've ever wondered why DRM is so roundly hated by engineers of a certain age, it's because not only it dumb makework that they are required to implement, not only is it extremely irritating to discover it interfering with your own computer, but if you do effectively point out how dumb, irritating, and eminently circumventable it is, they made it against the law to even tell anyone.
https://www.eff.org/press/releases/licensing-scheme-fair-use...
[+] [-] chmod775|4 months ago|reply
They broke that a while ago by making their DRM even worse, so now I just pirate those books.
[+] [-] professorseth|4 months ago|reply
One of the big publishers put heavy pressure on Amazon to patch this exploit or else they would pull all their content from the platform (or so I was told).
(I worked at Kindle 2017-2019, and was on the team that wrote the code that OP reversed engineered)
[+] [-] babblingfish|4 months ago|reply
I personally know people who pirate books, but pay hundreds of dollars a year for streaming services or battle pass type video games. It blows my mind. Books are so cheap people!
I recently bought the complete Storm Archives series by Brandon Sanderson on ebook for $10. That's over 100 hours of entertainment. It's literally a ratio of 10 CENTS per hour of entertainment.
[+] [-] Aurornis|4 months ago|reply
I know someone who wrote a (technical) book and how hard it is to get sales in the age of easy internet piracy.
I understand the desire to use the books as you please, but please remember that buying the book and downloading a pirated copy for your own use are not mutually exclusive choices.
You can still purchase the book to support the author even if you're not using the exact same file to read it. As the other commenter said, books are extremely cheap relative to the value and/or entertainment time they provide.
[+] [-] leshenka|4 months ago|reply
[+] [-] mothballed|4 months ago|reply
[+] [-] cassianoleal|4 months ago|reply
I haven't done that in a while though, so I'm not sure if they closed that loophole.
[+] [-] zaptheimpaler|4 months ago|reply
[+] [-] cubefox|4 months ago|reply
[+] [-] asveikau|4 months ago|reply
Because I did that on two books maybe 1-2 weeks ago without issue. I might be on an old version of the desktop app.
Edit: apparently it's for titles April 2025 or later
[+] [-] boznz|4 months ago|reply
There are also plenty of good free books from indie authors like me (www.rodyne.com) that don't make it to Amazon. I also normally check out smashwords (www.smashwords.com) for their free books or sales, and download about 30 books - about 5 are usually worth keeping, which is about in line with Kindle books I pay for. Also worth signing up for your local library for the best-sellers, they often have partnerships to allow you to loan ebooks.
[+] [-] pmarreck|4 months ago|reply
At least Steve Jobs understood how DRM should work.
[+] [-] anonymousiam|4 months ago|reply
https://linuxsecurity.com/news/government/sklyarov-hearing-s...
https://en.wikipedia.org/wiki/United_States_v._Elcom_Ltd.
[+] [-] semiquaver|4 months ago|reply
Sure seems like whoever at Amazon wrote this didn’t realize that it backdoors their DRM.
[+] [-] AnonC|4 months ago|reply
> To read one book? No.
> To prove a point? Absolutely.
> To learn about SVG rendering, perceptual hashing, and font metrics? Probably yes.
The dedication on this endeavor is admirable. I quite enjoyed reading it even though certain things were new to me (structural similarity index).”
Posting the code on some code sharing platform (not GitHub, where it could probably be taken down quickly) could be a logical next step.
[+] [-] nocchedure|4 months ago|reply
https://github.com/PixelMelt/amazon_book_downloader
Kind of expected, but I was surprised at how quick that was.
[+] [-] AdmiralAsshat|4 months ago|reply
I stopped buying ebooks from Amazon some time ago and switched completely to Kobo (and their much-more-easily-defeated DRM), but Amazon's acquisition of Comixology means they've still got by far the best collection of digital comics on the market.
[+] [-] benterix|4 months ago|reply
1. If possible, buy from the author directly (I mostly read tech books, so that's often an option).
2. Otherwise buy from elsewhere, without DRM.
3. If all other options fail, buy from Amazon but immediately download a DRM-free copy from libgen and use that.
This is both ethical and practical.
[+] [-] edent|4 months ago|reply
It's hard-coded to the .com store, but that's trivial to change.
The main problem is that every line is treated a `<p>` element. Which means the rendering is askew. That's fine if you're reading a PDF-style document with hard-coded line breaks, but a bit annoying for a reflowable ePub.
Commas are sometimes rendered as apostrophes. Full-stops are also sometimes mid-dots.
Given that the glyph shapes never change, it might be better to "bake in" the shapes rather than manually decoding them. Didn't take too long on my laptop to do the perceptual mapping, but could speed things up for others.
Nevertheless, an excellent demonstration of how pointless DRM is.
[+] [-] lifter3101|4 months ago|reply
One (niche) way to overcome not being able to download books from Amazon anymore is to get ebooks from a library that supports Overdrive/libby. (Some of?) Those support downloading DRM files directly from the app, which you then can run through Adobe + Calibre. Obviously, this is contingent on book availability and your ability to get a proper library card. But works for me for 90% of the books that I need.
[+] [-] GauntletWizard|4 months ago|reply
Over the course of a couple years they updated their scrambling; First to randomize the size of the regions, then to make them triangular instead of rectangular. It was an interesting if tedious challenge to reverse engineer.
[+] [-] mcv|4 months ago|reply
But I still think the better option is to never give any money to Amazon.
[+] [-] sohkamyung|4 months ago|reply
[1] https://libreture.com/bookshops/
[+] [-] martin82|4 months ago|reply
[+] [-] layer8|4 months ago|reply
A second peeve is that in dark mode you can only have gray on black, not white on black.
[+] [-] harshreality|4 months ago|reply