Skip to content

Instantly share code, notes, and snippets.

@ColeMundus
Created February 26, 2017 02:38
Show Gist options
  • Save ColeMundus/ffc55ff1139b52852e8b2c3303c5e37e to your computer and use it in GitHub Desktop.
Save ColeMundus/ffc55ff1139b52852e8b2c3303c5e37e to your computer and use it in GitHub Desktop.
import sys
import requests
import getpass
from lxml import html
while True:
try:
minecraftUsername = input("Please Enter Your Username: ")
except ValueError:
print("Sorry, I didn't understand that")
continue
if len(minecraftUsername) < 3 or len(minecraftUsername) > 16:
print("Invalid Username, Please Enter a Valid Username")
continue
u = requests.get("https://api.mojang.com/users/profiles/minecraft/" + minecraftUsername)
if u.status_code == 204:
print("Invalid Username, Please Enter a Valid Username")
continue
else:
break
minecraftEmail = input("Please Enter Your Email: ")
minecraftPassword = getpass.getpass("Please Enter Your Password: ")
loginHeaders = {
'Host': 'account.mojang.com',
'Referer': 'https://account.mojang.com/login',
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1',
}
loginData = {
'authenticityToken': '080ba189708ffeb3be34570e38d58a0247be033b',
'username': minecraftEmail,
'password': minecraftPassword,
'remember': 'true'
}
l = requests.post('https://account.mojang.com/login', headers=loginHeaders, data=loginData)
lParse = html.fromstring(l.content)
questionNamespaces={ 'x': 'http://www.w3.org/1999/xhtml', }
question1 = lParse.xpath('id("challengeForm")/fieldset[1]/label/text()', namespaces=questionNamespaces)
question2 = lParse.xpath('id("challengeForm")/fieldset[2]/label/text()', namespaces=questionNamespaces)
question3 = lParse.xpath('id("challengeForm")/fieldset[3]/label/text()', namespaces=questionNamespaces)
id1 = lParse.xpath('id("challengeForm")/input[2]/@value')
id2 = lParse.xpath('id("challengeForm")/input[3]/@value')
id3 = lParse.xpath('id("challengeForm")/input[4]/@value')
print("SECURITY QUESTIONS")
answer1 = input(question1[0].replace('["','').replace('"]','') + ": ")
answer2 = input(question2[0].replace('["','').replace('"]','') + ": ")
answer3 = input(question3[0].replace('["','').replace('"]','') + ": ")
qCookies = {
'_ga': 'GA1.2.1107785894.1487885148',
'_gat': '1',
'__utmt': '1',
'rememberme': '1d16cf46925ddc8183ad3a54b6921cf2e2d3a60f-mundus2018@gmail.com-1490477197518',
'PLAY_SESSION': 'a348a9bb2cf34706af7c1836c1efc95847195e8b-___AT=10ab26e913d91065228ed49aad866c3f3d776aa1&___ID=74eceab9-457e-43b7-b57a-b103fb541137&showInfoBar=false&useremail=mundus2018%40gmail.com&username=mundus2018%40gmail.com',
'__utma': '111701652.1107785894.1487885148.1487885153.1487885153.1',
'__utmb': '111701652.9.9.1487885199857',
'__utmc': '111701652',
'__utmz': '111701652.1487885153.1.1.utmcsr=mojang.com|utmccn=(referral)|utmcmd=referral|utmcct=/',
}
qHeaders = {
'Origin': 'https://account.mojang.com',
'Accept': '*/*',
'Referer': 'https://account.mojang.com/me/challenge',
'X-Requested-With': 'XMLHttpRequest',
'Connection': 'keep-alive',
'DNT': '1',
}
qData = {
'authenticityToken': '10ab26e913d91065228ed49aad866c3f3d776aa1',
'answer0': answer1,
'questionId0': id1[0].replace('["','').replace('"]',''),
'answer1': answer2,
'questionId1': id2[0].replace('["','').replace('"]',''),
'answer2': answer3,
'questionId2': id3[0].replace('["','').replace('"]',''),
}
d = requests.post('https://account.mojang.com/me/completeChallenge', headers=qHeaders, cookies=qCookies, data=qData)
print(d.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment