Skip to content

Instantly share code, notes, and snippets.

@leomos
Created May 10, 2016 18:43
Show Gist options
  • Save leomos/c452401d8e1507b768022ac129797c43 to your computer and use it in GitHub Desktop.
Save leomos/c452401d8e1507b768022ac129797c43 to your computer and use it in GitHub Desktop.
Fortigate firewall connection
#!/bin/bash
USER="user"
PASSWORD="password"
SEP="+++++"
TMP=`curl -s -D - www.google.it | grep Location`
echo "Header with magic: "$TMP
MAGIC=`echo $TMP | grep -o '[[:alnum:]]\{16\}' | tr -d '\r\n'`
echo "Magic extracted from header: "$MAGIC
echo $SEP
echo "First request."
curl --verbose -s 'http://172.17.0.1:1000/fgtauth?'$MAGIC -H 'Host: 172.17.0.1:1000' -H 'Connection: keep-alive'
sleep 1
echo $SEP
echo "Second request with affermative response to the License Agreement."
curl --verbose -s 'http://172.17.0.1:1000/' -H 'Host: 172.17.0.1:1000' -H 'Referer: http://172.17.0.1:1000/fgtauth?'$MAGIC -H 'Connection: keep-alive' --data '4Tredir=http%3A%2F%2Fgoogle.it%2F&magic='$MAGIC'&answer=1'
sleep 1
echo $SEP
echo "Last request with access credentials."
curl --verbose -s 'http://172.17.0.1:1000/' -H 'Host: 172.17.0.1:1000' -H 'Referer: http://172.17.0.1:1000/' -H 'Connection: keep-alive' --data '4Tredir=http%3A%2F%2Fgoogle.it%2F&magic='$MAGIC'&username='$USER'&password='$PASSWORD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment