Advertisement
Guest User

Untitled

a guest
Nov 16th, 2017
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #!/bin/sh
  2. [ -f /opt/bin/curl ] && alias curl=/opt/bin/curl || alias curl=$(which curl)
  3. alias
  4. echo $0 $1 $2 $3 $4 v150202test
  5. log() {
  6. echo $(TZ=UTC-1CEST date +%H%M ) " c"$c ": "$1
  7. }
  8. if [ $# -lt 2 ] ; then echo usage : hwr_S.sh login passwd [period] ; exit 0 ; fi
  9. login=$1
  10. pass=$2
  11. interval=$3
  12. interface_reseau="wlan0"
  13. ip_gateway="192.168.2.1"
  14. ip_portal="109.0.74.75"
  15. hotspot_url="hotspot.wifi.sfr.fr"
  16.  
  17.  
  18. route add $ip_portal gw $ip_gateway $interface_reseau >/dev/null 2>&1
  19. if [ $? == 0 ]; then log "Création de la route enpruntant "$interface_reseau" vers l'ip "$ip_portal"\n"; fi
  20. let c=0
  21. while true; do
  22. let c=c+1
  23. challenge=`curl -sS $ip_gateway:3990| grep challenge|sed -r 's/.*challenge=([0-9a-f]+).*/\1/'`
  24. if [ -n "${challenge}" ]
  25. then
  26. log "challenge="$challenge""
  27. 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`
  28. R1=$?
  29. # log "REPONSE RECUE : "$response""
  30.  
  31. jspopupurl=$(echo "$response"| sed -nr 's|.*window.location.*"(.*)";.*|\1|p')
  32. RESULT=`curl -s $jspopupurl|grep "http://"$ip_gateway":3990"`
  33. R2=$?
  34. # log "RESULT : $RESULT"
  35. log "R1,2 : $R1 $R2"
  36. if [ -n "${RESULT}" ]; then
  37. log "re-connexion OK"
  38. else
  39. log "failure"
  40. fi
  41. else
  42. log "connexion OK"
  43. fi
  44. sleep $interval
  45. done
  46. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement