Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.92 KB | None | 0 0
  1. import random
  2. import time
  3. import os
  4. import sys
  5.  
  6. # these are all external modules you'll need to download
  7. # note: faker is installed via pip as "fake-factory" at the moment
  8. import requests
  9. from faker import Factory
  10. from tempmail import TempMail
  11. from simplejson import scanner
  12. from bs4 import BeautifulSoup
  13.  
  14. fake = Factory.create('en_GB')
  15. countries = [x.replace('\n', '').split('|') for x in open('./countries.txt').readlines()]
  16.  
  17. if len(sys.argv) > 1:
  18.     times = int(sys.argv[1])
  19. else:
  20.     times = 10
  21. for attempt in range(times):
  22.     # get names, DOB
  23.     fname, lname = fake.first_name(), fake.last_name()
  24.     dob = fake.date_time_between('-40y', '-20y')
  25.     dob = [x.zfill(2) for x in map(str, [dob.year, dob.month, dob.day])]
  26.     rand_country = random.choice(countries)
  27.     ua = fake.user_agent()
  28.  
  29.     # first part of email, also used for username currently
  30.     emailprefix = fname[0].lower() + lname.lower() + str(random.randint(0, 999)).zfill(3)
  31.  
  32.     tm = TempMail(login=emailprefix)
  33.     # full email
  34.     try:
  35.         email = tm.get_email_address()
  36.     except scanner.JSONDecodeError:
  37.         # this generally doesn't fall through unless you try and get the email before
  38.         # the TempMail call finishes...
  39.         time.sleep(0.5)
  40.         email = tm.get_email_address()
  41.  
  42.     password = fname[0].lower() + lname.lower() + str(random.randint(0, 999)).zfill(3)
  43.  
  44.     print "%s : %s - %s %s - %s - %s" % (email, password, fname, lname, '-'.join(dob), rand_country[0])
  45.  
  46.     highload = True
  47.  
  48.     sess = requests.Session()
  49.  
  50.     print 'First request...'
  51.     r = sess.get('https://club.pokemon.com/us/pokemon-trainer-club/sign-up/')
  52.     while highload or 'csrftoken' not in dict(r.cookies):
  53.         if 'try again in an hour' in r.text or 'csrftoken' not in dict(r.cookies):
  54.             print 'High load.'
  55.             time.sleep(2)
  56.             r = sess.get('https://club.pokemon.com/us/pokemon-trainer-club/sign-up/')
  57.         else:
  58.             highload = False
  59.  
  60.     time.sleep(2)
  61.  
  62.     print 'Second request...'
  63.     # second request
  64.     csrf = dict(r.cookies)['csrftoken']
  65.     year = dob[0]
  66.     month = dob[1]
  67.     day = dob[2]
  68.     country = rand_country[1]
  69.     s = sess.post("https://club.pokemon.com/us/pokemon-trainer-club/sign-up/",
  70.         data='csrfmiddlewaretoken={0}&dob={1}-{2}-{3}&undefined={5}&undefined={1}&country={4}&country={4}'.format(csrf, year, month, day, country, str(int(month) - 1)),
  71.         headers={
  72.             "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
  73.             "Accept-Encoding": "gzip, deflate, br",
  74.             "Accept-Language": "en-GB,en-US;q=0.8,en;q=0.6",
  75.             "Cache-Control": "max-age=0",
  76.             "Connection": "keep-alive",
  77.             "Content-Type": "application/x-www-form-urlencoded",
  78.             "Origin": "https://club.pokemon.com",
  79.             "Referer": "https://club.pokemon.com/us/pokemon-trainer-club/sign-up/",
  80.             "Upgrade-Insecure-Requests": "1",
  81.             "User-Agent": "%s" % ua,
  82.         },
  83.     )
  84.  
  85.     if 'I accept the Pokemon.com Terms of Use.' in s.text:
  86.         print 'Second worked!'
  87.     else:
  88.         print 'Second did not work.'
  89.         break
  90.  
  91.     time.sleep(2)
  92.  
  93.     print 'Third request...'
  94.     t = sess.post("https://club.pokemon.com/us/pokemon-trainer-club/parents/sign-up",
  95.         data='csrfmiddlewaretoken={0}&username={1}&password={2}&confirm_password={2}&email={3}&confirm_email={3}&public_profile_opt_in=True&screen_name={1}&terms=on'.format(csrf, emailprefix, password, email),
  96.         headers={
  97.             "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
  98.             "Accept-Encoding": "gzip, deflate, br",
  99.             "Accept-Language": "en-GB,en-US;q=0.8,en;q=0.6",
  100.             "Cache-Control": "max-age=0",
  101.             "Connection": "keep-alive",
  102.             "Content-Type": "application/x-www-form-urlencoded",
  103.             "Origin": "https://club.pokemon.com",
  104.             "Referer": "https://club.pokemon.com/us/pokemon-trainer-club/parents/sign-up",
  105.             "Upgrade-Insecure-Requests": "1",
  106.             "User-Agent": "%s" % ua,
  107.         },
  108.     )
  109.  
  110.     time.sleep(2)
  111.  
  112.     print 'Last request...'
  113.  
  114.     u = sess.get("https://club.pokemon.com/us/pokemon-trainer-club/parents/email",
  115.         headers={
  116.             "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
  117.             "Accept-Encoding": "gzip, deflate, sdch, br",
  118.             "Accept-Language": "en-GB,en-US;q=0.8,en;q=0.6",
  119.             "Cache-Control": "max-age=0",
  120.             "Connection": "keep-alive",
  121.             "Referer": "https://club.pokemon.com/us/pokemon-trainer-club/parents/sign-up",
  122.             "Upgrade-Insecure-Requests": "1",
  123.             "User-Agent": "%s" % ua,
  124.         },
  125.     )
  126.  
  127.     print 'Getting mail...'
  128.  
  129.     time.sleep(1)
  130.     mail = False
  131.     tries = 1
  132.  
  133.     while not mail and tries < 5:
  134.         mail = tm.get_mailbox()
  135.         try:
  136.             print 'Attempt %s.' % tries
  137.             bs = BeautifulSoup(mail[0]['mail_html'])
  138.             mail = True
  139.  
  140.             activation_url = bs.find_all('a')[1]['href']
  141.  
  142.             print 'Activating account...'
  143.  
  144.             r = requests.get(activation_url)
  145.             if 'Thank you for signing up!' in r.text:
  146.                 print "Worked!"
  147.  
  148.                 if os.path.exists("accounts.txt"):
  149.                     f = open('./accounts.txt', 'a+b')
  150.                 else:
  151.                     f = open('./accounts.txt', 'w+b')
  152.  
  153.                 f.write("%s:%s\r\r\n" % (emailprefix,password))
  154.  
  155.                 f.close()
  156.             else:
  157.                 print "It didn't seem to work. If you like, here's the info so you can check yourself.\n%s : %s - %s %s - %s" % (email, password, fname, lname, '-'.join(dob))
  158.  
  159.         except KeyError:
  160.             print 'Attempt %s didn\'t work.' % tries
  161.             mail = False
  162.             tries += 1
  163.             time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement