Skip to content

Commit

Permalink
Moving the cookie jar to a file in tmp;
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsoft committed Nov 27, 2016
1 parent 0cfa967 commit 6543c4e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions doBackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ hostname=$1;
username=$2;
password=$3;

csrf=$(curl -Ss --insecure --cookie-jar /tmp/cookies.txt https://$hostname/diag_backup.php | grep "name='__csrf_magic'" | sed 's/.*value="\(.*\)".*/\1/')
csrf=$(curl -Ss --insecure --cookie-jar /tmp/$hostname-cookies.txt https://$hostname/diag_backup.php | grep "name='__csrf_magic'" | sed 's/.*value="\(.*\)".*/\1/')
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 | grep "name='__csrf_magic'" | sed 's/.*value="\(.*\)".*/\1/' | head -n 1)
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

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

curl -Ss --insecure --cookie cookies.txt --cookie-jar 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 csrf.txt csrf2.txt cookies.txt
rm /tmp/$hostname-cookies.txt;

0 comments on commit 6543c4e

Please sign in to comment.