Skip to content

Instantly share code, notes, and snippets.

@entchen66
Last active June 13, 2021 19:29
Show Gist options
  • Save entchen66/ca1692797c8d85cc65e71d174f896aa1 to your computer and use it in GitHub Desktop.
Save entchen66/ca1692797c8d85cc65e71d174f896aa1 to your computer and use it in GitHub Desktop.
AFK gift code redemption
import sys
import requests
game = 'afk'
#Hardcode your Username here or use as an inputline.
#user_id = 12345678
user_id = input("Whats your user ID?\n")
auth_code = input("Whats your verification Code?\n")
gift_code = input("Whats the giftcode you want to redeem?\n")
def redeem_gitfcode(user_id, auth_code, gift_code, game):
auth_data, auth_cookie = authentificate(user_id, auth_code, game)
l_p_cdkey_game = auth_cookie.get('l_p_cdkey_game')
l_p_cdkey_game_sig = auth_cookie.get('l_p_cdkey_game.sig')
l_p_cdkey_tk_afk = auth_cookie.get('l_p_cdkey_tk_afk')
l_p_cdkey_tk_afk_sig = auth_cookie.get('l_p_cdkey_tk_afk.sig')
l_p_uid_afk = auth_cookie.get('l_p_uid_afk')
l_p_uid_afk_sig = auth_cookie.get('l_p_uid_afk.sig')
cookie = {
"l_p_cdkey_game": l_p_cdkey_game,
"l_p_cdkey_game.sig": l_p_cdkey_game_sig,
"l_p_cdkey_tk_afk": l_p_cdkey_tk_afk,
"l_p_cdkey_tk_afk.sig": l_p_cdkey_tk_afk_sig,
"l_p_uid_afk": l_p_uid_afk,
"l_p_uid_afk.sig": l_p_uid_afk_sig
}
users_data = fetch_users(user_id, game, cookie)
for i in users_data['data']['users']:
use_giftcode(gift_code, game, i['uid'], cookie)
return 'Finish!'
def authentificate(user_id, auth_code, game):
payload = {
'code': auth_code,
'game': game,
'uid': user_id,
}
url = 'https://cdkey.lilith.com/api/verify-afk-code'
response = requests.post(url, json=payload)
if response.status_code >= 400:
sys.exit('Something went wrong!')
data = response.json()
if data['info'] == 'err_wrong_code':
return sys.exit('Wrong Auth Code!')
return data, response.cookies
def fetch_users(user_id, game, cookie):
payload = {
'game': game,
'uid': user_id,
}
url = 'https://cdkey.lilith.com/api/users'
response = requests.post(url, json=payload, cookies=cookie)
if response.status_code >= 400:
sys.exit('Something went wrong!')
data = response.json()
return data
def use_giftcode(gift_code, game, user_id, cookie):
payload = {
'cdkey': gift_code,
'game': game,
'type': 'cdkey_web',
'uid': int(user_id),
}
url = 'https://cdkey.lilith.com/api/cd-key/consume'
response = requests.post(url, json=payload, cookies=cookie)
if response.status_code >= 400:
sys.exit('Something went wrong!')
data = response.json()
if data['info'] == 'err_cdkey_batch_error':
return print(f'⚠ This code is already used for user ID: {user_id}!')
if data['info'] == 'err_cdkey_record_not_found':
return exit(f'⚠ Code is incorrect!')
if data['info'] == 'err_cdkey_expired':
return exit(f'⚠ Code is expired!')
print(data)
return data
print(redeem_gitfcode(user_id, auth_code, gift_code, game))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment