mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-06-28 01:48:26 +00:00
feat: add support for encrypted query parameters
Related: -6bd0f28d77
-7eae31613e
This commit is contained in:
parent
db53ee21ee
commit
facd01b52e
@ -384,6 +384,29 @@ def parse_link_endpoint(endpoint : JSON::Any, text : String, video_id : String)
|
|||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def decrypt_ecb_without_salt(data, key)
|
||||||
|
cipher = OpenSSL::Cipher.new("aes-128-ecb")
|
||||||
|
cipher.decrypt
|
||||||
|
cipher.key = key
|
||||||
|
cipher.padding = false
|
||||||
|
|
||||||
|
io = IO::Memory.new
|
||||||
|
io.write(cipher.update(data))
|
||||||
|
io.write(cipher.final)
|
||||||
|
io.rewind
|
||||||
|
|
||||||
|
data_ = io.to_s
|
||||||
|
padding = data_[-1].ord
|
||||||
|
|
||||||
|
return data_[0...(data_.bytesize - padding)]
|
||||||
|
end
|
||||||
|
|
||||||
|
def video_playback_decrypt(data)
|
||||||
|
data = Base64.decode(data)
|
||||||
|
decrypted_query = decrypt_ecb_without_salt(data, CONFIG.invidious_companion_key)
|
||||||
|
return decrypted_query
|
||||||
|
end
|
||||||
|
|
||||||
def encrypt_ecb_without_salt(data, key)
|
def encrypt_ecb_without_salt(data, key)
|
||||||
cipher = OpenSSL::Cipher.new("aes-128-ecb")
|
cipher = OpenSSL::Cipher.new("aes-128-ecb")
|
||||||
cipher.encrypt
|
cipher.encrypt
|
||||||
|
@ -3,6 +3,11 @@ module Invidious::Routes::VideoPlayback
|
|||||||
def self.get_video_playback(env)
|
def self.get_video_playback(env)
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
query_params = env.params.query
|
query_params = env.params.query
|
||||||
|
|
||||||
|
if query_params["enc"]? == "yes"
|
||||||
|
query_params = URI::Params.parse(video_playback_decrypt(query_params["data"]))
|
||||||
|
end
|
||||||
|
|
||||||
array = UInt8[0x78, 0]
|
array = UInt8[0x78, 0]
|
||||||
protobuf = Bytes.new(array.size)
|
protobuf = Bytes.new(array.size)
|
||||||
array.each_with_index do |byte, index|
|
array.each_with_index do |byte, index|
|
||||||
|
Loading…
Reference in New Issue
Block a user