Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- [ -f /opt/bin/curl ] && alias curl=/opt/bin/curl || alias curl=$(which curl)
- alias
- echo $0 $1 $2 $3 $4 v150202test
- log() {
- echo $(TZ=UTC-1CEST date +%H%M ) " c"$c ": "$1
- }
- if [ $# -lt 2 ] ; then echo usage : hwr_S.sh login passwd [period] ; exit 0 ; fi
- login=$1
- pass=$2
- interval=$3
- interface_reseau="wlan0"
- ip_gateway="192.168.2.1"
- ip_portal="109.0.74.75"
- hotspot_url="hotspot.wifi.sfr.fr"
- route add $ip_portal gw $ip_gateway $interface_reseau >/dev/null 2>&1
- if [ $? == 0 ]; then log "Création de la route enpruntant "$interface_reseau" vers l'ip "$ip_portal"\n"; fi
- let c=0
- while true; do
- let c=c+1
- challenge=`curl -sS $ip_gateway:3990| grep challenge|sed -r 's/.*challenge=([0-9a-f]+).*/\1/'`
- if [ -n "${challenge}" ]
- then
- log "challenge="$challenge""
- response=`curl -s -d "username="$login"&password="$pass"&cond=on&challenge="$challenge --resolve $hotspot_url":443:"$ip_portal"" https://$hotspot_url/nb4_crypt.php -k`
- R1=$?
- # log "REPONSE RECUE : "$response""
- jspopupurl=$(echo "$response"| sed -nr 's|.*window.location.*"(.*)";.*|\1|p')
- RESULT=`curl -s $jspopupurl|grep "http://"$ip_gateway":3990"`
- R2=$?
- # log "RESULT : $RESULT"
- log "R1,2 : $R1 $R2"
- if [ -n "${RESULT}" ]; then
- log "re-connexion OK"
- else
- log "failure"
- fi
- else
- log "connexion OK"
- fi
- sleep $interval
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement