password is passed to libgourou SECURELY
This commit is contained in:
parent
29fbbbff0d
commit
9241f845e8
2 changed files with 26 additions and 7 deletions
|
@ -27,11 +27,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1627404663,
|
"lastModified": 1627508403,
|
||||||
"narHash": "sha256-SnuVDohY/jnoN1oUGtYZBgDAqdVvETB6yuEuUiwzIOA=",
|
"narHash": "sha256-JHOxPSJSaS+0NTUkNv6a9oI8g30pBuCDC+JwtZBaq3U=",
|
||||||
"owner": "BentonEdmondson",
|
"owner": "BentonEdmondson",
|
||||||
"repo": "libgourou-utils",
|
"repo": "libgourou-utils",
|
||||||
"rev": "67e6e7ba08832c716ea156d80c9b3b26adb3cfd2",
|
"rev": "f16d3df200134209a1e2e530db056b3cd715425d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
27
knock
27
knock
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os, sys, argparse, subprocess, magic
|
import os, sys, argparse, subprocess, magic, shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
|
|
||||||
|
@ -20,18 +20,34 @@ if not args.acsm_file.exists():
|
||||||
if args.epub_file.exists():
|
if args.epub_file.exists():
|
||||||
sys.exit(f'ERROR: {str(args.epub_file)} already exists.')
|
sys.exit(f'ERROR: {str(args.epub_file)} already exists.')
|
||||||
|
|
||||||
|
if args.drm_file.exists():
|
||||||
|
sys.exit(f'ERROR: {str(args.drm_file)} must be moved or deleted.')
|
||||||
|
|
||||||
if not args.adobe_dir.exists():
|
if not args.adobe_dir.exists():
|
||||||
print('This device is not registered with Adobe.')
|
print('This device is not registered with Adobe.')
|
||||||
email = input("Enter your Adobe account's email address: ")
|
email = input("Enter your Adobe account's email address: ")
|
||||||
password = getpass("Enter your Adobe account's password: ")
|
password = getpass("Enter your Adobe account's password: ")
|
||||||
print('Registering this device with Adobe...')
|
print('Registering this device with Adobe...')
|
||||||
|
|
||||||
subprocess.run([
|
result = subprocess.run([
|
||||||
'adept-register',
|
'adept-register',
|
||||||
'-u', email,
|
'-u', email,
|
||||||
'-p', password,
|
|
||||||
'-O', str(args.adobe_dir)
|
'-O', str(args.adobe_dir)
|
||||||
], check=True)
|
], input=password.encode(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
|
if result.stdout.decode().strip().startswith('Exception code : 0x1003'):
|
||||||
|
shutil.rmtree(str(args.adobe_dir))
|
||||||
|
sys.exit('ERROR: Incorrect password')
|
||||||
|
|
||||||
|
if result.stdout.decode().strip().startswith('Exception code : 0x500a'):
|
||||||
|
shutil.rmtree(str(args.adobe_dir))
|
||||||
|
sys.exit('ERROR: No internet access')
|
||||||
|
|
||||||
|
if result.returncode != 0 or not args.adobe_dir.exists() or result.stdout.decode().strip().startswith('Exception code : '):
|
||||||
|
if args.adobe_dir.exists():
|
||||||
|
shutil.rmtree(str(args.adobe_dir))
|
||||||
|
print('ERROR: ', file=sys.stderr)
|
||||||
|
sys.exit(result)
|
||||||
|
|
||||||
print('Downloading the EPUB file from Adobe...')
|
print('Downloading the EPUB file from Adobe...')
|
||||||
|
|
||||||
|
@ -44,6 +60,9 @@ result = subprocess.run([
|
||||||
'-f', str(args.acsm_file)
|
'-f', str(args.acsm_file)
|
||||||
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
|
if result.stdout.decode().strip().startswith('Exception code : 0x500a'):
|
||||||
|
sys.exit('ERROR: No internet access')
|
||||||
|
|
||||||
if result.returncode != 0 or not args.drm_file.exists():
|
if result.returncode != 0 or not args.drm_file.exists():
|
||||||
print('ERROR: ', file=sys.stderr)
|
print('ERROR: ', file=sys.stderr)
|
||||||
sys.exit(result)
|
sys.exit(result)
|
||||||
|
|
Loading…
Reference in a new issue