summaryrefslogtreecommitdiff
path: root/iptv.sh
diff options
context:
space:
mode:
authorLi Zhineng <[email protected]>2024-07-05 21:09:56 +0800
committerGitHub <[email protected]>2024-07-05 21:09:56 +0800
commitd75b66b20217c3df378db138566c028038c0b9b3 (patch)
tree5e279fd59db392450b450d51b95e7d526f499da1 /iptv.sh
parent9aec9bfbd4d6370423927fdd7b8bc0bb0f8aa811 (diff)
parent94cc9f8998228d2b4f372e228919a5bab9c6b9ec (diff)
downloadchina-unicom-iptv-gd-d75b66b20217c3df378db138566c028038c0b9b3.tar.gz
china-unicom-iptv-gd-d75b66b20217c3df378db138566c028038c0b9b3.zip
Merge pull request #2 from lizhineng/decrypt
Find a possible key for authinfo
Diffstat (limited to 'iptv.sh')
-rwxr-xr-xiptv.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/iptv.sh b/iptv.sh
index c91c824..f562a13 100755
--- a/iptv.sh
+++ b/iptv.sh
@@ -226,6 +226,54 @@ make_playlist () {
exit 0
}
+decrypt_authinfo () {
+ local authinfo="$1"
+
+ if [[ -z "$authinfo" ]]; then
+ fatal "Requires authinfo data from /EPG/oauth/v2/token"
+ fi
+
+ authinfo=$(echo -n "$authinfo" | xxd -r -p)
+
+ local loading=("Still working." "Still working.." "Still working...")
+
+ local key
+ for ((i=0; i<1000000; i++)); do
+ key=$(printf "%06d" "$i")
+
+ if (( i % 100 == 0 )); then
+ echo -ne "\r\033[K${loading[i % 3]} $((i / 1000000 * 100))%"
+ fi
+
+ local result=$(echo -n "$authinfo" | \
+ openssl enc -d -des-ede3 -K "$(echo -n "${key}000000000000000000" | xxd -p -c 0)" 2>/dev/null | \
+ tr -d '\0')
+
+ if echo -n "$result" | grep -q OTT; then
+ IFS='$' read -ra components <<< "$result"
+
+ echo -e "\n"
+ echo "========================================"
+ echo "Found key: $key"
+ echo "========================================"
+ echo "$result"
+ echo "========================================"
+ echo " random: ${components[0]}"
+ echo " encry token: ${components[1]}"
+ echo " user id: ${components[2]}"
+ echo " device id: ${components[3]}"
+ echo " ip address: ${components[4]}"
+ echo " mac address: ${components[5]}"
+ echo " reserved: ${components[6]}"
+ echo " ott: ${components[7]}"
+
+ exit 0
+ fi
+ done
+
+ fatal "Could not find a possible key."
+}
+
##
## Main
##
@@ -234,6 +282,7 @@ while [ $# -gt 0 ]; do
case "$1" in
make:playlist) shift 1; make_playlist "$@";;
make:epg) shift 1; make_epg "$@";;
+ decrypt:authinfo) shift 1; decrypt_authinfo "$@";;
*) echo "Unknown command: $1"; exit 1;;
esac
done