Last active
December 3, 2022 20:22
-
-
Save chris124567/02577d7d27281eeaec10661b10929225 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 python3 | |
import os, sys | |
import json | |
from http import client | |
from hashlib import sha256, sha512 | |
from binascii import hexlify | |
from base64 import b64encode | |
from json import loads, dumps | |
email = 'email_here' | |
password = 'password_here' | |
def get_login_passport(): | |
global email, password | |
device_id = hexlify(sha256(bytes(password, 'utf-8')).digest()).decode('utf-8') | |
password_sha512 = hexlify(sha512(bytes(password, 'utf-8')).digest()).decode('utf-8') | |
#Headers were obtained by dumping memory of the nexon launcher process and searching for common http headers | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) NexonLauncher/2.4.0 Chrome/66.0.3359.181 Electron/3.0.4 Safari/537.36', | |
'Accept': 'application/json, text/javascript, */*', | |
'Origin': 'https://www.nexon.com', | |
'Content-Type': 'application/json', | |
'Accept-Encoding': 'gzip, deflate', | |
'Accept-Language': 'en-US' | |
} | |
body = { | |
'id': email, | |
'password': password_sha512, | |
'auto_login': False, | |
'client_id': '7853644408', | |
'scope': 'us.launcher.all', | |
'device_id': device_id | |
} | |
connection = client.HTTPSConnection('www.nexon.com', 443) | |
connection.request('POST', '/account-webapi/login/launcher', body=dumps(body), headers=headers) | |
response = loads(connection.getresponse().read().decode('utf-8')) | |
if not 'access_token' in response: | |
print("Account credentials are invalid. Exiting.") | |
sys.exit() | |
# Don't leave credentials lingering in memory | |
email = None | |
password = None | |
# Second request | |
access_token_b64 = b64encode(bytes(response['access_token'], 'utf-8')).decode('utf-8') | |
headers = { | |
'User-Agent': 'NexonLauncher.nxl-18.13.18-148-195388a-coreapp-2.4.0', | |
'Cookie': 'nxtk=' + response['access_token'] + ';domain=.nexon.net;path=/;', | |
'Authorization': 'bearer ' + access_token_b64, | |
'Content-Type': 'application/json'#, | |
# 'Accept': '' | |
} | |
connection = client.HTTPSConnection('api.nexon.io', 443) | |
connection.request('GET', '/users/me/passport', headers=headers) | |
response = loads(connection.getresponse().read().decode('utf-8')) | |
# Return the login passport. | |
return response['passport'] | |
print(get_login_passport()) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment