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

Working w/Duo config #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sprabhuanand
Copy link

@sprabhuanand sprabhuanand commented Apr 14, 2020

The code from the master is not working with the latest DUO security. So, update the code and it works with Duo Security. Comments are added inline to the changes I did.

The code from the master is not working with the latest DUO security. So, update the code and it works with Duo Security
LOG = logging.getLogger('alohomora.req')

csrf="";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DUO looks for the csrf token when requesting for TFA. So made that as global var.

@@ -213,11 +216,17 @@ def login_one_factor(self, username, password):
elif "pass" in name.lower():
# Make an educated guess that this is the right field for the password
payload[name] = password
elif "csrfp_token" in name.lower():
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs csrfp_token and AuthState in the header, else it fails with this error

Traceback (most recent call last):
File "main.py", line 282, in
Main().main()
File "main.py", line 196, in main
(okay, response) = provider.login_two_factor(response, auth_device)
File "/usr/local/lib/python3.7/site-packages/alohomora/req.py", line 280, in login_two_factor
sigs = sig_request.split(':')
AttributeError: 'NoneType' object has no attribute 'split'

else:
# Populate the parameter with the existing value (picks up hidden fields as well)
# payload[name] = value
pass
payload['_eventId_proceed'] = ''
#payload['_eventId_proceed'] = ''
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is not needed

for inputtag in soup.find_all(re.compile('form', re.IGNORECASE)):
action = inputtag.get('action')
if action:
parsedurl = urlparse.urlparse(self.idp_url)
idpauthformsubmiturl = parsedurl.scheme + "://" + parsedurl.netloc + action
idpauthformsubmiturl = parsedurl.scheme + "://" + parsedurl.netloc + "/dag/module.php/core/loginuserpass.php"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form action they converted to "?", hence changing the action part to the loginuserpass endpoint.

payload = {
'_eventId_proceed': 'transition',
'sig_response': '%s:%s' % (signed_auth, app_sig)
'sig_response': '%s:%s' % (signed_auth, app_sig),
'csrfp_token': csrf
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed a csrfp token, else the req gets forbidden

@@ -562,8 +563,11 @@ def _get_assertion(self, soup):
LOG.debug('Pulling out SAML assertion')
form = soup.find('form')
input_tag = form.find('input')
LOG.debug('Found assertion %s', input_tag['value'])
return input_tag['value']
for inputtag in soup.find_all('input'):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the parsing for samlresponse. Now, we have multiple input tags in the response code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant