Skip to content

Instantly share code, notes, and snippets.

@dragonman225
Created February 5, 2020 06:34
Show Gist options
  • Save dragonman225/8260ed63da6df46d585d56ceaf8e1219 to your computer and use it in GitHub Desktop.
Save dragonman225/8260ed63da6df46d585d56ceaf8e1219 to your computer and use it in GitHub Desktop.
Login NCTU dorm network from the command line
#!/bin/bash
# Login NCTU
UA="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
BASE_URL="https://dorm.nctu.edu.tw"
PATH="/cgi-bin/ace_web_auth.cgi?web_jumpto=&orig_referer=www.google.com"
read -p "Student ID : " username
read -p "NCTU Portal Password : " password
FORMDATA="username=${username}&userpwd=${password}"
/usr/bin/curl -H "${UA}" -d "${FORMDATA}" -X POST -vv -L -o index.html "${BASE_URL}${PATH}"
# Complete login
PATH2="/login_online_detail.php?show_portal=1&orig_referer=www.google.com&login_page="
/usr/bin/curl -L -o index.html -vv "${BASE_URL}${PATH2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment