mirror of
https://github.com/rwinkhart/sshyp-labs.git
synced 2026-09-05 08:37:35 -04:00
Added comments, removed unnecessary blank lines
This commit is contained in:
@@ -13,7 +13,7 @@ from sys import argv, exit as s_exit
|
|||||||
from time import sleep, strftime, time
|
from time import sleep, strftime, time
|
||||||
|
|
||||||
|
|
||||||
def totp(_secret, _algo, _digits, _period):
|
def totp(_secret, _algo, _digits, _period): # uses provided information to generate a standard totp key
|
||||||
_secret = b32decode(_secret.upper() + '=' * ((8 - len(_secret)) % 8))
|
_secret = b32decode(_secret.upper() + '=' * ((8 - len(_secret)) % 8))
|
||||||
_counter = pack('>Q', int(time() / _period))
|
_counter = pack('>Q', int(time() / _period))
|
||||||
_mac = new_mac(_secret, _counter, _algo).digest()
|
_mac = new_mac(_secret, _counter, _algo).digest()
|
||||||
@@ -22,7 +22,7 @@ def totp(_secret, _algo, _digits, _period):
|
|||||||
return str(_binary)[-_digits:].zfill(_digits)
|
return str(_binary)[-_digits:].zfill(_digits)
|
||||||
|
|
||||||
|
|
||||||
def mfa_read_shortcut():
|
def mfa_read_shortcut(): # reads and extracts MFA info from the user-specified sshyp entry
|
||||||
if not Path(f"{directory}{argument_list[1].replace('/', '', 1)}.gpg").exists():
|
if not Path(f"{directory}{argument_list[1].replace('/', '', 1)}.gpg").exists():
|
||||||
print(f"\n\u001b[38;5;9merror: entry ({argument_list[1].replace('/', '', 1)}) does not exist\u001b[0m\n")
|
print(f"\n\u001b[38;5;9merror: entry ({argument_list[1].replace('/', '', 1)}) does not exist\u001b[0m\n")
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
@@ -50,9 +50,8 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
gpg = 'gpg'
|
gpg = 'gpg'
|
||||||
|
|
||||||
# main process
|
# main process; runs functions to generate MFA key, then continuously copies up-to-date MFA key to clipboard
|
||||||
try:
|
try:
|
||||||
|
|
||||||
if len(argument_list) == 1:
|
if len(argument_list) == 1:
|
||||||
entry_list_gen()
|
entry_list_gen()
|
||||||
argument_list.append(input('entry to read: '))
|
argument_list.append(input('entry to read: '))
|
||||||
@@ -76,7 +75,6 @@ if __name__ == '__main__':
|
|||||||
else: # X11 clipboard detection
|
else: # X11 clipboard detection
|
||||||
system(f"echo -n '{_mfa_key}' | xclip -sel c")
|
system(f"echo -n '{_mfa_key}' | xclip -sel c")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
|
|||||||
Reference in New Issue
Block a user