Created
July 31, 2012 19:09
-
-
Save grapeot/3219601 to your computer and use it in GitHub Desktop.
Auto login script for CMU blackboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import re | |
# Initial request for blackboard | |
r = requests.get('http://blackboard.andrew.cmu.edu/') | |
# Authenticaton | |
payload = { 'j_username' : '<your username>', 'j_password' : '<your password>', 'j_continue' : '1', 'submit' : 'Login' } | |
r2 = requests.post(r.url, data=payload, cookies=r.cookies) | |
# Manually proceed with the form | |
url = 'https://blackboard.andrew.cmu.edu/Shibboleth.sso/SAML2/POST' | |
relayState = str(re.search('name="RelayState" value="(.*)"', r2.text).group(1)).replace(':', ':') | |
samlResponse = str(re.search('name="SAMLResponse" value="(.*)"', r2.text).group(1)) | |
r3 = requests.post(url, data={'RelayState': relayState, 'SAMLResponse': samlResponse}, cookies=r2.cookies) |
r4 = requests.post(url, data={'action': 'refreshAjaxModule', 'modId': '_4_1','tabId':'_1_1','tab_tab_group_id':'_1_1','RelayState': relayState, 'SAMLResponse': samlResponse}, cookies=r3.cookies, verify=False)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Depends on requests,
before running.