You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
959 B

  1. #!/bin/sh
  2. # captive portal auto-login script for german ICE hotspots
  3. # written by Dirk Brenken (dev@brenken.org)
  4. # This is free software, licensed under the GNU General Public License v3.
  5. # You should have received a copy of the GNU General Public License
  6. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7. domain="www.wifionice.de"
  8. cmd="$(command -v curl)"
  9. # curl check
  10. #
  11. if [ ! -x "${cmd}" ]
  12. then
  13. exit 1
  14. fi
  15. # initial get request to receive & extract a valid security token
  16. #
  17. "${cmd}" "http://${domain}/en/" -s -o /dev/null -c "/tmp/${domain}.cookie"
  18. if [ -f "/tmp/${domain}.cookie" ]
  19. then
  20. sec_token="$(awk '/csrf/{print $7}' "/tmp/${domain}.cookie")"
  21. rm -f "/tmp/${domain}.cookie"
  22. else
  23. exit 2
  24. fi
  25. # final post request/login with valid session cookie/security token
  26. #
  27. if [ -n "${sec_token}" ]
  28. then
  29. "${cmd}" "http://${domain}/en/" -H "Cookie: csrf=${sec_token}" --data "login=true&CSRFToken=${sec_token}&connect="
  30. else
  31. exit 3
  32. fi