Skip to content

Instantly share code, notes, and snippets.

@immanuelpotter
Created September 15, 2020 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save immanuelpotter/15205ac5a410e080d933e3f9a9d85660 to your computer and use it in GitHub Desktop.
Save immanuelpotter/15205ac5a410e080d933e3f9a9d85660 to your computer and use it in GitHub Desktop.
Get MFA code for a TOTP String, right now
#!/usr/bin/env python
# https://github.com/pyotp/pyotp
import pyotp
import argparse
parser = argparse.ArgumentParser(description='Get the TOTP code, for an MFA string, right now.')
parser.add_argument('mfa_string', metavar='mfa_string', type=str, help='The MFA string to get the current totp code for.')
args = parser.parse_args()
mfa_string = args.__dict__["mfa_string"]
totp = pyotp.TOTP(mfa_string)
print(totp.now())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment