Skip to content

Commit

Permalink
Issue #16 (work in progress/need sources): implementing '-EA' for 'en…
Browse files Browse the repository at this point in the history
…hanced authentication' to use SN and DEVID in GET requests.

- minor fix in dns regexp : '_' in path allowed
  • Loading branch information
dougy147 committed Sep 27, 2023
1 parent fad3045 commit 1b6954b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
28 changes: 26 additions & 2 deletions bin/mcbash
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ read_args() {
[[ $(echo ${args[${i}]}) == "--debug" ]] && \
debug=true && \
debug_verbose_curl="-vvvvvv"
[[ $(echo ${args[${i}]}) == "-EA" || \
$(echo ${args[${i}]}) == "--enhanced-auth" ]] && \
enhanced_auth=true
[[ $(echo ${args[${i}]}) == "--show-only-mac" ]] && \
only_outputs_mac=true
[[ $(echo ${args[${i}]}) == "-np" || \
Expand Down Expand Up @@ -163,7 +166,7 @@ inspect_dns() {
URL_IP="([0-9]{1,3}\.){3}[0-9]{1,3}"
URL_host_or_IP="($URL_host|$URL_IP)"
URL_port="(:[0-9]{1,5})?"
URL_path="(/([-a-zA-Z0-9]+(/)?)?*)?"
URL_path="(/([-_a-zA-Z0-9]+(/)?)?*)?"
URL_query_string="(\?.*)?"
URL_regexp=$(echo ${URL_protocol}${URL_user_information}${URL_host_or_IP}${URL_port}${URL_path}${URL_query_string})
if ! [[ $(echo "${1}" | grep -Eo "$URL_regexp") == "${1}" ]]; then #||
Expand Down Expand Up @@ -802,11 +805,25 @@ check_curl_exit_code() {
return 0
}

make_cookie() {
cookie="mac=$mac; stb_lang=en; timezone=Europe/Amsterdam; "
if [[ -n ${enhanced_auth} ]]; then
# generate Sn and DEViD
mac_sn=$(echo -n "${mac}" | tr 'a-z' 'A-Z' | md5sum | tr 'a-z' 'A-Z')
sn=${mac_sn:0:13}
mac_dev=$(echo -n "${mac}" | tr 'a-z' 'A-Z' | sha256sum | sed "s/\ .*//g" | tr 'a-z' 'A-Z')
device_id=$mac_dev
#device_id2=
#signature=
#stb_type=
cookie="mac=$mac; sn=$sn; device_id=$device_id; stb_lang=en; timezone=Europe/Amsterdam; "
fi
}


get_handshake() {
handshake_url=$(echo $dns)'/portal.php?action=handshake&type=stb&token=&mac='$(echo $encoded_mac)
cookie="mac=$mac; stb_lang=en; timezone=Europe/Amsterdam; "
make_cookie
random_user_agent

handshake_token=$(curl $debug_verbose_curl $proxy_user_option $proxy_url_option --max-time $timeout -s -X GET -H "Accept: */*" -H "User-Agent: $(echo $user_agent)" -H "Cookie: $(echo $cookie)" "$(echo $handshake_url)"); if ! check_curl_exit_code; then return 1; fi
Expand All @@ -833,6 +850,13 @@ get_profile() {
profile_url=$(echo $dns)'/portal.php?type=account_info&action=get_main_info&mac='$(echo $mac)
profile=$(curl $debug_verbose_curl $proxy_user_option $proxy_url_option --max-time $timeout -s -X GET -H "Accept: */*" -H "User-Agent: $(echo $user_agent)" -H "Authorization: $(echo $authorization)" -H "Cookie: $(echo $cookie)" "$(echo $profile_url)"); if ! check_curl_exit_code; then return 1; fi

if [[ -n ${debug} ]]; then
full_profile_url=$(echo $dns)'/portal.php?type=stb&action=get_profile&JsHttpRequest=1-xml'
full_profile=$(curl $debug_verbose_curl $proxy_user_option $proxy_url_option --max-time $timeout -s -X GET -H "Accept: */*" -H "User-Agent: $(echo $user_agent)" -H "Authorization: $(echo $authorization)" -H "Cookie: $(echo $cookie)" "$(echo $full_profile_url)"); if ! check_curl_exit_code; then return 1; fi
echo -e "${_YELLOW}FULL_PROFILE : ${_RESET}${_BLUE}${full_profile}${_RESET}"
fi


if [[ $profile == "" ]]; then
maybeGEN1portal=true
profile_url=$(echo $dns)'/portal.php?type=stb&action=get_profile&JsHttpRequest=1-xml='$(echo $mac)
Expand Down
5 changes: 4 additions & 1 deletion func/01_args
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ read_args() {
[[ $(echo ${args[${i}]}) == "--debug" ]] && \
debug=true && \
debug_verbose_curl="-vvvvvv"
[[ $(echo ${args[${i}]}) == "-EA" || \
$(echo ${args[${i}]}) == "--enhanced-auth" ]] && \
enhanced_auth=true
[[ $(echo ${args[${i}]}) == "--show-only-mac" ]] && \
only_outputs_mac=true
[[ $(echo ${args[${i}]}) == "-np" || \
Expand Down Expand Up @@ -137,7 +140,7 @@ inspect_dns() {
URL_IP="([0-9]{1,3}\.){3}[0-9]{1,3}"
URL_host_or_IP="($URL_host|$URL_IP)"
URL_port="(:[0-9]{1,5})?"
URL_path="(/([-a-zA-Z0-9]+(/)?)?*)?"
URL_path="(/([-_a-zA-Z0-9]+(/)?)?*)?"
URL_query_string="(\?.*)?"
URL_regexp=$(echo ${URL_protocol}${URL_user_information}${URL_host_or_IP}${URL_port}${URL_path}${URL_query_string})
if ! [[ $(echo "${1}" | grep -Eo "$URL_regexp") == "${1}" ]]; then #||
Expand Down
23 changes: 22 additions & 1 deletion func/11_scan
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,25 @@ check_curl_exit_code() {
return 0
}

make_cookie() {
cookie="mac=$mac; stb_lang=en; timezone=Europe/Amsterdam; "
if [[ -n ${enhanced_auth} ]]; then
# generate Sn and DEViD
mac_sn=$(echo -n "${mac}" | tr 'a-z' 'A-Z' | md5sum | tr 'a-z' 'A-Z')
sn=${mac_sn:0:13}
mac_dev=$(echo -n "${mac}" | tr 'a-z' 'A-Z' | sha256sum | sed "s/\ .*//g" | tr 'a-z' 'A-Z')
device_id=$mac_dev
#device_id2=
#signature=
#stb_type=
cookie="mac=$mac; sn=$sn; device_id=$device_id; stb_lang=en; timezone=Europe/Amsterdam; "
fi
}


get_handshake() {
handshake_url=$(echo $dns)'/portal.php?action=handshake&type=stb&token=&mac='$(echo $encoded_mac)
cookie="mac=$mac; stb_lang=en; timezone=Europe/Amsterdam; "
make_cookie
random_user_agent

handshake_token=$(curl $debug_verbose_curl $proxy_user_option $proxy_url_option --max-time $timeout -s -X GET -H "Accept: */*" -H "User-Agent: $(echo $user_agent)" -H "Cookie: $(echo $cookie)" "$(echo $handshake_url)"); if ! check_curl_exit_code; then return 1; fi
Expand All @@ -148,6 +162,13 @@ get_profile() {
profile_url=$(echo $dns)'/portal.php?type=account_info&action=get_main_info&mac='$(echo $mac)
profile=$(curl $debug_verbose_curl $proxy_user_option $proxy_url_option --max-time $timeout -s -X GET -H "Accept: */*" -H "User-Agent: $(echo $user_agent)" -H "Authorization: $(echo $authorization)" -H "Cookie: $(echo $cookie)" "$(echo $profile_url)"); if ! check_curl_exit_code; then return 1; fi

if [[ -n ${debug} ]]; then
full_profile_url=$(echo $dns)'/portal.php?type=stb&action=get_profile&JsHttpRequest=1-xml'
full_profile=$(curl $debug_verbose_curl $proxy_user_option $proxy_url_option --max-time $timeout -s -X GET -H "Accept: */*" -H "User-Agent: $(echo $user_agent)" -H "Authorization: $(echo $authorization)" -H "Cookie: $(echo $cookie)" "$(echo $full_profile_url)"); if ! check_curl_exit_code; then return 1; fi
echo -e "${_YELLOW}FULL_PROFILE : ${_RESET}${_BLUE}${full_profile}${_RESET}"
fi


if [[ $profile == "" ]]; then
maybeGEN1portal=true
profile_url=$(echo $dns)'/portal.php?type=stb&action=get_profile&JsHttpRequest=1-xml='$(echo $mac)
Expand Down

0 comments on commit 1b6954b

Please sign in to comment.