Created
July 21, 2014 15:40
-
-
Save r-plus/b232097e41653db0f5ce 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
#!/usr/bin/env python | |
import logging | |
import urllib2 | |
import hmac | |
import hashlib | |
import base64 | |
import time | |
import datetime | |
import sys | |
def CydiaStoreCheck(UDID, package, vendor, secret_key): | |
mode = 'local' | |
unix_time = str(int(time.mktime(datetime.datetime.now().timetuple()))) | |
data = 'api=store-0.9&device=' + UDID + '&mode=' + mode + '&nonce=' + unix_time + '&package=' + package + '×tamp=' + unix_time + '&vendor=' +vendor | |
hmac_data = hmac.new(secret_key, data, hashlib.sha1) | |
signature = base64.encodestring(hmac_data.digest()).strip().rstrip('=').replace('/','_').replace('+', '-') | |
failureCount = 0 | |
while True: | |
try: | |
transactions = urllib2.urlopen('http://cydia.saurik.com/api/check?' + data + '&signature=' + signature) | |
except: | |
failureCount += 1 | |
if failureCount >= 5: | |
logging.warn('failureCount over 5 count.') | |
raise | |
else: | |
break | |
transaction = transactions.readline() | |
res_dict = {} | |
for i in transaction.split('&'): | |
j = [x for x in i.split('=')] | |
res_dict[j[0]] = j[1] | |
return res_dict | |
if __name__ == '__main__': | |
print sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4] | |
print CydiaStoreCheck(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment