Skip to content

Commit

Permalink
Separating the secionts somewhat
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsoft committed Nov 27, 2016
1 parent 58a023b commit 5507ac3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doBackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
hostname=$1;
username=$2;
password=$3;

([ -z "$hostname" ] || [ -z "$username" ] || [ -z "$password" ]) && echo "all 3 arguments must be specified: hostname username password " && exit 1;

csrf=$(curl -Ss --insecure --cookie-jar /tmp/$hostname-cookies.txt https://$hostname/diag_backup.php | sed -n 's/.*name=.__csrf_magic. value="\([^"]*\)".*/\1/p')
csrf2=$(curl -Ss --insecure --location --cookie-jar /tmp/$hostname-cookies.txt --cookie /tmp/$hostname-cookies.txt --data "login=Login&usernamefld=$username&passwordfld=$password&__csrf_magic=$csrf" https://$hostname/diag_backup.php | sed -n 's/.*var csrfMagicToken = "\([^"]*\)".*/\1/p')

curl -Ss --insecure --cookie /tmp/$hostname-cookies.txt --cookie-jar /tmp/$hostname-cookies.txt --data "Submit=download&donotbackuprrd=yes&__csrf_magic=$csrf2" https://$hostname/diag_backup.php > config-router-`date +%Y%m%d%H%M%S`.xml

rm /tmp/$hostname-cookies.txt;

0 comments on commit 5507ac3

Please sign in to comment.