travelmate: update to 2.0.4lilik-openwrt-22.03
@ -1,43 +1,40 @@ | |||||
#!/bin/sh | #!/bin/sh | ||||
# captive portal auto-login script for german chs hotels | |||||
# Copyright (c) 2020 Dirk Brenken (dev@brenken.org) | |||||
# captive portal auto-login script for chs hotels (DE) | |||||
# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | # This is free software, licensed under the GNU General Public License v3. | ||||
# set (s)hellcheck exceptions | # set (s)hellcheck exceptions | ||||
# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188 | |||||
# shellcheck disable=1091,2181,3040 | |||||
export LC_ALL=C | export LC_ALL=C | ||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | ||||
set -o pipefail | set -o pipefail | ||||
if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ] | |||||
then | |||||
# source function library if necessary | |||||
# | |||||
if [ -z "${_C}" ]; then | |||||
. "/lib/functions.sh" | . "/lib/functions.sh" | ||||
fi | fi | ||||
trm_domain="hotspot.internet-for-guests.com" | trm_domain="hotspot.internet-for-guests.com" | ||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | ||||
trm_fetch="$(command -v curl)" | trm_fetch="$(command -v curl)" | ||||
# initial get request to receive & extract valid security tokens | |||||
# get security tokens | |||||
# | # | ||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/logon/cgi/index.cgi" | |||||
if [ -r "/tmp/${trm_domain}.cookie" ] | |||||
then | |||||
lg_id="$(awk '/LGNSID/{print $7}' "/tmp/${trm_domain}.cookie")" | |||||
ta_id="$(awk '/ta_id/{print $7}' "/tmp/${trm_domain}.cookie")" | |||||
cl_id="$(awk '/cl_id/{print $7}' "/tmp/${trm_domain}.cookie")" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
else | |||||
exit 2 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/logon/cgi/index.cgi" | |||||
lg_id="$(awk '/LGNSID/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
ta_id="$(awk '/ta_id/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
cl_id="$(awk '/cl_id/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
if [ -z "${lg_id}" ] || [ -z "${ta_id}" ] || [ -z "${cl_id}" ]; then | |||||
exit 1 | |||||
fi | fi | ||||
# final post request/login with valid session cookie/security token | |||||
# final login request | |||||
# | # | ||||
if [ -n "${lg_id}" ] && [ -n "${ta_id}" ] && [ -n "${cl_id}" ] | |||||
then | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}/logon/cgi/index.cgi" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: LGNSID=${lg_id}; lang=en_US; use_mobile_interface=0; ta_id=${ta_id}; cl_id=${cl_id}" --data "accept_termsofuse=&freeperperiod=1&device_infos=1125:2048:1152:2048" --output /dev/null "https://${trm_domain}/logon/cgi/index.cgi" | |||||
else | |||||
exit 3 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}/logon/cgi/index.cgi" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: LGNSID=${lg_id}; lang=en_US; use_mobile_interface=0; ta_id=${ta_id}; cl_id=${cl_id}" --data "accept_termsofuse=&freeperperiod=1&device_infos=1125:2048:1152:2048" --output /dev/null "https://${trm_domain}/logon/cgi/index.cgi" | |||||
if [ "${?}" != "0" ]; then | |||||
exit 2 | |||||
fi | fi |
@ -1,65 +1,49 @@ | |||||
#!/bin/sh | #!/bin/sh | ||||
# captive portal auto-login script for german DB hotspots via portal login API | |||||
# Copyright (c) 2020 Dirk Brenken (dev@brenken.org) | |||||
# captive portal auto-login script for DB hotspots (DE) | |||||
# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | # This is free software, licensed under the GNU General Public License v3. | ||||
# set (s)hellcheck exceptions | # set (s)hellcheck exceptions | ||||
# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188 | |||||
# shellcheck disable=1091,2181,3040 | |||||
export LC_ALL=C | export LC_ALL=C | ||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | ||||
set -o pipefail | set -o pipefail | ||||
if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ] | |||||
then | |||||
# source function library if necessary | |||||
# | |||||
if [ -z "${_C}" ]; then | |||||
. "/lib/functions.sh" | . "/lib/functions.sh" | ||||
fi | fi | ||||
trm_domain="wifi.bahn.de" | trm_domain="wifi.bahn.de" | ||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | ||||
trm_fetch="$(command -v curl)" | trm_fetch="$(command -v curl)" | ||||
# initial get request to receive all header information | |||||
# | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}" | |||||
# extract the session cookie and the hotspot location | |||||
# get all header information | |||||
# | # | ||||
if [ -s "/tmp/${trm_domain}.cookie" ] | |||||
then | |||||
sec_token="$(awk 'BEGIN{FS="[ ;]"}/^Set-Cookie:/{print $2}' "/tmp/${trm_domain}.cookie")" | |||||
location="$(awk '/^Location:/{print $2}' "/tmp/${trm_domain}.cookie")" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
else | |||||
exit 2 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait / 6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}" | |||||
sec_token="$(awk 'BEGIN{FS="[ ;]"}/^Set-Cookie:/{print $2}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
location="$(awk '/^Location:/{print $2}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
if [ -z "${sec_token}" ] || [ -z "${location}" ]; then | |||||
exit 1 | |||||
fi | fi | ||||
# post request to subscribe to the portal API | # post request to subscribe to the portal API | ||||
# | # | ||||
if [ -n "${sec_token}" ] && [ -n "${location}" ] | |||||
then | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait/6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --header "Cookie: ${sec_token}" --data "action=subscribe&type=one&connect_policy_accept=false&user_login=&user_password=&user_password_confirm=&email_address=&prefix=&phone=&policy_accept=false&gender=&interests=" --output /dev/null "https://${trm_domain}/portal_api.php" | |||||
else | |||||
exit 3 | |||||
fi | |||||
# extract additional login and password information from the portal API | |||||
# | |||||
if [ -s "/tmp/${trm_domain}.cookie" ] | |||||
then | |||||
login="$(awk 'BEGIN{FS="[\"]"}/^\{\"info/{print $12}' "/tmp/${trm_domain}.cookie")" | |||||
password="$(awk 'BEGIN{FS="[\"]"}/^\{\"info/{print $16}' "/tmp/${trm_domain}.cookie")" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
else | |||||
exit 4 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait / 6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --header "Cookie: ${sec_token}" --data "action=subscribe&type=one&connect_policy_accept=false&user_login=&user_password=&user_password_confirm=&email_address=&prefix=&phone=&policy_accept=false&gender=&interests=" --output /dev/null "https://${trm_domain}/portal_api.php" | |||||
login="$(awk 'BEGIN{FS="[\"]"}/^\{\"info/{print $12}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
password="$(awk 'BEGIN{FS="[\"]"}/^\{\"info/{print $16}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
if [ -z "${login}" ] && [ -z "${password}" ]; then | |||||
exit 2 | |||||
fi | fi | ||||
# final post request to authenticate to the portal API | # final post request to authenticate to the portal API | ||||
# | # | ||||
if [ -n "${login}" ] && [ -n "${password}" ] | |||||
then | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: ${sec_token}" --data "action=authenticate&login=${login}&password=${password}&policy_accept=false&from_ajax=true&wispr_mode=false" "https://${trm_domain}/portal_api.php" | |||||
else | |||||
exit 5 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: ${sec_token}" --data "action=authenticate&login=${login}&password=${password}&policy_accept=false&from_ajax=true&wispr_mode=false" "https://${trm_domain}/portal_api.php" | |||||
if [ "${?}" != "0" ]; then | |||||
exit 3 | |||||
fi | fi |
@ -1,35 +1,32 @@ | |||||
#!/bin/sh | #!/bin/sh | ||||
# captive portal auto-login script template with credentials as parameters | # captive portal auto-login script template with credentials as parameters | ||||
# Copyright (c) 2020 Dirk Brenken (dev@brenken.org) | |||||
# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | # This is free software, licensed under the GNU General Public License v3. | ||||
# set (s)hellcheck exceptions | # set (s)hellcheck exceptions | ||||
# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188 | |||||
# shellcheck disable=1091,2039,3040 | |||||
export LC_ALL=C | export LC_ALL=C | ||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | ||||
set -o pipefail | set -o pipefail | ||||
if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ] | |||||
then | |||||
# source function library if necessary | |||||
# | |||||
if [ -z "${_C}" ]; then | |||||
. "/lib/functions.sh" | . "/lib/functions.sh" | ||||
fi | fi | ||||
trm_domain="example.com" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | |||||
trm_fetch="$(command -v curl)" | |||||
user="${1}" | user="${1}" | ||||
password="${2}" | password="${2}" | ||||
success="Thank you!" | success="Thank you!" | ||||
trm_domain="example.com" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | |||||
trm_fetch="$(command -v curl)" | |||||
# login with credentials | # login with credentials | ||||
# | # | ||||
response="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --data "username=${user}&password=${password}" --header "Content-Type:application/x-www-form-urlencoded" "http://${trm_domain}")" | |||||
if [ -n "$(printf "%s" "${response}" | grep "${success}")" ] | |||||
then | |||||
exit 0 | |||||
else | |||||
exit 2 | |||||
raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --silent --show-error --header "Content-Type:application/x-www-form-urlencoded" --data "username=${user}&password=${password}" "http://${trm_domain}")" | |||||
if [ -n "${raw_html##*${success}*}" ]; then | |||||
exit 1 | |||||
fi | fi |
@ -1,43 +1,40 @@ | |||||
#!/bin/sh | #!/bin/sh | ||||
# captive portal auto-login script for Telekom hotspots in german h+hotels | |||||
# Copyright (c) 2020 Dirk Brenken (dev@brenken.org) | |||||
# captive portal auto-login script for Telekom hotspots in h+hotels (DE) | |||||
# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | # This is free software, licensed under the GNU General Public License v3. | ||||
# set (s)hellcheck exceptions | # set (s)hellcheck exceptions | ||||
# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188 | |||||
# shellcheck disable=1091,2181,3040 | |||||
export LC_ALL=C | export LC_ALL=C | ||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | ||||
set -o pipefail | set -o pipefail | ||||
if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ] | |||||
then | |||||
. "/lib/functions.sh" | |||||
# source function library if necessary | |||||
# | |||||
if [ -z "${_C}" ]; then | |||||
. "/lib/functions.sh" | |||||
fi | fi | ||||
trm_domain="hotspot.t-mobile.net" | trm_domain="hotspot.t-mobile.net" | ||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | ||||
trm_fetch="$(command -v curl)" | trm_fetch="$(command -v curl)" | ||||
# initial get request to receive & extract valid security tokens | |||||
# get security tokens | |||||
# | # | ||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/wlan/rest/freeLogin" | |||||
if [ -r "/tmp/${trm_domain}.cookie" ] | |||||
then | |||||
ses_id="$(awk '/JSESSIONID/{print $7}' "/tmp/${trm_domain}.cookie")" | |||||
sec_id="$(awk '/DT_H/{print $7}' "/tmp/${trm_domain}.cookie")" | |||||
dev_id="$(sha256sum /etc/config/wireless | awk '{printf "%s",substr($1,1,13)}')" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
else | |||||
exit 2 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/wlan/rest/freeLogin" | |||||
ses_id="$(awk '/JSESSIONID/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
sec_id="$(awk '/DT_H/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
dev_id="$(sha256sum /etc/config/wireless 2>/dev/null | awk '{printf "%s",substr($1,1,13)}' 2>/dev/null)" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
if [ -z "${ses_id}" ] || [ -z "${sec_id}" ] || [ -z "${dev_id}" ]; then | |||||
exit 1 | |||||
fi | fi | ||||
# final post request/login with valid session cookie/security token | |||||
# final post request | |||||
# | # | ||||
if [ -n "${ses_id}" ] && [ -n "${sec_id}" ] && [ -n "${dev_id}" ] | |||||
then | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}/TD/hotspot/H_Hotels/en_GB/index.html" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: JSESSIONID=${ses_id}; DT_DEV_ID=${dev_id}; DT_H=${sec_id}" --data "rememberMe=true" --output /dev/null "https://${trm_domain}/wlan/rest/freeLogin" | |||||
else | |||||
exit 3 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}/TD/hotspot/H_Hotels/en_GB/index.html" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: JSESSIONID=${ses_id}; DT_DEV_ID=${dev_id}; DT_H=${sec_id}" --data "rememberMe=true" --output /dev/null "https://${trm_domain}/wlan/rest/freeLogin" | |||||
if [ "${?}" != "0" ]; then | |||||
exit 2 | |||||
fi | fi |
@ -0,0 +1,46 @@ | |||||
#!/bin/sh | |||||
# captive portal auto-login script for Julianahoeve beach resort (NL) | |||||
# Copyright (c) 2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | |||||
# set (s)hellcheck exceptions | |||||
# shellcheck disable=1091,2039,2181,3040 | |||||
export LC_ALL=C | |||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | |||||
set -o pipefail | |||||
# source function library if necessary | |||||
# | |||||
if [ -z "${_C}" ]; then | |||||
. "/lib/functions.sh" | |||||
fi | |||||
trm_domain="n23.network-auth.com" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")" | |||||
trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | |||||
trm_fetch="$(command -v curl)" | |||||
# get redirect url | |||||
# | |||||
redirect_url="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --write-out "%{redirect_url}" --silent --show-error --output /dev/null "${trm_captiveurl}")" | |||||
if [ -z "${redirect_url}" ]; then | |||||
exit 1 | |||||
fi | |||||
# get session cookie | |||||
# | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://${trm_domain}" --silent --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "${redirect_url}" | |||||
session_id="$(awk '/p_splash_session/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
if [ -z "${session_id}" ]; then | |||||
exit 2 | |||||
fi | |||||
# final login request | |||||
# | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${redirect_url}" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: p_splash_session=${session_id};" --output /dev/null "https://${trm_domain}/Camping-Julianah/hi/IHYW9cx/grant" | |||||
if [ "${?}" != "0" ]; then | |||||
exit 3 | |||||
fi |
@ -0,0 +1,64 @@ | |||||
#!/bin/sh | |||||
# captive portal auto-login script for telekom hotspots (DE) | |||||
# Copyright (c) 2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | |||||
# set (s)hellcheck exceptions | |||||
# shellcheck disable=1091,3040,3043,3057 | |||||
export LC_ALL=C | |||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | |||||
set -o pipefail | |||||
# source function library if necessary | |||||
# | |||||
if [ -z "${_C}" ]; then | |||||
. "/lib/functions.sh" | |||||
fi | |||||
# url encoding function | |||||
# | |||||
urlencode() | |||||
{ | |||||
local chr str="${1}" len="${#1}" pos=0 | |||||
while [ "${pos}" -lt "${len}" ]; do | |||||
chr="${str:pos:1}" | |||||
case "${chr}" in | |||||
[a-zA-Z0-9.~_-]) | |||||
printf "%s" "${chr}" | |||||
;; | |||||
" ") | |||||
printf "%%20" | |||||
;; | |||||
*) | |||||
printf "%%%02X" "'${chr}" | |||||
;; | |||||
esac | |||||
pos=$((pos + 1)) | |||||
done | |||||
} | |||||
username="$(urlencode "${1}")" | |||||
password="$(urlencode "${2}")" | |||||
trm_domain="telekom.portal.fon.com" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")" | |||||
trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | |||||
trm_fetch="$(command -v curl)" | |||||
# get redirect url | |||||
# | |||||
raw_html="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --location --silent --show-error "${trm_captiveurl}")" | |||||
redirect_url="$(printf "%s" "${raw_html}" | awk 'match(tolower($0),/<loginurl>.*<\/loginurl>/){printf "%s",substr($0,RSTART+10,RLENGTH-21)}' 2>/dev/null | awk '{gsub("&","\\&");printf "%s",$0}' 2>/dev/null)" | |||||
if [ -z "${redirect_url}" ]; then | |||||
exit 1 | |||||
fi | |||||
# final login request | |||||
# | |||||
raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}" --connect-timeout $((trm_maxwait / 6)) --header "content-type: application/x-www-form-urlencoded" --location --silent --show-error --data "UserName=${username}&Password=${password}&FNAME=0&button=Login&OriginatingServer=http%3A%2F%2F${trm_captiveurl}" "${redirect_url}")" | |||||
login_url="$(printf "%s" "${raw_html}" | awk 'match(tolower($0),/<logoffurl>.*<\/logoffurl>/){printf "%s",substr($0,RSTART+11,RLENGTH-23)}' 2>/dev/null)" | |||||
if [ -z "${login_url}" ]; then | |||||
exit 2 | |||||
fi |
@ -1,34 +1,19 @@ | |||||
#!/bin/sh | #!/bin/sh | ||||
# ntp hotplug script for travelmate | # ntp hotplug script for travelmate | ||||
# Copyright (c) 2020 Dirk Brenken (dev@brenken.org) | |||||
# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | # This is free software, licensed under the GNU General Public License v3. | ||||
# set (s)hellcheck exceptions | # set (s)hellcheck exceptions | ||||
# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188 | |||||
# shellcheck disable=3023 | |||||
trm_init="/etc/init.d/travelmate" | trm_init="/etc/init.d/travelmate" | ||||
trm_ntpfile="/var/state/travelmate.ntp" | trm_ntpfile="/var/state/travelmate.ntp" | ||||
trm_logger="$(command -v logger)" | trm_logger="$(command -v logger)" | ||||
f_log() | |||||
{ | |||||
local class="${1}" log_msg="${2}" | |||||
if [ -x "${trm_logger}" ] | |||||
then | |||||
"${trm_logger}" -p "${class}" -t "trm-ntp [${$}]" "${log_msg}" | |||||
else | |||||
printf "%s %s %s\\n" "${class}" "trm-ntp [${$}]" "${log_msg}" | |||||
fi | |||||
} | |||||
if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && [ "$("${trm_init}" enabled; printf "%u" ${?})" = "0" ] | |||||
then | |||||
if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && "${trm_init}" enabled; then | |||||
{ | { | ||||
flock -xn 1001 | |||||
if [ "$?" = "0" ] | |||||
then | |||||
f_log "info" "get ntp time sync" | |||||
if flock -xn 1001; then | |||||
"${trm_logger}" -p "info" -t "trm-ntp [${$}]" "get ntp time sync" 2>/dev/null | |||||
"${trm_init}" restart | "${trm_init}" restart | ||||
fi | fi | ||||
} 1001>"${trm_ntpfile}" | } 1001>"${trm_ntpfile}" | ||||
@ -0,0 +1,49 @@ | |||||
#!/bin/sh | |||||
# captive portal auto-login script for vodafone hotspots (DE) | |||||
# Copyright (c) 2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | |||||
# set (s)hellcheck exceptions | |||||
# shellcheck disable=1091,3040 | |||||
export LC_ALL=C | |||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | |||||
set -o pipefail | |||||
# source function library if necessary | |||||
# | |||||
if [ -z "${_C}" ]; then | |||||
. "/lib/functions.sh" | |||||
fi | |||||
username="${1}" | |||||
password="${2}" | |||||
trm_domain="hotspot.vodafone.de" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")" | |||||
trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | |||||
trm_fetch="$(command -v curl)" | |||||
# get sid | |||||
# | |||||
raw_html="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --write-out "%{redirect_url}" --silent --show-error --output /dev/null "${trm_captiveurl}")" | |||||
sid="$(printf "%s" "${raw_html}" 2>/dev/null | awk 'BEGIN{FS="[=&]"}{printf "%s",$2}')" | |||||
if [ -z "${sid}" ]; then | |||||
exit 1 | |||||
fi | |||||
# get session | |||||
# | |||||
raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" --silent --connect-timeout $((trm_maxwait / 6)) "https://${trm_domain}/api/v4/session?sid=${sid}")" | |||||
session="$(printf "%s" "${raw_html}" 2>/dev/null | jsonfilter -q -l1 -e '@.session')" | |||||
if [ -z "${session}" ]; then | |||||
exit 2 | |||||
fi | |||||
# final login request | |||||
# | |||||
raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" --silent --connect-timeout $((trm_maxwait / 6)) --data "accessType=csc-community&accountType=csc&loginProfile=4&password=${password}&session=${session}&username=${username}&save=true" "https://${trm_domain}/api/v4/login?sid=${sid}")" | |||||
success="$(printf "%s" "${raw_html}" 2>/dev/null | jsonfilter -q -l1 -e '@.success')" | |||||
if [ "${success}" != "true" ]; then | |||||
exit 3 | |||||
fi |
@ -1,41 +1,38 @@ | |||||
#!/bin/sh | #!/bin/sh | ||||
# captive portal auto-login script for german ICE hotspots | |||||
# Copyright (c) 2020 Dirk Brenken (dev@brenken.org) | |||||
# captive portal auto-login script for ICE hotspots (DE) | |||||
# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org) | |||||
# This is free software, licensed under the GNU General Public License v3. | # This is free software, licensed under the GNU General Public License v3. | ||||
# set (s)hellcheck exceptions | # set (s)hellcheck exceptions | ||||
# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188 | |||||
# shellcheck disable=1091,2181,3040 | |||||
export LC_ALL=C | export LC_ALL=C | ||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | export PATH="/usr/sbin:/usr/bin:/sbin:/bin" | ||||
set -o pipefail | set -o pipefail | ||||
if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ] | |||||
then | |||||
. "/lib/functions.sh" | |||||
# source function library if necessary | |||||
# | |||||
if [ -z "${_C}" ]; then | |||||
. "/lib/functions.sh" | |||||
fi | fi | ||||
trm_domain="www.wifionice.de" | trm_domain="www.wifionice.de" | ||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")" | |||||
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")" | |||||
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | trm_maxwait="$(uci_get travelmate global trm_maxwait "30")" | ||||
trm_fetch="$(command -v curl)" | trm_fetch="$(command -v curl)" | ||||
# initial get request to receive & extract a valid security token | |||||
# get security token | |||||
# | # | ||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}/en/" | |||||
if [ -f "/tmp/${trm_domain}.cookie" ] | |||||
then | |||||
sec_token="$(awk '/csrf/{print $7}' "/tmp/${trm_domain}.cookie")" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
else | |||||
exit 2 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}/en/" | |||||
sec_token="$(awk '/csrf/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)" | |||||
rm -f "/tmp/${trm_domain}.cookie" | |||||
if [ -z "${sec_token}" ]; then | |||||
exit 1 | |||||
fi | fi | ||||
# final post request/login with valid session cookie/security token | |||||
# final post request | |||||
# | # | ||||
if [ -n "${sec_token}" ] | |||||
then | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: csrf=${sec_token}" --data "login=true&CSRFToken=${sec_token}&connect=" --output /dev/null "http://${trm_domain}/en/" | |||||
else | |||||
exit 3 | |||||
"${trm_fetch}" --user-agent "${trm_useragent}" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: csrf=${sec_token}" --data "login=true&CSRFToken=${sec_token}&connect=" --output /dev/null "http://${trm_domain}/en/" | |||||
if [ "${?}" != "0" ]; then | |||||
exit 2 | |||||
fi | fi |