Skip to content

Instantly share code, notes, and snippets.

@sonya75
Last active August 10, 2017 11:56
Show Gist options
  • Save sonya75/f4d1e4f9c8e1ef1b726e7d2863a02318 to your computer and use it in GitHub Desktop.
Save sonya75/f4d1e4f9c8e1ef1b726e7d2863a02318 to your computer and use it in GitHub Desktop.
ACCOUNTFILENAME="nikeemails.txt"
#Don't change anything below this line
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
import re
def getAppVersion():
global APPVERSION,EXPVERSION
sess=requests.session()
sess.headers.update({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"})
try:
d=sess.get("https://s3.nikecdn.com/unite/scripts/unite.min.js")
APPVERSION=re.search("\"app-version\"\]\|\|\"([0-9]*)\"",d.text).group(1)
EXPVERSION=re.search("\"experience-version\"\]\|\|\"([0-9]*)\"",d.text).group(1)
print "Successfully updated nike app version and experience version"
except:
print "Failed to update app version, using default ones"
APPVERSION="294"
EXPVERSION="255"
def f(email,password):
sess=requests.session()
sess.cookies["CONSUMERCHOICE"]="us/en_us"
sess.cookies["NIKE_COMMERCE_COUNTRY"]="US"
sess.cookies["NIKE_COMMERCE_LANG_LOCALE"]="en_US"
sess.cookies["nike_locale"]="us/en_US"
sess.headers.update({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"})
e=sess.post("https://unite.nike.com/loginWithSetCookie?appVersion={0}&experienceVersion={1}&uxid=com.nike.commerce.nikedotcom.web&locale=en_US&backendEnvironment=identity&browser=Google%20Inc.&os=undefined&mobile=false&native=false".format(APPVERSION,EXPVERSION),json={"username":email,"password":password,"client_id":"HlHa2Cje3ctlaOqnxvgZXNaAs7T9nAuH","ux_id":"com.nike.commerce.nikedotcom.web","grant_type":"password"},verify=False)
e=sess.post("https://secure-store.nike.com/us/services/profileService",data={"action":"getprofile","rt":"JSON"},headers={"X-Requested-With":"XMLHttpRequest"})
e.raise_for_status()
if __name__=="__main__":
getAppVersion()
p=open(ACCOUNTFILENAME,'r').read().split("\n")
for q in p:
q=q.strip()
if q=="":
continue
try:
[email,password]=q.split(":",1)
f(email,password)
print "Successfully fixed {0}".format(email)
except Exception as j:
print j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment