Skip to content

Instantly share code, notes, and snippets.

@leoheck
Last active March 14, 2020 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoheck/9e0c276d00afbdfd3a7f5e5cf8d05ec2 to your computer and use it in GitHub Desktop.
Save leoheck/9e0c276d00afbdfd3a7f5e5cf8d05ec2 to your computer and use it in GitHub Desktop.
Attempt to automate host authentication in PUCRS using curl
#!/bin/bash
# By Leandro Heck (leoheck@gmail.com)
# Save this script in /usr/bin/authenticate_pucrs
# Usage
# authenticate_pucrs 12981829
# Automating..
# echo "minhaSenha" | authenticate_pucrs 12981829
# Automating with crontab
# 0 */6 * * * echo "senha" | authenticate_pucrs 12981829
authenticate_pucrs()
{
user=$1
echo -n "password for $user: "
read -s pass
if [[ $# != 1 ]]; then
echo -e "\nUSAGE: $0 <MATRICULA>\n"
return 1
fi
set -x
curl 'https://gwpolicy02.pucrs.br/Login' \
--tlsv1.2 --ciphers \
-v \
-o /tmp/response \
-w "\nStatus: %{http_code}\n\n" \
--compressed \
-H 'Host: gwpolicy02.pucrs.br' \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'Accept-Language: en-US,en;q=0.5' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Referer: https://gwpolicy02.pucrs.br/PortalMain' \
-H 'Cookie: cpnacportal_login_type=password; cpnacportal_username=10084214; NACSID=5cde328e527b64ce23477b2582092642' \
-H 'Connection: keep-alive' \
--data realm=passwordRealm \
--data username="$user" \
--data password="$password"
{ set +x; } 2>/dev/null
cat /tmp/response 2> /dev/null
rm -rf /tmp/response
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment