Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Smart Lock App MFA support #276

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ by this tool are:
| Dual prompt | ``.../signin/challenge/dp/...`` |
| (Validate 2FA ) | |
+------------------+-------------------------------------+
| Security key OTP | ``.../signin/challenge/skotp/...`` |
| (Google Smart | |
| Lock App) | |
+------------------+-------------------------------------+
| Backup code | ``... (unknown yet) ...`` |
| (printed codes) | |
+------------------+-------------------------------------+
Expand Down
36 changes: 36 additions & 0 deletions aws_google_auth/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ def do_login(self):
sess = self.handle_prompt(sess)
elif "challenge/sk/" in sess.url:
sess = self.handle_sk(sess)
elif "challenge/skotp/" in sess.url:
sess = self.handle_skotp(sess)
elif "challenge/iap/" in sess.url:
sess = self.handle_iap(sess)
elif "challenge/dp/" in sess.url:
Expand Down Expand Up @@ -691,6 +693,38 @@ def handle_totp(self, sess):
# Submit TOTP
return self.post(challenge_url, data=payload)

def handle_skotp(self, sess):
response_page = BeautifulSoup(sess.text, 'html.parser')
challenge_url = sess.url.split("?")[0]

security_code = input("Security code: ") or None

if not security_code:
raise ValueError(
"MFA token required for {} but none supplied.".format(
self.config.username))

payload = {
'challengeId': response_page.find('input', {'name': 'challengeId'}).get('value'),
'challengeType': response_page.find('input', {'name': 'challengeType'}).get('value'),
'ifkv': response_page.find('input', {'name': 'ifkv'}).get('value'),
'checkedDomains': response_page.find('input', {'name': 'checkedDomains'}).get('value'),
'checkConnection': response_page.find('input', {'name': 'checkConnection'}).get('value'),
'continue': response_page.find('input', {'name': 'continue'}).get('value'),
'flowName': response_page.find('input', {'name': 'flowName'}).get('value'),
'followup': response_page.find('input', {'name': 'followup'}).get('value'),
'faa': response_page.find('input', {'name': 'faa'}).get('value'),
'oauth': response_page.find('input', {'name': 'oauth'}).get('value'),
'scc': response_page.find('input', {'name': 'scc'}).get('value'),
'sarp': response_page.find('input', {'name': 'sarp'}).get('value'),
'ltmpl': response_page.find('input', {'name': 'ltmpl'}).get('value'),
'TL': response_page.find('input', {'name': 'TL'}).get('value'),
'gxf': response_page.find('input', {'name': 'gxf'}).get('value'),
'Pin': security_code,
}

return self.post(challenge_url, data=payload)

def handle_dp(self, sess):
response_page = BeautifulSoup(sess.text, 'html.parser')

Expand Down Expand Up @@ -844,6 +878,8 @@ def handle_selectchallenge(self, sess):
challenges.append(['YubiKey', i.attrs.get("data-challengeentry")])
elif "challenge/az/" in action:
challenges.append(['Google Prompt', i.attrs.get("data-challengeentry")])
elif "challenge/totp/" in action:
challenges.append(['Security Key', i.attrs.get("data-challengeentry")])

print('Choose MFA method from available:')
for i, mfa in enumerate(challenges, start=1):
Expand Down