Skip to content

Commit 8daa4a2

Browse files
fix: allanime openssl aes-256-ctr decryption (#1650)
1 parent c5733bd commit 8daa4a2

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ pkg install termux-am
159159

160160
For players you can use the apk (playstore/fdroid) versions of mpv and vlc. Note that these cannot be checked from termux so a warning is generated when checking dependencies.
161161

162+
**Note:** The `openssl` CLI utility is in the `openssl-tool` package on Termux, not `openssl`. Install it with:
163+
```sh
164+
pkg install openssl-tool
165+
```
166+
162167
</details>
163168

164169
### Tier 2 Support: Windows, WSL, iOS, Steam Deck, FreeBSD
@@ -507,7 +512,8 @@ apk del grep sed curl fzf git aria2 ffmpeg ncurses
507512
- yt-dlp - m3u8 Downloader
508513
- ffmpeg - m3u8 Downloader (fallback)
509514
- fzf - User interface
510-
- ani-skip (optional)
515+
- openssl (for decrypting encrypted video sources; on Termux, the CLI is in the `openssl-tool` package)
516+
- ani-skip (optional, for auto-skipping anime intros)
511517
- patch - Self updating
512518

513519
### Ani-Skip

ani-cli

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
version_number="4.11.0"
3+
version_number="4.12.0"
44

55
# UI
66

@@ -208,13 +208,29 @@ select_quality() {
208208
episode=$(printf "%s" "$result" | cut -d'>' -f2)
209209
}
210210

211+
decode_tobeparsed() {
212+
tmp="$(mktemp)"
213+
printf '%s' "$1" | base64 -d >"$tmp"
214+
iv="$(dd if="$tmp" bs=1 count=12 2>/dev/null | od -A n -t x1 | tr -d ' \n')"
215+
ctr="${iv}00000002"
216+
plain="$(dd if="$tmp" bs=1 skip=12 2>/dev/null | openssl enc -d -aes-256-ctr -K "$allanime_key" -iv "$ctr" -nosalt -nopad 2>/dev/null)"
217+
rm -f "$tmp"
218+
printf '%s' "$plain" | tr '{}' '\n' | sed -nE 's|.*"sourceUrl":"--([^"]*)".*"sourceName":"([^"]*)".*|\2 :\1|p'
219+
}
220+
211221
# gets embed urls, collects direct links into provider files, selects one with desired quality into $episode
212222
get_episode_url() {
213223
# get the embed urls of the selected episode
214224
#shellcheck disable=SC2016
215225
episode_embed_gql='query ($showId: String!, $translationType: VaildTranslationTypeEnumType!, $episodeString: String!) { episode( showId: $showId translationType: $translationType episodeString: $episodeString ) { episodeString sourceUrls }}'
216226

217-
resp=$(curl -e "$allanime_refr" -s -H "Content-Type: application/json" -X POST "${allanime_api}/api" --data "{\"variables\":{\"showId\":\"$id\",\"translationType\":\"$mode\",\"episodeString\":\"$ep_no\"},\"query\":\"$episode_embed_gql\"}" -A "$agent" | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"--([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
227+
api_resp="$(curl -e "$allanime_refr" -s -H "Content-Type: application/json" -X POST "${allanime_api}/api" --data "{\"variables\":{\"showId\":\"$id\",\"translationType\":\"$mode\",\"episodeString\":\"$ep_no\"},\"query\":\"$episode_embed_gql\"}" -A "$agent")"
228+
if printf "%s" "$api_resp" | grep -q '"tobeparsed"'; then
229+
blob="$(printf "%s" "$api_resp" | sed -nE 's|.*"tobeparsed":"([^"]*)".*|\1|p')"
230+
resp="$(decode_tobeparsed "$blob")"
231+
else
232+
resp="$(printf "%s" "$api_resp" | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"--([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')"
233+
fi
218234
# generate links into sequential files
219235
cache_dir="$(mktemp -d)"
220236
providers="1 2 3 4"
@@ -387,6 +403,7 @@ agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefo
387403
allanime_refr="https://allmanga.to"
388404
allanime_base="allanime.day"
389405
allanime_api="https://api.${allanime_base}"
406+
allanime_key="$(printf '%s' 'SimtVuagFbGR2K7P' | openssl dgst -sha256 -binary | od -A n -t x1 | tr -d ' \n')"
390407
mode="${ANI_CLI_MODE:-sub}"
391408
download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
392409
log_episode="${ANI_CLI_LOG:-1}"
@@ -490,6 +507,10 @@ done
490507
[ "$external_menu_normal_window" = "1" ] && external_menu_args="-normal-window"
491508
printf "\33[2K\r\033[1;34mChecking dependencies...\033[0m\n"
492509
dep_ch "curl" "sed" "grep" || true
510+
case "$(uname -o 2>/dev/null)" in
511+
*ndroid*) command -v openssl >/dev/null || die 'Program "openssl" not found. On Termux, install with: pkg install openssl-tool' ;;
512+
*) dep_ch "openssl" || true ;;
513+
esac
493514
[ "$skip_intro" = 1 ] && (dep_ch "ani-skip" || true)
494515
dep_ch "fzf" || true
495516
case "$player_function" in

0 commit comments

Comments
 (0)