Created
April 11, 2019 19:13
-
-
Save kyledrake/a8d7a120838cf26cb64a2eaf71f567ec to your computer and use it in GitHub Desktop.
Script for solving question/answer from Myspace circa 2009
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
module Myspace | |
class Token | |
def self.get_for_song(o = {}) | |
return nil unless o[:artist_id] && o[:album_id] && o[:song_id] | |
headers = HttpHeader.random_agent 'http://lads.myspace.com/videos/Main.swf' | |
headers['x-myspace-id'] = "ownerId=#{o[:artist_id]};contentId=#{o[:song_id]},#{o[:album_id]}" | |
headers['x-myspace-type'] = "Music" | |
headers['x-myspace-action'] = "Stream" | |
request = Net::HTTP.new 'musicservices.myspace.com', '80' | |
response = request.post '/Modules/MusicServices/Services/MusicPlayerService.ashx?action=getToken', | |
'service=tokennew', | |
headers | |
xml_data = REXML::Document.new response.body | |
self.decrypt xml_data.elements['token'].text | |
end | |
def self.decrypt(data) | |
encoded_data = Base64.decode64(data) | |
iv = encoded_data[0..32] | |
token = encoded_data[32..encoded_data.length] | |
key = Base64.decode64 "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=" # <- lol | |
aes = OpenSSL::Cipher::Cipher.new 'AES-256-CBC' | |
aes.decrypt | |
aes.key = key | |
aes.iv = iv | |
output = aes.update(encoded_data) + aes.final | |
output[32..output.length] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment