Add standalone scripts & Account key downloader

This commit is contained in:
Florian Bach 2021-09-27 17:06:05 +02:00
parent a930a99c80
commit 05e9ebf247
4 changed files with 113 additions and 3 deletions

View file

@ -21,6 +21,15 @@ IMPORTANT:
- This plugin doesn't yet work with PDFs. Importing an ACSM file for a PDF book will just result in the ACSM file being imported, it won't be converted into a PDF.
- This software is not approved by Adobe. I am not responsible if Adobe detects that you're using nonstandard software and bans your account. Do not complain to me if Adobe bans your main ADE account - you have been warned.
## Standalone version
In the folder "calibre-plugin" in this repo (or inside the Calibre plugin ZIP file) there's some scripts that can also be used standalone without Calibre. If you want to use these, you need to extract the whole ZIP file.
- `register_ADE_account.py` can be used to authorize a computer with an ADE account. This creates the three files `activation.xml`, `device.xml` and `devicesalt`. These files are in the same format as the ones for the Calibre computer authorization (inside the `plugins/DeACSM/account/` folder). A ZIP activation export from Calibre will also contain these three files.
- `fulfill.py` can be used - with valid ADE account files in the same folder - to turn an URLLink.acsm file into an eBook.
- `get_key_from_Adobe.py` can be used to contact the Adobe server and download the DER key file for a given AdobeID to import into a DeDRM plugin. Just input your credentials and this script will output the DER file that can be used with DeDRM to decrypt books for this AdobeID. This works independantly from the account activation files or from this plugin, so it's a good way to get your AdobeID decryption key, especially if you're on Linux and it's too difficult to export the keys from ADE running inside Wine. This process does not use up one of your six device activations.
Though, generally it's recommended to use the Calibre plugin instead of these standalone scripts. Except for maybe the `get_key_from_Adobe.py` script if you want to remove DRM from existing eBooks without having to extract the key from ADE.
## To-Do list for the future?

View file

@ -7,6 +7,11 @@ This is an experimental Python version of libgourou.
# pyright: reportUndefinedVariable=false
import sys
if sys.version_info[0] < 3:
print("This script requires Python 3.")
exit(1)
import zipfile
from lxml import etree
@ -20,7 +25,8 @@ FILE_ACTIVATIONXML = "activation.xml"
#######################################################################
def download(replyData: str):
def download(replyData):
# replyData: str
adobe_fulfill_response = etree.fromstring(replyData)
NSMAP = { "adept" : "http://ns.adobe.com/adept" }
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)

View file

@ -0,0 +1,75 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Run this tool to download the eBook DER encryption key
for a given ADE account from the Adobe server.
I am not responsible if Adobe does ban your Account for using
nonstandard software, though in all my previous tests that has
never happened.
Though I would suggest not running this script multiple times -
just run it once and then make enough backups of the key file.
'''
import sys, getpass, tempfile
if sys.version_info[0] < 3:
print("This script requires Python 3.")
exit(1)
from libadobe import VAR_HOBBES_VERSION, createDeviceKeyFile, update_account_path
from libadobeAccount import createDeviceFile, createUser, signIn, exportAccountEncryptionKeyDER
# These are the only two variables you'll need to change
# The mail address and password of your Adobe account
VAR_MAIL = ""
VAR_PASS = ""
#################################################################
def main():
global VAR_MAIL
global VAR_PASS
if (VAR_MAIL == ""):
VAR_MAIL = input("Please enter your AdobeID: ")
if (VAR_PASS == ""):
VAR_PASS = getpass.getpass("Please enter the password for your AdobeID: ")
if (VAR_MAIL == "" or VAR_PASS == ""):
print("Empty credential, aborting")
exit(1)
filename = "adobekey_" + VAR_MAIL + ".der"
with tempfile.TemporaryDirectory() as temp_dir:
update_account_path(temp_dir)
createDeviceKeyFile()
createDeviceFile(VAR_HOBBES_VERSION, True)
success, resp = createUser()
if (success is False):
print("Error, couldn't create user: %s" % resp)
exit(1)
success, resp = signIn(VAR_MAIL, VAR_PASS)
if (success is False):
print("Login unsuccessful: " + resp)
exit(1)
success = exportAccountEncryptionKeyDER(filename)
if (success is False):
print("Couldn't export key.")
exit(1)
print("Successfully exported key for account " + VAR_MAIL + " to file " + filename)
if __name__ == "__main__":
main()

View file

@ -5,6 +5,11 @@
This is an experimental Python version of libgourou.
'''
import getpass, sys
if sys.version_info[0] < 3:
print("This script requires Python 3.")
exit(1)
from libadobe import VAR_HOBBES_VERSION, createDeviceKeyFile
from libadobeAccount import createDeviceFile, createUser, signIn, activateDevice
@ -14,11 +19,26 @@ from libadobeAccount import createDeviceFile, createUser, signIn, activateDevice
# This tool doesn't support anonymous registrations,
# so it's recommended to make a throwaway Adobe account.
VAR_MAIL = "test@example.com"
VAR_PASS = "mypassword"
VAR_MAIL = ""
VAR_PASS = ""
#################################################################
def main():
global VAR_MAIL
global VAR_PASS
if (VAR_MAIL == ""):
VAR_MAIL = input("Please enter your AdobeID: ")
if (VAR_PASS == ""):
VAR_PASS = getpass.getpass("Please enter the password for your AdobeID: ")
if (VAR_MAIL == "" or VAR_PASS == ""):
print("Empty credential, aborting")
exit(1)
createDeviceKeyFile()
createDeviceFile(VAR_HOBBES_VERSION, False)
success, resp = createUser()