Browse Source

Merge pull request #16612 from dibdot/travelmate

travelmate: update to 2.0.7
lilik-openwrt-22.03
Dirk Brenken 3 years ago
committed by GitHub
parent
commit
a1159bf37c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 118 additions and 196 deletions
  1. +2
    -2
      net/travelmate/Makefile
  2. +4
    -12
      net/travelmate/files/chs-hotel.login
  3. +0
    -49
      net/travelmate/files/db-bahn.login
  4. +3
    -9
      net/travelmate/files/generic-user-pass.login
  5. +4
    -12
      net/travelmate/files/h-hotels.login
  6. +5
    -15
      net/travelmate/files/julianahoeve.login
  7. +7
    -15
      net/travelmate/files/telekom.login
  8. +2
    -6
      net/travelmate/files/travelmate.mail
  9. +34
    -14
      net/travelmate/files/travelmate.sh
  10. +2
    -6
      net/travelmate/files/travelmate.vpn
  11. +21
    -18
      net/travelmate/files/vodafone.login
  12. +34
    -0
      net/travelmate/files/wifibahn.login
  13. +0
    -38
      net/travelmate/files/wifionice.login

+ 2
- 2
net/travelmate/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=travelmate PKG_NAME:=travelmate
PKG_VERSION:=2.0.6
PKG_VERSION:=2.0.7
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE:=GPL-3.0-or-later
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org> PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
@ -17,7 +17,7 @@ define Package/travelmate
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
TITLE:=A wlan connection manager for travel router TITLE:=A wlan connection manager for travel router
DEPENDS:=+iwinfo +jshn +jsonfilter +curl +ca-bundle
DEPENDS:=+iwinfo +jshn +jsonfilter +curl +ca-bundle +wpa-supplicant
PKGARCH:=all PKGARCH:=all
endef endef


+ 4
- 12
net/travelmate/files/chs-hotel.login View File

@ -6,16 +6,12 @@
# set (s)hellcheck exceptions # set (s)hellcheck exceptions
# shellcheck disable=1091,2181,3040 # shellcheck disable=1091,2181,3040
. "/lib/functions.sh"
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
# source function library if necessary
#
if [ -z "${_C}" ]; then
. "/lib/functions.sh"
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:90.0) Gecko/20100101 Firefox/90.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")"
@ -28,13 +24,9 @@ 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)" 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)" cl_id="$(awk '/cl_id/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
rm -f "/tmp/${trm_domain}.cookie" rm -f "/tmp/${trm_domain}.cookie"
if [ -z "${lg_id}" ] || [ -z "${ta_id}" ] || [ -z "${cl_id}" ]; then
exit 1
fi
{ [ -z "${lg_id}" ] || [ -z "${ta_id}" ] || [ -z "${cl_id}" ]; } && exit 1
# final login request # final login request
# #
"${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" "${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
[ "${?}" = "0" ] && exit 0 || exit 255

+ 0
- 49
net/travelmate/files/db-bahn.login View File

@ -1,49 +0,0 @@
#!/bin/sh
# 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.
# set (s)hellcheck exceptions
# shellcheck disable=1091,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="wifi.bahn.de"
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)"
# get 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}"
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
# post request to subscribe to the portal API
#
"${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
# final post request to authenticate to the portal API
#
"${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

+ 3
- 9
net/travelmate/files/generic-user-pass.login View File

@ -6,16 +6,12 @@
# set (s)hellcheck exceptions # set (s)hellcheck exceptions
# shellcheck disable=1091,2039,3040 # shellcheck disable=1091,2039,3040
. "/lib/functions.sh"
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
# source function library if necessary
#
if [ -z "${_C}" ]; then
. "/lib/functions.sh"
fi
user="${1}" user="${1}"
password="${2}" password="${2}"
success="Thank you!" success="Thank you!"
@ -27,6 +23,4 @@ trm_fetch="$(command -v curl)"
# login with credentials # login with credentials
# #
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}")" 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
[ -z "${raw_html##*${success}*}" ] && exit 0 || exit 255

