Advertisement
Guest User

Untitled

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