SHARE
TWEET

Automatic authentication on SFR WiFi network

a guest Nov 10th, 2014 3,711 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Auto-connect to SFR WiFi
  4. # To use in combination with wicd
  5. # by vincesafe (Twitter: @vincesafe / blog: vincesafe.fr)
  6.  
  7. # VARS
  8. # location: URL associated with 302 reply (contains challenge)
  9. # challenge: part of POST data to be sent
  10. # target: target URL for POST
  11. # nasid: hotspot's MAC address (part of location)
  12. # mac: client's MAC address (part of location)
  13. # uamport: same here
  14. # uamip: same here
  15. # mode, channel: ...
  16. # uname: username
  17. # pass: password
  18. uname=#SFR ADDRESS OR TELEPHONE NUMBER
  19. pass=#ACCOUNT PASSWORD
  20. target=https://hotspot.wifi.sfr.fr/nb4_crypt.php
  21.  
  22. # Step 0: wait for the connection to establish
  23. sleep 2
  24.  
  25. # Step 1: get the location with wget
  26. wget -O /dev/null -o loc http://perdu.com
  27. echo `grep Location loc` > loc
  28. location=`awk 'BEGIN { FS=" " } { print $2 }' loc`
  29.  
  30.  
  31. # Step 2: extract challenge, MAC addresses, ... from location
  32.  
  33. challenge=`awk 'BEGIN { FS="&" } { print $4 }' loc | awk 'BEGIN { FS="=" } { print $2 }'`
  34. nasid=`awk 'BEGIN { FS="&" } { print $6 }' loc | awk 'BEGIN { FS="=" } { print $2 }'`
  35. mac=`awk 'BEGIN { FS="&" } { print $7 }' loc | awk 'BEGIN { FS="=" } { print $2 }'`
  36. uamport=`awk 'BEGIN { FS="&" } { print $3 }' loc | awk 'BEGIN { FS="=" } { print $2 }'`
  37. uamip=`awk 'BEGIN { FS="&" } { print $2 }' loc | awk 'BEGIN { FS="=" } { print $2 }'`
  38. mode=`awk 'BEGIN { FS="&" } { print $8 }' loc | awk 'BEGIN { FS="=" } { print $2 }'`
  39. channel=`awk 'BEGIN { FS="&" } { print $9 }' loc | awk 'BEGIN { FS="=" } { print $2 }' | awk 'BEGIN { FS=" " } { print $1 }'`
  40.  
  41.  
  42.  
  43.  
  44. # Step 3: prepare POST with target URL (set in the code)
  45. postdata="choix=neuf&username=$uname&password=$pass&conditions=on&challenge=$challenge&username2=$uname&accessType=neuf&lang=fr&mode=$mode&userurl=http://perdu.com&uamip=$uamip&uamport=$uamport&channel=$channel&mac=$nasid|mac&connexion=Connexion"
  46.  
  47.  
  48. # Step 4: send POST request
  49. wget -O debug $target --post-data="$postdata"
  50.  
  51.  
  52. # Step 5: get a page on local AP
  53. newloc=`grep location debug | awk 'BEGIN { FS="\"" } { print $2 }'`
  54. wget $newloc -O newloc
  55.  
  56. # DEBUG
  57. echo START DEBUG
  58. echo challenge $challenge
  59. echo nasid $nasid
  60. echo mac $mac
  61. echo uamport $uamport
  62. echo uamip $uamip
  63. echo mode $mode
  64. echo channel $channel
  65. echo location $location
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top