Skip to content

Commit

Permalink
| grep | sed is kinda pointless; if we match and replace the entire l…
Browse files Browse the repository at this point in the history
…ine with sed -n s///p then we can remove the need for grep at all; although this has coupled the order of the attributes
  • Loading branch information
mintsoft committed Nov 27, 2016
1 parent bb4cefa commit 2a0c22e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doBackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ hostname=$1;
username=$2;
password=$3;

csrf=$(curl -Ss --insecure --cookie-jar /tmp/$hostname-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 | 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 | 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

Expand Down

0 comments on commit 2a0c22e

Please sign in to comment.