Created
March 18, 2014 00:32
-
-
Save adamldoyle/9611324 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
import base64 | |
import binascii | |
import hashlib | |
import hmac | |
import requests | |
import scrypt | |
def hex2bin(hex): | |
return bin(int(hex, 16))[2:] | |
logN = 15 | |
r = 8 | |
p = 1 | |
name = 'name' | |
password = 'password' | |
salt_response = requests.get('https://keybase.io/_/api/1.0/getsalt.json', params={'email_or_username': name}).json() | |
salt = salt_response['salt'] | |
csrf_token = salt_response['csrf_token'] | |
login_session = salt_response['login_session'] | |
pwh = scrypt.hash(password, hex2bin(salt), 1 << logN, r, p, 128)[96:128] | |
hmac_pwh = hmac.new(pwh, base64.b64decode(login_session), hashlib.sha512).hexdigest() | |
login_response = requests.post('https://keybase.io/_/api/1.0/login.json', params={'email_or_username': name, 'csrf_token': csrf_token, 'hmac_pwh': hmac_pwh, 'login_session': login_session}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment