Last active
March 20, 2017 16:00
-
-
Save Yengas/d53650afadabebd6493ee2b2c2a8eec7 to your computer and use it in GitHub Desktop.
Trakya Üniversitesi Fortigate Authentication Otomatikleştirme. Kısaca: bash script ile internet bağlantısını aktif tutma. $USER kısmına mail adresinizin @'den öncesini, $PASSWORD kısmına şifrenizi girin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| IP=10.40.254.2 | |
| PORT=1000 | |
| SLEEP_TIME=5 | |
| USER="USER" | |
| PASSWORD="PASS" | |
| # Color and info | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| CYAN='\033[0;36m' | |
| NC='\033[0m' # No Color | |
| SEP="---------" | |
| TMP=`curl -s -D - www.google.com | grep Location` | |
| echo -e "${CYAN}Header with magic: ${GREEN}${TMP}${NC}" | |
| MAGIC=`echo $TMP | grep -o '[[:alnum:]]\{16\}' | tr -d '\r\n'` | |
| echo -e "${CYAN}Magic extracted from header: ${GREEN}${MAGIC}${NC}" | |
| echo $SEP | |
| echo -e "${CYAN}First request.${NC}" | |
| curl --verbose -s -o /dev/null "http://$IP:$PORT/fgtauth?$MAGIC" -H "Host: $IP:$PORT" -H 'Connection: keep-alive' | |
| sleep 1 | |
| echo $SEP | |
| echo -e "${CYAN}Last request with access credentials.${NC}" | |
| TMP=`curl --verbose -s "http://$IP:$PORT/" -H "Host: $IP:$PORT" -H "Referer: http://$IP:$PORT/" -H 'Connection: keep-alive' --data '4Tredir=http%3A%2F%2Fgoogle.com%2F&magic='$MAGIC'&username='$USER'&password='$PASSWORD | grep location\.href` | |
| MAGIC=`echo $TMP | grep -o '[[:alnum:]]\{16\}' | tr -d '\r\n'` | |
| echo -e "${CYAN}New magic: ${GREEN}${MAGIC}${NC}" | |
| while true; do | |
| echo -e "${CYAN}Will wait $SLEEP_TIME seconds to ping fortigate auth server.${NC}" | |
| sleep $SLEEP_TIME | |
| echo -e "${GREEN}Sending ping to the fortigate auth server.${NC}" | |
| curl -s -o /dev/null --verbose --fail "http://$IP:$PORT/keepalive?$MAGIC" -H "Referer: http://$IP:$PORT/" -H "Connection: keep-alive" -H "Cache-Control: max-age=0" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment