Created
September 1, 2016 13:26
-
-
Save anonymous/f60c50623dbbd2a8fc6cbb665d6e7ab0 to your computer and use it in GitHub Desktop.
This file contains 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/https' | |
require 'json' | |
require 'openssl' | |
=begin | |
UUID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | |
OS = "<OS NAME> <VERSION> - <ARCH>" | |
USERNAME = "YOUR USERNAME" | |
PASSWORD = "YOUR PASSWORD" | |
TARGET_FONT = "jf-jinxuan-Medium" | |
=end | |
resp = Net::HTTP.post_form( | |
URI("http://api.justfont.com/desktop/authdata"), | |
u: USERNAME, | |
p: PASSWORD | |
) | |
resp = JSON.parse(resp.body) | |
@user_id = resp['user_id'] | |
@user_key = resp['user_key'] | |
ts = Time.now.to_i | |
resp = Net::HTTP.post_form( | |
URI("http://api.justfont.com/desktop/tokenget"), | |
user_id: @user_id, | |
auth: OpenSSL::HMAC.hexdigest('sha256', @user_key ,ts.to_s), | |
uuid: 'uuid', | |
os: 'osInfo', | |
timestamp: ts | |
) | |
@token = JSON.parse(resp.body)['token'] | |
resp = Net::HTTP.post_form( | |
URI("http://api.justfont.com/desktop/userdata"), | |
user_id: @user_id, | |
token: @token, | |
uuid: UUID, | |
os: OS | |
) | |
resp = JSON.parse(resp.body) | |
@url = URI(resp['fonts'][TARGET_FONT]['url']) | |
@tmpfile = File.new(TARGET_FONT + ".tmp", "wb") | |
@tmpfile << Net::HTTP.get(@url) | |
@tmpfile.close | |
@tmpfile = File.new(TARGET_FONT + ".tmp", "rb") | |
cipher = OpenSSL::Cipher::AES256.new('CBC') | |
cipher.decrypt | |
@tmpfile.seek(-48,:END) | |
cipher.key = @tmpfile.read(32) | |
cipher.iv = @tmpfile.read(16) | |
@tmpfile.rewind | |
File.open(TARGET_FONT + ".otf", "wb") do |f| | |
f << cipher.update(@tmpfile.read) | |
end | |
@tmpfile.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment