Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XianxinMao
Yt Dlp
提交
1d3586d0
Y
Yt Dlp
项目概览
XianxinMao
/
Yt Dlp
11 个月 前同步成功
通知
27
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
Yt Dlp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
1d3586d0
编写于
1月 31, 2022
作者:
P
pukkandan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[aes] Add unpad_pkcs7
上级
c533c89c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
45 addition
and
53 deletion
+45
-53
yt_dlp/aes.py
yt_dlp/aes.py
+15
-3
yt_dlp/cookies.py
yt_dlp/cookies.py
+7
-4
yt_dlp/downloader/fragment.py
yt_dlp/downloader/fragment.py
+2
-3
yt_dlp/extractor/adn.py
yt_dlp/extractor/adn.py
+6
-10
yt_dlp/extractor/drtv.py
yt_dlp/extractor/drtv.py
+6
-10
yt_dlp/extractor/newstube.py
yt_dlp/extractor/newstube.py
+3
-7
yt_dlp/extractor/rtl2.py
yt_dlp/extractor/rtl2.py
+4
-12
yt_dlp/extractor/shemaroome.py
yt_dlp/extractor/shemaroome.py
+2
-4
未找到文件。
yt_dlp/aes.py
浏览文件 @
1d3586d0
...
...
@@ -2,8 +2,15 @@
from
math
import
ceil
from
.compat
import
compat_b64decode
,
compat_pycrypto_AES
from
.utils
import
bytes_to_intlist
,
intlist_to_bytes
from
.compat
import
(
compat_b64decode
,
compat_ord
,
compat_pycrypto_AES
,
)
from
.utils
import
(
bytes_to_intlist
,
intlist_to_bytes
,
)
if
compat_pycrypto_AES
:
...
...
@@ -25,6 +32,10 @@ def aes_gcm_decrypt_and_verify_bytes(data, key, tag, nonce):
return
intlist_to_bytes
(
aes_gcm_decrypt_and_verify
(
*
map
(
bytes_to_intlist
,
(
data
,
key
,
tag
,
nonce
))))
def
unpad_pkcs7
(
data
):
return
data
[:
-
compat_ord
(
data
[
-
1
])]
BLOCK_SIZE_BYTES
=
16
...
...
@@ -506,5 +517,6 @@ def ghash(subkey, data):
'aes_encrypt'
,
'aes_gcm_decrypt_and_verify'
,
'aes_gcm_decrypt_and_verify_bytes'
,
'key_expansion'
'key_expansion'
,
'unpad_pkcs7'
,
]
yt_dlp/cookies.py
浏览文件 @
1d3586d0
...
...
@@ -11,7 +11,11 @@
from
enum
import
Enum
,
auto
from
hashlib
import
pbkdf2_hmac
from
.aes
import
aes_cbc_decrypt_bytes
,
aes_gcm_decrypt_and_verify_bytes
from
.aes
import
(
aes_cbc_decrypt_bytes
,
aes_gcm_decrypt_and_verify_bytes
,
unpad_pkcs7
,
)
from
.compat
import
(
compat_b64decode
,
compat_cookiejar_Cookie
,
...
...
@@ -846,10 +850,9 @@ def pbkdf2_sha1(password, salt, iterations, key_length):
def
_decrypt_aes_cbc
(
ciphertext
,
key
,
logger
,
initialization_vector
=
b
' '
*
16
):
plaintext
=
aes_cbc_decrypt_bytes
(
ciphertext
,
key
,
initialization_vector
)
padding_length
=
plaintext
[
-
1
]
plaintext
=
unpad_pkcs7
(
aes_cbc_decrypt_bytes
(
ciphertext
,
key
,
initialization_vector
))
try
:
return
plaintext
[:
-
padding_length
]
.
decode
(
'utf-8'
)
return
plaintext
.
decode
(
'utf-8'
)
except
UnicodeDecodeError
:
logger
.
warning
(
'failed to decrypt cookie (AES-CBC) because UTF-8 decoding failed. Possibly the key is wrong?'
,
only_once
=
True
)
return
None
...
...
yt_dlp/downloader/fragment.py
浏览文件 @
1d3586d0
...
...
@@ -14,7 +14,7 @@
from
.common
import
FileDownloader
from
.http
import
HttpFD
from
..aes
import
aes_cbc_decrypt_bytes
from
..aes
import
aes_cbc_decrypt_bytes
,
unpad_pkcs7
from
..compat
import
(
compat_os_name
,
compat_urllib_error
,
...
...
@@ -366,8 +366,7 @@ def decrypt_fragment(fragment, frag_content):
# not what it decrypts to.
if
self
.
params
.
get
(
'test'
,
False
):
return
frag_content
decrypted_data
=
aes_cbc_decrypt_bytes
(
frag_content
,
decrypt_info
[
'KEY'
],
iv
)
return
decrypted_data
[:
-
decrypted_data
[
-
1
]]
return
unpad_pkcs7
(
aes_cbc_decrypt_bytes
(
frag_content
,
decrypt_info
[
'KEY'
],
iv
))
return
decrypt_fragment
...
...
yt_dlp/extractor/adn.py
浏览文件 @
1d3586d0
...
...
@@ -8,11 +8,10 @@
import
random
from
.common
import
InfoExtractor
from
..aes
import
aes_cbc_decrypt
from
..aes
import
aes_cbc_decrypt
_bytes
,
unpad_pkcs7
from
..compat
import
(
compat_HTTPError
,
compat_b64decode
,
compat_ord
,
)
from
..utils
import
(
ass_subtitles_timecode
,
...
...
@@ -84,14 +83,11 @@ def _get_subtitles(self, sub_url, video_id):
return
None
# http://animedigitalnetwork.fr/components/com_vodvideo/videojs/adn-vjs.min.js
dec_subtitles
=
intlist_to_bytes
(
aes_cbc_decrypt
(
bytes_to_intlist
(
compat_b64decode
(
enc_subtitles
[
24
:])),
bytes_to_intlist
(
binascii
.
unhexlify
(
self
.
_K
+
'ab9f52f5baae7c72'
)),
bytes_to_intlist
(
compat_b64decode
(
enc_subtitles
[:
24
]))
))
subtitles_json
=
self
.
_parse_json
(
dec_subtitles
[:
-
compat_ord
(
dec_subtitles
[
-
1
])].
decode
(),
None
,
fatal
=
False
)
dec_subtitles
=
unpad_pkcs7
(
aes_cbc_decrypt_bytes
(
compat_b64decode
(
enc_subtitles
[
24
:]),
binascii
.
unhexlify
(
self
.
_K
+
'ab9f52f5baae7c72'
),
compat_b64decode
(
enc_subtitles
[:
24
])))
subtitles_json
=
self
.
_parse_json
(
dec_subtitles
.
decode
(),
None
,
fatal
=
False
)
if
not
subtitles_json
:
return
None
...
...
yt_dlp/extractor/drtv.py
浏览文件 @
1d3586d0
...
...
@@ -7,13 +7,11 @@
from
.common
import
InfoExtractor
from
..aes
import
aes_cbc_decrypt
from
..aes
import
aes_cbc_decrypt
_bytes
,
unpad_pkcs7
from
..compat
import
compat_urllib_parse_unquote
from
..utils
import
(
bytes_to_intlist
,
ExtractorError
,
int_or_none
,
intlist_to_bytes
,
float_or_none
,
mimetype2ext
,
str_or_none
,
...
...
@@ -191,13 +189,11 @@ def hex_to_bytes(hex):
def
decrypt_uri
(
e
):
n
=
int
(
e
[
2
:
10
],
16
)
a
=
e
[
10
+
n
:]
data
=
bytes_to_intlist
(
hex_to_bytes
(
e
[
10
:
10
+
n
]))
key
=
bytes_to_intlist
(
hashlib
.
sha256
(
(
'%s:sRBzYNXBzkKgnjj8pGtkACch'
%
a
).
encode
(
'utf-8'
)).
digest
())
iv
=
bytes_to_intlist
(
hex_to_bytes
(
a
))
decrypted
=
aes_cbc_decrypt
(
data
,
key
,
iv
)
return
intlist_to_bytes
(
decrypted
[:
-
decrypted
[
-
1
]]).
decode
(
'utf-8'
).
split
(
'?'
)[
0
]
data
=
hex_to_bytes
(
e
[
10
:
10
+
n
])
key
=
hashlib
.
sha256
((
'%s:sRBzYNXBzkKgnjj8pGtkACch'
%
a
).
encode
(
'utf-8'
)).
digest
()
iv
=
hex_to_bytes
(
a
)
decrypted
=
unpad_pkcs7
(
aes_cbc_decrypt_bytes
(
data
,
key
,
iv
))
return
decrypted
.
decode
(
'utf-8'
).
split
(
'?'
)[
0
]
for
asset
in
assets
:
kind
=
asset
.
get
(
'Kind'
)
...
...
yt_dlp/extractor/newstube.py
浏览文件 @
1d3586d0
...
...
@@ -5,11 +5,9 @@
import
hashlib
from
.common
import
InfoExtractor
from
..aes
import
aes_cbc_decrypt
from
..aes
import
aes_cbc_decrypt
_bytes
,
unpad_pkcs7
from
..utils
import
(
bytes_to_intlist
,
int_or_none
,
intlist_to_bytes
,
parse_codecs
,
parse_duration
,
)
...
...
@@ -47,10 +45,8 @@ def _real_extract(self, url):
}))
key
=
hashlib
.
pbkdf2_hmac
(
'sha1'
,
video_guid
.
replace
(
'-'
,
''
).
encode
(),
enc_data
[:
16
],
1
)[:
16
]
dec_data
=
aes_cbc_decrypt
(
bytes_to_intlist
(
enc_data
[
32
:]),
bytes_to_intlist
(
key
),
bytes_to_intlist
(
enc_data
[
16
:
32
]))
sources
=
self
.
_parse_json
(
intlist_to_bytes
(
dec_data
[:
-
dec_data
[
-
1
]]),
video_guid
)
dec_data
=
unpad_pkcs7
(
aes_cbc_decrypt_bytes
(
enc_data
[
32
:],
key
,
enc_data
[
16
:
32
]))
sources
=
self
.
_parse_json
(
dec_data
,
video_guid
)
formats
=
[]
for
source
in
sources
:
...
...
yt_dlp/extractor/rtl2.py
浏览文件 @
1d3586d0
...
...
@@ -4,16 +4,13 @@
import
re
from
.common
import
InfoExtractor
from
..aes
import
aes_cbc_decrypt
from
..aes
import
aes_cbc_decrypt
_bytes
,
unpad_pkcs7
from
..compat
import
(
compat_b64decode
,
compat_ord
,
compat_str
,
)
from
..utils
import
(
bytes_to_intlist
,
ExtractorError
,
intlist_to_bytes
,
int_or_none
,
strip_or_none
,
)
...
...
@@ -142,17 +139,12 @@ def _real_extract(self, url):
self
.
_BACKWERK_BASE_URL
+
'stream/video/'
+
video_id
,
video_id
)
data
,
iv
=
compat_b64decode
(
stream_data
[
'streamUrl'
]).
decode
().
split
(
':'
)
stream_url
=
intlist_to_bytes
(
aes_cbc_decrypt
(
bytes_to_intlist
(
compat_b64decode
(
data
)),
bytes_to_intlist
(
self
.
_AES_KEY
),
bytes_to_intlist
(
compat_b64decode
(
iv
))
))
stream_url
=
unpad_pkcs7
(
aes_cbc_decrypt_bytes
(
compat_b64decode
(
data
),
self
.
_AES_KEY
,
compat_b64decode
(
iv
)))
if
b
'rtl2_you_video_not_found'
in
stream_url
:
raise
ExtractorError
(
'video not found'
,
expected
=
True
)
formats
=
self
.
_extract_m3u8_formats
(
stream_url
[:
-
compat_ord
(
stream_url
[
-
1
])].
decode
(),
video_id
,
'mp4'
,
'm3u8_native'
)
formats
=
self
.
_extract_m3u8_formats
(
stream_url
.
decode
(),
video_id
,
'mp4'
,
'm3u8_native'
)
self
.
_sort_formats
(
formats
)
video_data
=
self
.
_download_json
(
...
...
yt_dlp/extractor/shemaroome.py
浏览文件 @
1d3586d0
...
...
@@ -2,10 +2,9 @@
from
__future__
import
unicode_literals
from
.common
import
InfoExtractor
from
..aes
import
aes_cbc_decrypt
from
..aes
import
aes_cbc_decrypt
,
unpad_pkcs7
from
..compat
import
(
compat_b64decode
,
compat_ord
,
)
from
..utils
import
(
bytes_to_intlist
,
...
...
@@ -76,8 +75,7 @@ def _real_extract(self, url):
url_data
=
bytes_to_intlist
(
compat_b64decode
(
data_json
[
'new_play_url'
]))
key
=
bytes_to_intlist
(
compat_b64decode
(
data_json
[
'key'
]))
iv
=
[
0
]
*
16
m3u8_url
=
intlist_to_bytes
(
aes_cbc_decrypt
(
url_data
,
key
,
iv
))
m3u8_url
=
m3u8_url
[:
-
compat_ord
((
m3u8_url
[
-
1
]))].
decode
(
'ascii'
)
m3u8_url
=
unpad_pkcs7
(
intlist_to_bytes
(
aes_cbc_decrypt
(
url_data
,
key
,
iv
))).
decode
(
'ascii'
)
formats
,
m3u8_subs
=
self
.
_extract_m3u8_formats_and_subtitles
(
m3u8_url
,
video_id
,
fatal
=
False
,
headers
=
{
'stream_key'
:
data_json
[
'stream_key'
]})
self
.
_sort_formats
(
formats
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录