sumatrapdfreader / sumatrapdf

SumatraPDF reader
http://www.sumatrapdfreader.org
GNU General Public License v3.0
13.33k stars 1.69k forks source link

Run unzipped epub file from memory #1778

Closed OgiBalboa closed 3 years ago

OgiBalboa commented 3 years ago

Hello! I am developing an open-source "document cryptography" app with Python for the authors who wants to protect their works from copying and distributing without permission when they give access to the readers for their e-books. I have a simple algorithm for this process; First user registers to the database with specified "access code" given from author. Then he downloads pre-assigned book for him inside of a -password crypted- zip file. Then he unzips the book to a temp directory and runs the reader app. I want to use Sumatra to read epub files.

Till this, everything is cool. But unzipping book to the "temp" directory is a weakness. So I decided to unzip files on a memory (ram) and then I read the file. So, how can I start the Sumatra Reader with a file stored in RAM?

GitHubRulesOK commented 3 years ago

Personally I think this is solution looking for a problem, My own view is its a waste of humanities time to create DRM issues, I have not seen any DRM snake oil that works, unless you lock in a vault and delete it or pluck out the eyes of the beholder. any mobile phone camera with screen scraper can be made to work even when the system is monitored for a software footprint. On a practical level when SumatraPDF reads files in temporary space and handles it in RAM e.g. from a web site it INTENTIONALLY allows to save AS a copy. Thus I suggest that would negate any advantage on any system other than run on a ROM drive. Similarly opening an epub or any container file like a PDF already places it in RAM so there is no need for shuffling it about from one address to another. Circumvention is as simple as use one of the many diagnostic tools to search for a decrypted epub=50 4B 03 04 or PDF=25 50 44 46 magic signature in the volatile workspace.

OgiBalboa commented 3 years ago

If I run Sumatra with -restrict command, there's no option for reader, to save copy, this is why I've choose Sumatra. And yes, there's no way to prevent data from user right now, but at least, blocking copy-paste is a one step. I use zipfile module of Python. App reads the book inside the zip and gets its bytes. I dont know what to do next, how can I pass these bytes to Sumatra?

GitHubRulesOK commented 3 years ago

SumatraPDF uses sniffing passes to confirm the file object is structured as a simple application/epub+zip i.e. = 50 4B 03 04. if (file::StartsWith(mimetypePath, "application/epub+zip")) { return kindFileEpub; Using any app to unwrap a zip renders the object as not an application/epub+zip, thus in general cannot pass other tests as a file object for SumatraPDF to process. You would potentially need to approach the MuPDF authors to purchase an application that handles unpacked xhtml streams in memory, however as PDF rather than ePub is their forte, I would be looking to stronger ePub developers such as Calibre .

kjk commented 3 years ago

It's not possible for Sumatra to open a file from memory