+ 4
- 12
net/travelmate/files/h-hotels.login View File

@ -6,16 +6,12 @@
# set (s)hellcheck exceptions # set (s)hellcheck exceptions
# shellcheck disable=1091,2181,3040 # shellcheck disable=1091,2181,3040
. "/lib/functions.sh"
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
# source function library if necessary
#
if [ -z "${_C}" ]; then
. "/lib/functions.sh"
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:90.0) Gecko/20100101 Firefox/90.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")"
@ -28,13 +24,9 @@ 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)" 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)" 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" rm -f "/tmp/${trm_domain}.cookie"
if [ -z "${ses_id}" ] || [ -z "${sec_id}" ] || [ -z "${dev_id}" ]; then
exit 1
fi
{ [ -z "${ses_id}" ] || [ -z "${sec_id}" ] || [ -z "${dev_id}" ]; } && exit 1
# final post request # final post request
# #
"${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" "${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
[ "${?}" = "0" ] && exit 0 || exit 255

+ 5
- 15
net/travelmate/files/julianahoeve.login View File

@ -6,16 +6,12 @@
# set (s)hellcheck exceptions # set (s)hellcheck exceptions
# shellcheck disable=1091,2039,2181,3040 # shellcheck disable=1091,2039,2181,3040
. "/lib/functions.sh"
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
# source function library if necessary
#
if [ -z "${_C}" ]; then
. "/lib/functions.sh"
fi
trm_domain="n23.network-auth.com" 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_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_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")"
@ -25,22 +21,16 @@ trm_fetch="$(command -v curl)"
# get redirect url # 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}")" 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
[ -z "${redirect_url}" ] && exit 1
# get session cookie # 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}" "${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)" session_id="$(awk '/p_splash_session/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
rm -f "/tmp/${trm_domain}.cookie" rm -f "/tmp/${trm_domain}.cookie"
if [ -z "${session_id}" ]; then
exit 2
fi
[ -z "${session_id}" ] && exit 2
# final login request # 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" "${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" ] && exit 0 || exit 255

+ 7
- 15
net/travelmate/files/telekom.login View File

@ -6,15 +6,7 @@
# set (s)hellcheck exceptions # set (s)hellcheck exceptions
# shellcheck disable=1091,3040,3043,3057 # 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
. "/lib/functions.sh"
# url encoding function # url encoding function
# #
@ -39,6 +31,10 @@ urlencode()
done done
} }
export LC_ALL=C
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
set -o pipefail
username="$(urlencode "${1}")" username="$(urlencode "${1}")"
password="$(urlencode "${2}")" password="$(urlencode "${2}")"
trm_domain="telekom.portal.fon.com" trm_domain="telekom.portal.fon.com"
@ -51,14 +47,10 @@ trm_fetch="$(command -v curl)"
# #
raw_html="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --location --silent --show-error "${trm_captiveurl}")" 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("&amp;","\\&");printf "%s",$0}' 2>/dev/null)" 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("&amp;","\\&");printf "%s",$0}' 2>/dev/null)"
if [ -z "${redirect_url}" ]; then
exit 1
fi
[ -z "${redirect_url}" ] && exit 1
# final login request # 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}")" 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)" 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
[ -n "${login_url}" ] && exit 0 || exit 255

+ 2
- 6
net/travelmate/files/travelmate.mail View File

@ -8,16 +8,12 @@
# Please note: you have to setup the package 'msmtp' before using this script # Please note: you have to setup the package 'msmtp' before using this script
. "/lib/functions.sh"
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
# source function library if necessary
#
if [ -z "${_C}" ]; then
. "/lib/functions.sh"
fi
trm_debug="$(uci_get travelmate global trm_debug "0")" trm_debug="$(uci_get travelmate global trm_debug "0")"
trm_mailreceiver="$(uci_get travelmate global trm_mailreceiver)" trm_mailreceiver="$(uci_get travelmate global trm_mailreceiver)"
trm_mailprofile="$(uci_get travelmate global trm_mailprofile "trm_notify")" trm_mailprofile="$(uci_get travelmate global trm_mailprofile "trm_notify")"


