mirror of
https://github.com/nikdoof/decrypt-otpauth-files.git
synced 2025-12-17 16:19:28 +00:00
Print QR Codes to terminal for accessing!
This commit is contained in:
1
Pipfile
1
Pipfile
@@ -14,6 +14,7 @@ name = "pypi"
|
|||||||
bpylist = "==0.1.4"
|
bpylist = "==0.1.4"
|
||||||
click = "==6.7"
|
click = "==6.7"
|
||||||
pycrypto = "==2.6.1"
|
pycrypto = "==2.6.1"
|
||||||
|
pyqrcode = "==1.2.1"
|
||||||
|
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
|
|||||||
9
Pipfile.lock
generated
9
Pipfile.lock
generated
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "0b92a1b04112e0b557c968c57e6236924878f55115d37dfc4a170fb7a98969bd"
|
"sha256": "81d534465fc2e9af42dacab3d37d305414bfe0fb1642f22fb3142ffebf745505"
|
||||||
},
|
},
|
||||||
"host-environment-markers": {
|
"host-environment-markers": {
|
||||||
"implementation_name": "cpython",
|
"implementation_name": "cpython",
|
||||||
@@ -47,6 +47,13 @@
|
|||||||
"sha256:f2ce1e989b272cfcb677616763e0a2e7ec659effa67a88aa92b3a65528f60a3c"
|
"sha256:f2ce1e989b272cfcb677616763e0a2e7ec659effa67a88aa92b3a65528f60a3c"
|
||||||
],
|
],
|
||||||
"version": "==2.6.1"
|
"version": "==2.6.1"
|
||||||
|
},
|
||||||
|
"pyqrcode": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:fdbf7634733e56b72e27f9bce46e4550b75a3a2c420414035cae9d9d26b234d5",
|
||||||
|
"sha256:1b2812775fa6ff5c527977c4cd2ccb07051ca7d0bc0aecf937a43864abe5eff6"
|
||||||
|
],
|
||||||
|
"version": "==1.2.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"develop": {}
|
"develop": {}
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
|
import base64
|
||||||
import click
|
import click
|
||||||
import getpass
|
import getpass
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
from itertools import chain
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
from Crypto.Cipher import AES
|
import pyqrcode
|
||||||
import hashlib
|
|
||||||
|
|
||||||
from bpylist import archiver
|
from bpylist import archiver
|
||||||
from bpylist.archive_types import uid
|
from bpylist.archive_types import uid
|
||||||
|
|
||||||
|
from Crypto.Cipher import AES
|
||||||
|
|
||||||
|
|
||||||
class Type(Enum):
|
class Type(Enum):
|
||||||
Unknown = 0
|
Unknown = 0
|
||||||
@@ -156,7 +161,27 @@ def main(encrypted_otpauth_backup):
|
|||||||
|
|
||||||
# Decode actual archive
|
# Decode actual archive
|
||||||
archive = DangerousUnarchive(data).top_object()
|
archive = DangerousUnarchive(data).top_object()
|
||||||
print(archive)
|
|
||||||
|
accounts = [account for folder in archive['Folders'] for account in folder.accounts]
|
||||||
|
for account in accounts:
|
||||||
|
otp_type = account.type
|
||||||
|
otp_label = quote(f'{account.issuer}:{account.label}')
|
||||||
|
otp_parameters = {
|
||||||
|
'secret': base64.b32encode(account.secret).decode("utf-8"),
|
||||||
|
'algorithm': account.algorithm,
|
||||||
|
'period': account.period,
|
||||||
|
'digits': account.digits,
|
||||||
|
'issuer': account.issuer,
|
||||||
|
'counter': account.counter,
|
||||||
|
}
|
||||||
|
otp_parameters = '&'.join([f'{str(k)}={quote(str(v))}' for (k, v) in otp_parameters.items() if v])
|
||||||
|
otp_uri = f'otpauth://{otp_type}/{otp_label}?{otp_parameters}'
|
||||||
|
qr = pyqrcode.create(otp_uri, error="L")
|
||||||
|
click.echo("")
|
||||||
|
click.echo(f'{account.type}: {account.issuer} - {account.label}')
|
||||||
|
click.echo(qr.terminal(quiet_zone=4))
|
||||||
|
click.echo("")
|
||||||
|
input("Press Enter to continue...")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user