Skip to content

Instantly share code, notes, and snippets.

@michaelsproul
Created July 26, 2013 23:36
Show Gist options
  • Save michaelsproul/6092951 to your computer and use it in GitHub Desktop.
Save michaelsproul/6092951 to your computer and use it in GitHub Desktop.
Logon to myUNSW with curl
#!/bin/bash
# A filthy bash script to fetch a timetable from myUNSW
# Add your credentials here
USERNAME=""
PASSWORD=""
MYUNSW="https://ssologin.unsw.edu.au/cas/login?service=https%3A%2F%2Fmy.unsw.edu.au%2Famserver%2FUI%2FLogin%3Fmodule%3DISISWSSO%26IDToken1%3D"
TIMETABLE="https://my.unsw.edu.au/active/studentTimetable/timetable.xml"
COOKIE=unsw-cookie
# This is required, presumably to prevent automated logins... (no match for copy and paste!)
STUPID="_cNoOpConversation+id_krO0ABXNyAGFvcmcuc3ByaW5nZnJhbWV3b3JrLndlYmZsb3cuZXhlY3V0aW9uLnJlcG9zaXRvcnkuY29udGludWF0aW9uLlNlcmlhbGl6ZWRGbG93RXhlY3V0aW9uQ29udGludWF0aW9uPMZQHZQEyycMAAB4cgBXb3JnLnNwcmluZ2ZyYW1ld29yay53ZWJmbG93LmV4ZWN1dGlvbi5yZXBvc2l0b3J5LmNvbnRpbnVhdGlvbi5GbG93RXhlY3V0aW9uQ29udGludWF0aW9ujvgpwtO1430CAAB4cHoAAAQAAAALEB-LCAAAAAAAAAClWXtsHEcZn9hxGjtxenk7fYY0tElK75o2TR_OA_tsJ1fOjetzkqrhkfHu-G7jvZ3N7Kx9BtpGRYmQaAmghpdaCirlpYiWCkFFkUoa2j8oraAiQi0gVUIgAeJR8QeiqMD3zc4-7m7tu6iWstn9Zub3ffPN95rvzv6VdHmC3M5FOeu5wnLKU4JW2SwX09lZNjll89ksc8qWw7JW1bWzI0AYrjHDlxZ3CkDpu22l95dvnHt4OSE1V5Jem8PkG_RSQF5zjM7QLEy3s0XLmWZm0fLk8q2lD9159JObOnHR7GJCyCKYeuvFCFFinqdFKG86-5r5ketfVSIcJ_eTDpBjxmKzRZRlhItqS_BwR0nokq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Bc96krg6PKxKOHVAx7_Qv3HTnR_9SiTtJZICsNtH1LzhUcQ6iOaYEsZ0HvNM99Rx4hy_QndjEhjxxJsS03bOP7IpwQGL2e8JlX73k84221w65tjxv9qf2sbf4dDXT5o6GTZz7_7A93BL-yLsdWvG7MBxfGPkn2XFxTPu13g5trNbdWq_0fB1M7VUkeAAABeA.."
if [ -e $COOKIE ]
then
rm $COOKIE
fi
# Login with a POST request
curl -c $COOKIE --data "lt=$STUPID&_eventId=submit&username=$USERNAME&password=$PASSWORD&submit=Agree+%26+Sign+On" "$MYUNSW" --location > /dev/null
# Using the stored cookie, you can get whatever you like
curl -b $COOKIE $TIMETABLE > timetable.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment