Skip to content

Instantly share code, notes, and snippets.

@Daniel-Worrall
Created June 21, 2020 02:12
Show Gist options
  • Save Daniel-Worrall/6552378391fa9e8046972ee4dc3e80f1 to your computer and use it in GitHub Desktop.
Save Daniel-Worrall/6552378391fa9e8046972ee4dc3e80f1 to your computer and use it in GitHub Desktop.
Unencryption for video links on twist.moe
require "openssl"
data = ""
KEY = "LXgIVP&PorO68Rq7dTx8N^lP!Fa5sGJ^*XK"
cipher = OpenSSL::Cipher.new("aes-256-cbc")
encrypted = Base64.decode_string(data)
salt = encrypted.to_slice[8, 8]
my_data = KEY + String.new(salt)
final_key = key = String.build { |str| str.write(OpenSSL::MD5.hash(my_data).to_slice) }
while final_key.to_slice.size < 48
key = String.build { |str| str.write(OpenSSL::MD5.hash(key + my_data).to_slice) }
final_key += key
end
cipher.key = String.new(final_key.to_slice[0...32])
cipher.iv = String.new(final_key.to_slice[32...48])
cipher.decrypt
final = String.build do |str|
str.write(cipher.update(encrypted.to_slice[16..]))
str.write(cipher.final)
end
p final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment