Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created September 1, 2016 13:26
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/f60c50623dbbd2a8fc6cbb665d6e7ab0 to your computer and use it in GitHub Desktop.
Save anonymous/f60c50623dbbd2a8fc6cbb665d6e7ab0 to your computer and use it in GitHub Desktop.
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