+ 34
- 14
net/travelmate/files/travelmate.sh View File

@ -10,7 +10,7 @@ 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
trm_ver="2.0.6"
trm_ver="2.0.7"
trm_enabled="0" trm_enabled="0"
trm_debug="0" trm_debug="0"
trm_iface="" trm_iface=""
@ -148,9 +148,9 @@ f_char() {
# wifi helper function # wifi helper function
# #
f_wifi() { f_wifi() {
local status radio timeout="0"
local status radio radio_up timeout="0"
"${trm_wifi}" reconf
"${trm_wifi}" reload
for radio in ${trm_radiolist}; do for radio in ${trm_radiolist}; do
while true; do while true; do
if [ "${timeout}" -ge "${trm_maxwait}" ]; then if [ "${timeout}" -ge "${trm_maxwait}" ]; then
@ -159,6 +159,10 @@ f_wifi() {
status="$("${trm_wifi}" status 2>/dev/null)" status="$("${trm_wifi}" status 2>/dev/null)"
if [ "$(printf "%s" "${status}" | jsonfilter -q -l1 -e "@.${radio}.up")" != "true" ] || if [ "$(printf "%s" "${status}" | jsonfilter -q -l1 -e "@.${radio}.up")" != "true" ] ||
[ "$(printf "%s" "${status}" | jsonfilter -q -l1 -e "@.${radio}.pending")" != "false" ]; then [ "$(printf "%s" "${status}" | jsonfilter -q -l1 -e "@.${radio}.pending")" != "false" ]; then
if [ "${radio}" != "${radio_up}" ]; then
"${trm_wifi}" up "${radio}"
radio_up="${radio}"
fi
timeout="$((timeout + 1))" timeout="$((timeout + 1))"
sleep 1 sleep 1
else else
@ -166,8 +170,10 @@ f_wifi() {
fi fi
done done
done done
sleep "$((trm_maxwait / 6))"
timeout="$((timeout + (trm_maxwait / 6)))"
if [ "${timeout}" -lt "${trm_maxwait}" ]; then
sleep "$((trm_maxwait / 6))"
timeout="$((timeout + (trm_maxwait / 6)))"
fi
f_log "debug" "f_wifi ::: radio_list: ${trm_radiolist}, radio: ${radio}, timeout: ${timeout}" f_log "debug" "f_wifi ::: radio_list: ${trm_radiolist}, radio: ${radio}, timeout: ${timeout}"
} }
@ -179,10 +185,9 @@ f_vpn() {
vpn="$(f_getval "vpn")" vpn="$(f_getval "vpn")"
vpn_service="$(f_getval "vpnservice")" vpn_service="$(f_getval "vpnservice")"
vpn_iface="$(f_getval "vpniface")" vpn_iface="$(f_getval "vpniface")"
if [ -z "${vpn_action}" ]; then
[ "${vpn}" = "1" ] && vpn_action="enable" || vpn_action="disable"
fi
if [ -x "${trm_vpnpgm}" ] && [ -n "${vpn_service}" ] && [ -n "${vpn_iface}" ]; then
[ -z "${vpn_action}" ] && { [ "${vpn}" = "1" ] && vpn_action="enable" || vpn_action="disable"; }
if [ -x "${trm_vpnpgm}" ] && [ -n "${vpn_service}" ] && [ -n "${vpn_iface}" ] && [ -f "${trm_ntpfile}" ]; then
if { [ "${vpn_action}" = "disable" ] && [ -f "${trm_vpnfile}" ]; } || if { [ "${vpn_action}" = "disable" ] && [ -f "${trm_vpnfile}" ]; } ||
{ [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; } || { [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; } ||
{ [ "${vpn}" != "1" ] && [ "${vpn_action}" = "enable" ] && [ -f "${trm_vpnfile}" ]; }; then { [ "${vpn}" != "1" ] && [ "${vpn_action}" = "enable" ] && [ -f "${trm_vpnfile}" ]; }; then
@ -211,13 +216,20 @@ f_mac() {
uci_set "wireless" "${section}" "macaddr" "${result}" uci_set "wireless" "${section}" "macaddr" "${result}"
elif [ "${trm_randomize}" = "1" ]; then elif [ "${trm_randomize}" = "1" ]; then
result="$(hexdump -n6 -ve '/1 "%.02X "' /dev/random 2>/dev/null | result="$(hexdump -n6 -ve '/1 "%.02X "' /dev/random 2>/dev/null |
awk -v local="2,6,A,E" -v seed="$(date +%s)" 'BEGIN{srand(seed)}NR==1{split(local,b,",");seed=int(rand()*4+1);printf "%s%s:%s:%s:%s:%s:%s",substr($1,0,1),b[seed],$2,$3,$4,$5,$6}')"
awk -v local="2,6,A,E" -v seed="$(date +%s)" 'BEGIN{srand(seed)}NR==1{split(local,b,",");
seed=int(rand()*4+1);printf "%s%s:%s:%s:%s:%s:%s",substr($1,0,1),b[seed],$2,$3,$4,$5,$6}')"
uci_set "wireless" "${section}" "macaddr" "${result}" uci_set "wireless" "${section}" "macaddr" "${result}"
else else
result="$(uci_get "wireless" "${section}" "macaddr")"
uci_remove "wireless" "${section}" "macaddr" 2>/dev/null
ifname="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -q -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
result="$(${trm_iwinfo} "${ifname}" info 2>/dev/null | awk '/Access Point:/{printf "%s",$3}')"
fi fi
elif [ "${action}" = "get" ]; then elif [ "${action}" = "get" ]; then
result="$(uci_get "wireless" "${section}" "macaddr")" result="$(uci_get "wireless" "${section}" "macaddr")"
if [ -z "${result}" ]; then
ifname="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -q -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
result="$(${trm_iwinfo} "${ifname}" info 2>/dev/null | awk '/Access Point:/{printf "%s",$3}')"
fi
fi fi
printf "%s" "${result}" printf "%s" "${result}"
f_log "debug" "f_mac ::: action: ${action:-"-"}, section: ${section:-"-"}, macaddr: ${macaddr:-"-"}, result: ${result:-"-"}" f_log "debug" "f_mac ::: action: ${action:-"-"}, section: ${section:-"-"}, macaddr: ${macaddr:-"-"}, result: ${result:-"-"}"
@ -568,9 +580,17 @@ f_check() {
login_script_args="$(f_getval "script_args")" login_script_args="$(f_getval "script_args")"
"${login_script}" ${login_script_args} >/dev/null 2>&1 "${login_script}" ${login_script_args} >/dev/null 2>&1
rc="${?}" rc="${?}"
f_log "info" "captive portal login for '${cp_domain}' has been executed with rc '${rc}'"
if [ "${rc}" = "0" ]; then
result="$(f_net)"
if [ "${rc}" = "255" ]; then
f_log "info" "captive portal login script for '${cp_domain}' failed with rc '${rc}'"
unset trm_connection
trm_ifstatus="${status}"
f_jsnup
break
else
f_log "info" "captive portal login script for '${cp_domain}' has been finished with rc '${rc}'"
if [ "${rc}" = "0" ]; then
result="$(f_net)"
fi
fi fi
fi fi
fi fi


+ 2
- 6
net/travelmate/files/travelmate.vpn View File

@ -8,16 +8,12 @@
# Please note: you have to setup the package 'wireguard' or 'openvpn' before using this script # Please note: you have to setup the package 'wireguard' or 'openvpn' before using this script
. "/lib/functions.sh"
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
# source function library if necessary
#
if [ -z "${_C}" ]; then
. "/lib/functions.sh"
fi
vpn="${1}" vpn="${1}"
vpn_action="${2}" vpn_action="${2}"
vpn_service="${3}" vpn_service="${3}"


+ 21
- 18
net/travelmate/files/vodafone.login View File

@ -6,16 +6,12 @@
# set (s)hellcheck exceptions # set (s)hellcheck exceptions
# shellcheck disable=1091,3040 # shellcheck disable=1091,3040
. "/lib/functions.sh"
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
# source function library if necessary
#
if [ -z "${_C}" ]; then
. "/lib/functions.sh"
fi
username="${1}" username="${1}"
password="${2}" password="${2}"
trm_domain="hotspot.vodafone.de" trm_domain="hotspot.vodafone.de"
@ -26,24 +22,31 @@ trm_fetch="$(command -v curl)"
# get sid # 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
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}")"
sid="$(printf "%s" "${redirect_url}" 2>/dev/null | awk 'BEGIN{FS="[=&]"}{printf "%s",$2}')"
[ -z "${sid}" ] && exit 1
# get session # 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}")" 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')" session="$(printf "%s" "${raw_html}" 2>/dev/null | jsonfilter -q -l1 -e '@.session')"
if [ -z "${session}" ]; then
exit 2
fi
[ -z "${session}" ] && exit 2
ids="$(printf "%s" "${raw_html}" 2>/dev/null | jsonfilter -q -e '@.loginProfiles[*].id' | sort -n | awk '{ORS=" ";print $0}')"
for id in ${ids}; do
if [ "${id}" = "4" ]; then
login_id="4"
access_type="csc-community"
account_type="csc"
break
fi
done
[ -z "${login_id}" ] && exit 3
# final login request # 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
if [ "${login_id}" = "4" ] && [ -n "${username}" ] && [ -n "${password}" ]; then
raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" --silent --connect-timeout $((trm_maxwait / 6)) --data "loginProfile=${login_id}&accessType=${access_type}&accountType=${account_type}&password=${password}&session=${session}&username=${username}" "https://${trm_domain}/api/v4/login?sid=${sid}")"
fi fi
success="$(printf "%s" "${raw_html}" 2>/dev/null | jsonfilter -q -l1 -e '@.success')"
[ "${success}" = "true" ] && exit 0 || exit 255

+ 34
- 0
net/travelmate/files/wifibahn.login View File

@ -0,0 +1,34 @@
#!/bin/sh
# captive portal auto-login script for bahn hotspots (DE)
# Copyright (c) 2020-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
. "/lib/functions.sh"
export LC_ALL=C
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
set -o pipefail
trm_domain="wifi.bahn.de"
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)"
# get security token
#
"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --silent --show-error --output /dev/null "https://${trm_domain}/en/"
sec_token="$(awk '/csrf/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
rm -f "/tmp/${trm_domain}.cookie"
[ -z "${sec_token}" ] && exit 1
# final post request
#
if [ -z "$redirect_url" ]; then
raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --connect-timeout $((trm_maxwait / 6)) --header "Cookie: csrf=${sec_token}" --data "login=true&CSRFToken=${sec_token}" --silent --show-error "https://${trm_domain}/en/")"
else
raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --connect-timeout $((trm_maxwait / 6)) --header "Cookie: PHPSESSID=${sec_token}" --data "login=true&PHPSESSID=${sec_token}" --silent --show-error "${redirect_url}")"
fi
[ -z "${raw_html}" ] && exit 0 || exit 255

+ 0
- 38
net/travelmate/files/wifionice.login View File

@ -1,38 +0,0 @@
#!/bin/sh
# 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.
# set (s)hellcheck exceptions
# shellcheck disable=1091,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="www.wifionice.de"
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)"
# 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/"
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
# final post request
#
"${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

Loading…
Cancel
Save