https://shkspr.mobi/blog/2025/03/towards-extracting-content-from-an-lcp-protected-epub/ Photo of Terence Eden. He has a beard and is smiling. Terence Eden's Blog Mastodon. LinkedIn. GitHub. Email. Feed. [?] Theme: [ / ] 2025-03-16 Extracting content from an LCP "protected" ePub @edent[a]debugging drm ebooks epub * 10 comments * 1,800 words * read ~6,253 times. --------------------------------------------------------------------- As Cory Doctorow once said "Any time that someone puts a lock on something that belongs to you but won't give you the key, that lock's not there for you." But here's the thing with the LCP DRM scheme; they do give you the key! As I've written about previously, LCP mostly relies on the user entering their password (the key) when they want to read the book. Oh, there's some deep cryptographic magic in the background but, ultimately, the key is sat on your computer waiting to be found. Of course, cryptography is Very Hard(tm) which make retrieving the key almost impossible - so perhaps we can use a different technique to extract the unencrypted content? One popular LCP app is Thorium. It is an Electron Web App. That means it is a bundled browser running JavaScript. That also means it can trivially be debugged. The code is running on your own computer, it doesn't touch anyone else's machine. There's no reverse engineering. No cracking of cryptographic secrets. No circumvention of any technical control. It doesn't reveal any illegal numbers. It doesn't jailbreak anything. We simply ask the reader to give us the content we've paid for - and it agrees. Here Be Dragons This is a manual, error-prone, and tiresome process. This cannot be used to automatically remove DRM. I've only tested this on Linux. It must only be used on books that you have legally acquired. I am using it for research and private study. This uses Thorium 3.1.0 AppImage. First, extract the application: BASH BASH./Thorium-3.1.0.AppImage --appimage-extract That creates a directory called squashfs-root which contains all the app's code. The Thorium app can be run with remote debugging enabled by using: BASH BASH./squashfs-root/thorium --remote-debugging-port=9223 --remote-allow-origins=* Within the Thorium app, open up the book you want to read. Open up Chrome and go to http://localhost:9223/ - you will see a list of Thorium windows. Click on the link which relates to your book. In the Thorium book window, navigate through your book. In the debug window, you should see the text and images pop up. Chrome debug screen. In the debug window's "Content" tab, you'll be able to see the images and HTML that the eBook contains. Images The images are the full resolution files decrypted from your ePub. They can be right-clicked and saved from the developer tools. Files An ePub file is just a zipped collection of files. Get a copy of your ePub and rename it to whatever.zip then extract it. You will now be able to see the names of all the files - images, css, fonts, text, etc - but their contents will be encrypted, so you can't open them. You can, however, give their filenames to the Electron app and it will read them for you. Images To get a Base64 encoded version of an image, run this command in the debug console: JavaScript JavaScriptfetch("httpsr2://...--/xthoriumhttps/ip0.0.0.0/p/OEBPS/image/whatever.jpg") .then(response => response.arrayBuffer()) .then(buffer => { let base64 = btoa( new Uint8Array(buffer).reduce((data, byte) => data + String.fromCharCode(byte), '') ); console.log(`data:image/jpeg;base64,${base64}`); }); Thorium uses the httpsr2 URl scheme - you can find the exact URl by looking at the content tab. CSS The CSS can be read directly and printed to the console: JavaScript JavaScriptfetch("httpsr2://....--/xthoriumhttps/ip0.0.0.0/p/OEBPS/css/styles.css").then(response => response.text()) .then(cssText => console.log(cssText)); However, it is much larger than the original CSS - presumably because Thorium has injected its own directives in there. Metadata Metadata like the NCX and the OPF can also be decrypted without problem: JavaScript JavaScriptfetch("httpsr2://....--/xthoriumhttps/ip0.0.0.0/p/OEBPS/content.opf").then(response => response.text()) .then(metadata => console.log(metadata)); They have roughly the same filesize as their encrypted counterparts - so I don't think anything is missing from them. Fonts If a font has been used in the document, it should be available. It can be grabbed as Base64 encoded text to the console using: JavaScript JavaScriptfetch("httpsr2://....--/xthoriumhttps/ip0.0.0.0/p/OEBPS/font/Whatever.ttf") .then(response => response.arrayBuffer()) .then(buffer => { let base64 = btoa( new Uint8Array(buffer).reduce((data, byte) => data + String.fromCharCode(byte), '') ); console.log(`${base64}`); }); From there it can be copied into a new file and then decoded. Text The HTML of the book is also visible on the Content tab. It is not the original content from the ePub. It has a bunch of CSS and JS added to it. But, once you get to the body, you'll see something like: HTML HTML
Lorem ipsum etc.
Your Name (required): [ ] Your Email
(required): [ ] Your Website (optional):
[ ]
[Post Comment]
To respond on your own website, write a post which contains a link to
this post - then enter the URl of your page here.
Learn more about WebMentions.
[ ]
[Ping me!]
Search
Search for: [ ] [Search]
[?] Explore The Archives
* 2025
+ January 17 posts
February 20 posts
March 12 posts
April
May
June
July
August
September
October
November
December
* 2024
+ January 31 posts
February 29 posts
March 31 posts
April 30 posts
May 31 posts
June 30 posts
July 19 posts
August 18 posts
September 18 posts
October 29 posts
November 31 posts
December 30 posts
* 2023
+ January 31 posts
February 28 posts
March 31 posts
April 30 posts
May 31 posts
June 30 posts
July 31 posts
August 31 posts
September 30 posts
October 31 posts
November 30 posts
December 31 posts
* 2022
+ January 30 posts
February 23 posts
March 15 posts
April 19 posts
May 19 posts
June 19 posts
July 19 posts
August 18 posts
September 12 posts
October 8 posts
November 30 posts
December 31 posts
* 2021
+ January 31 posts
February 28 posts
March 31 posts
April 30 posts
May 31 posts
June 30 posts
July 31 posts
August 31 posts
September 30 posts
October 31 posts
November 30 posts
December 31 posts
* 2020
+ January 31 posts
February 29 posts
March 31 posts
April 30 posts
May 31 posts
June 30 posts
July 31 posts
August 31 posts
September 30 posts
October 31 posts
November 30 posts
December 31 posts
* 2019
+ January 31 posts
February 12 posts
March 17 posts
April 12 posts
May 12 posts
June 10 posts
July 7 posts
August 5 posts
September 6 posts
October 14 posts
November 30 posts
December 17 posts
* 2018
+ January 8 posts
February 4 posts
March 6 posts
April 14 posts
May 5 posts
June 6 posts
July 6 posts
August 13 posts
September 14 posts
October 8 posts
November 30 posts
December 4 posts
* 2017
+ January 12 posts
February 9 posts
March 8 posts
April 4 posts
May 10 posts
June 5 posts
July 5 posts
August 6 posts
September 3 posts
October 4 posts
November 30 posts
December
* 2016
+ January 10 posts
February 10 posts
March 11 posts
April 9 posts
May 8 posts
June 9 posts
July 6 posts
August 9 posts
September 4 posts
October 2 posts
November 30 posts
December 14 posts
* 2015
+ January 8 posts
February 11 posts
March 10 posts
April 4 posts
May 9 posts
June 3 posts
July 7 posts
August 9 posts
September 10 posts
October 2 posts
November 30 posts
December 4 posts
* 2014
+ January 13 posts
February 13 posts
March 15 posts
April 14 posts
May 8 posts
June 7 posts
July 9 posts
August 5 posts
September 5 posts
October 1 post
November 30 posts
December 20 posts
* 2013
+ January 25 posts
February 17 posts
March 15 posts
April 18 posts
May 11 posts
June 14 posts
July 6 posts
August 14 posts
September 6 posts
October 4 posts
November 30 posts
December 15 posts
* 2012
+ January 14 posts
February 8 posts
March 13 posts
April 15 posts
May 10 posts
June 16 posts
July 8 posts
August 8 posts
September 6 posts
October 6 posts
November 30 posts
December 30 posts
* 2011
+ January 13 posts
February 11 posts
March 12 posts
April 12 posts
May 8 posts
June 8 posts
July 6 posts
August 5 posts
September 11 posts
October 7 posts
November 30 posts
December 17 posts
* 2010
+ January 6 posts
February 15 posts
March 12 posts
April 13 posts
May 4 posts
June 3 posts
July 15 posts
August 8 posts
September 11 posts
October 10 posts
November 30 posts
December 9 posts
* 2009
+ January 1 post
February 5 posts
March 3 posts
April 7 posts
May 12 posts
June 8 posts
July 10 posts
August 10 posts
September 12 posts
October 22 posts
November 31 posts
December 15 posts
* 2008
+ January 2 posts
February
March 2 posts
April 3 posts
May 2 posts
June
July 1 post
August 3 posts
September 1 post
October 3 posts
November 2 posts
December 1 post
* 2007
+ January
February
March
April
May
June
July
August
September
October
November 4 posts
December 5 posts
* 2006
+ January
February
March
April 1 post
May
June
July
August
September
October
November 1 post
December
* 2005
+ January
February
March 1 post
April
May
June
July
August
September 1 post
October
November
December
* 2004
+ January
February
March
April
May 5 posts
June 3 posts
July 1 post
August
September
October
November
December
* 2003
+ January
February
March 2 posts
April
May
June
July
August
September
October
November
December
* 2002
+ January
February 1 post
March
April 3 posts
May
June
July
August
September
October
November
December
* 2001
+ January
February
March
April
May
June
July 1 post
August
September
October 1 post
November
December
* 2000
+ January
February
March 1 post
April
May
June
July
August
September
October 1 post
November 1 post
December
* 1999
+ January
February
March
April
May
June
July
August
September 1 post
October
November
December 1 post
* 1998
+ January
February
March
April
May 1 post
June
July
August
September
October
November
December
* 1997
+ January 1 post
February
March
April
May
June
July
August
September
October
November
December
* 1995
+ January
February
March 1 post
April
May 1 post
June
July
August
September
October
November
December
* 1993
+ January
February
March
April
May
June 1 post
July
August
September
October
November
December
* 1987
+ January
February
March
April
May
June
July
August
September
October
November
December 1 post
Subscribe by Email
[ ]
[ ]
[Subscribe]
* (c) Terence Eden
* Contact Me
* Subscribe
* Citations
* Support My Blog
* Library
* On This Day
* Link Rot
* Trending Posts
* About Me
ISSN 2753-1570 MMXXV *