WatchGuard Auth Script

As we have a nice WatchGuard firewall at work, we needed a script to authenticate from an outside Linux machine to open our ports for fetching files from FTP. For this I wrote this little script:

UPDATE: I changed it a bit to use the SED script for URL encoding.

wgauth.sh
#!/bin/sh
# Change this IP to the WatchGuard Auth Applet:
URL="https://123.123.123.123:4100"
read -p "Enter username: " USER
echo -n "Enter password: "
/bin/stty -echo
read PASS
/bin/stty echo
echo ""
DOMAIN=Firebox-DB
#DOMAIN=RADIUS
 
# change this to the SED script
SEDSCRIPT=/path/to/urlencode.sed
 
USER=`echo $USER | sed -f $SEDSCRIPT`
PASS=`echo $PASS | sed -f $SEDSCRIPT`
 
# POST with multipart/form-data (form name: user_auth_form)
TMP=`tempfile -p WG`
POST="fw_username=${USER}&fw_password=${PASS}&fw_domain=${DOMAIN}&submit=Login&action=fw_logon&style=fw_logon_progress.xsl&fw_logon_ty
pe=logon"
echo "Sending login data..."
wget --quiet -S -O "$TMP" --no-check-certificate --post-data="$POST" "$URL/?action=fw_logon&style=fw_logon.xsl&fw_logon_type=status"
 
REQID=`cat "$TMP" | egrep -o "<reqId>(.*)</reqId>" | sed 's/<reqId>\(.*\)<\/reqId>/\1/g'`
rm "$TMP"
echo "Got Request ID: $REQID"
 
sleep 2
URI="/?action=fw_logon&style=fw_logon_progress.xsl&fw_logon_type=progress&fw_reqId=${REQID}"
echo "Requesting login status..."
wget --quiet -S -O "$TMP" --no-check-certificate "${URL}${URI}"
 
STATUS=`cat "$TMP" | egrep -o "<logon_status>(.*)</logon_status>" | sed 's/<logon_status>\(.*\)<\/logon_status>/\1/g'`
echo "Status: $STATUS"
rm "$TMP"
if [ $STATUS = "1" ]; then
    echo "Logged in successfully."
else
    echo "Login failed for some reason. Please try again."
fi

 
software/sh/watchguard-auth-script.txt · Last modified: 2010-01-15 14:31.50 by mbirth
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Contents powered by Club-Mate Contents powered by BassDrive.com Labelled with ICRA