Duo

duo.configure_mfa()

Interactively prompts the user to configure MFA. Offers a choice between Duo Push via a registered virtual device and HOTP passcode. For push, the user can either activate a new virtual device using an activation code or supply existing device credentials directly. RSA private key input is accepted as PEM or base64-encoded PEM.

Examples

>>> h.duo.configure_mfa()
MFA Type (push/hotp): push
Setup Type (new/existing): new
Duo Activation Code: ABCDEF-dGVzdC5kdW9zZWN1cml0eS5jb20=

duo.get_device_registration(code)

Registers SynackAPI as a virtual Duo device using an activation code from the Duo admin portal. Stores the resulting credentials (akey, pkey, host) in the database for use in subsequent logins. This only needs to be run once.

ArgumentsDescription
codeDuo activation code in the format <code>-<base64host> (from the Duo admin QR code)

Examples

>>> h.duo.get_device_registration('ABCDEF-dGVzdC5kdW9zZWN1cml0eS5jb20=')

duo.get_grant_token(auth_url)

Handles Duo Security MFA stages and returns the grant_token used to finish logging into Synack. Supports both HOTP passcode and registered virtual device push, selected automatically based on configured credentials.

ArgumentsDescription
auth_urlDuo Security Authentication URL generated by sending credentials to Synack

Examples

>>> h.duo.get_grant_token('https:///...duosecurity.com/...')
'Y8....6g'

duo.get_passcode()

Generates the next Duo Mobile offline HOTP passcode for the registered virtual device and increments otp_count in the database. Returns None if no HOTP secret is configured.

Examples

>>> h.duo.get_passcode()
'029833'

duo.set_push_approved(attempts=10, approvals=1, sleep=5, verified_push_code=None)

Fetches pending Duo push transactions for the registered virtual device and approves them. Called automatically during login when duo_akey is set in the database.

ArgumentsDescription
attemptsNumber of polling attempts. 0 polls forever.
approvalsStop after approving this many transactions. 0 approves all transactions found.
sleepSeconds to wait between polling attempts.
verified_push_codeOptional number-match code for Duo Verified Push transactions.

Examples

>>> h.duo.set_push_approved()

duo.set_verified_push_code(verified_push_code, attempts=10, approvals=1, sleep=5)

Convenience wrapper for approving Duo Verified Push / number-match transactions with the displayed numeric code. Plain push transactions are approved normally.

ArgumentsDescription
verified_push_codeNumber shown on the login screen.
attemptsNumber of polling attempts. 0 polls forever.
approvalsStop after approving this many transactions. 0 approves all transactions found.
sleepSeconds to wait between polling attempts.

Examples

>>> h.duo.set_verified_push_code('244')