Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Trying to change FW rules with script

    Scheduled Pinned Locked Moved General pfSense Questions
    1 Posts 1 Posters 210 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      TobiasS
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.