Trying to change FW rules with script
-
I'm trying to programatically enabling and disabling FW rules from outside the firewall. I try to mimic this with some curl calls. The last call where i want to do a get at http://192.168.0.1/firewall_rules.php?act=toggle&if=lan&id=15. It fails for some reason. Do you get it to work or know what I'm thinking wrong here?
#Get CSRF
curl -i -s -L -k --cookie-jar cookies.txt http://192.168.0.1/ | grep "name='__csrf_magic'" | sed 's/.value="(.)".*/\1/' > csrf.txt#Login
echo LOGIN
curl -i -s -k --cookie cookies.txt
--cookie-jar cookies.txt
--data-urlencode "login=Login"
--data-urlencode "usernamefld=USER"
--data-urlencode "passwordfld=USERPASSWORD"
--data-urlencode "__csrf_magic=$(cat csrf.txt)"
http://192.168.0.1/#Toggle
echo TOGGLE
curl -v -X GET
--cookie cookies.txt
--cookie-jar cookies.txt
--data-urlencode "__csrf_magic=$(cat csrf.txt)"
--data-urlencode "act=toggle"
--data-urlencode "if=lan"
--data-urlencode "id=15"
http://192.168.0.1/firewall_rules.php