Skip to content

Instantly share code, notes, and snippets.

@npcardoso
Created April 2, 2014 15:35
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 npcardoso/9936547 to your computer and use it in GitHub Desktop.
Save npcardoso/9936547 to your computer and use it in GitHub Desktop.
A script to refresh the password in SIGARRA when expiring.
#!/bin/bash
[[ $# != 2 ]] && echo "Usage: $0 <user> <pass>" && exit 1
USER=$1
CURRENT_PASS=$2
ORIGINAL_PASS=$2
CYCLES=5
URL="https://sigarra.up.pt/feup/pt/pass_cica.muda"
function do_params() {
USERNAME=$1
OLD=$2
NEW=$3
RET="pv_sistema=S"
RET=$RET"&pv_util=$USERNAME"
RET=$RET"&pv_anpc=$OLD"
RET=$RET"&pv_nopc=$NEW"
RET=$RET"&pv_cnpc=$NEW"
echo $RET
}
for ((i=1; i<=CYCLES; i++)); do
NEW_PASS="$ORIGINAL_PASS"$i
POST=`do_params $USER "$CURRENT_PASS" "$NEW_PASS"`
echo "Setting new pass = '$NEW_PASS'"
echo $POST
curl -s --data $POST $URL | grep "<title>"
CURRENT_PASS="$NEW_PASS"
echo "Sleeping...."
sleep 60
done
POST=`do_params $USER "$CURRENT_PASS" "$ORIGINAL_PASS"`
curl -s --data $POST $URL | grep "<title>"
@npcardoso
Copy link
Author

This script does not check whether or not the requests succeed.
One must check the output and see where the request first failed and keep track of the last password used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment