· 10 years ago · Jul 28, 2016, 04:18 PM
1import string
2import random
3import mechanize
4import requests
5import imaplib
6import email
7import re
8import time
9from faker import Factory
10
11NUM_ACCOUNTS = 10
12
13def processMailbox(M):
14 M.select()
15 typ, data = M.search(None, 'UnSeen', 'FROM', 'noreply@pokemon.com')
16 mails = data[0].split()
17 print "There are %i accounts to verify!" % len(mails)
18 for num in mails:
19 typ, data = M.fetch(num, '(RFC822)')
20 msg = email.message_from_string(data[0][1])
21 if msg.is_multipart():
22 for payload in msg.get_payload():
23 manipulatePayload(payload)
24 break
25 else:
26 manipulatePayload(msg)
27
28def manipulatePayload(payload):
29 m=re.search('https://club\.pokemon\.com/us/.*', str(payload.get_payload(None,True)))
30 newURL = m.group(0).rstrip(".")
31 print("Sending confirmation request to " + newURL)
32 tried = 0
33 br = mechanize.Browser()
34 while tried <= 3:
35 try:
36 br.open(newURL)
37 print 'Confirmation Successful!'
38 break
39 except:
40 tried += 1
41
42def generateStr(numChars):
43 return ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(numChars))
44
45def verifyAccounts():
46 M = imaplib.IMAP4_SSL('imap.gmail.com')
47 try:
48 M.login('pokemongomapsteam@gmail.com', "PokemonPassword")
49 except imaplib.IMAP4.error:
50 print("LOGIN FAILED")
51
52 rv, mailboxes = M.list()
53
54 if rv == 'OK' :
55 print("Selecting Mailbox Inbox")
56 processMailbox(M)
57 M.close()
58 M.logout()
59
60
61
62
63def createAccount(fake):
64 myPassword = generateStr(10)
65 myAccount = 'PokeMapper' + generateStr(5)
66
67 print 'Creating Account for ' + myAccount + ' with password ' + myPassword
68 br = mechanize.Browser()
69
70 tried = 0
71 while tried < 5:
72 try:
73 br.open("https://club.pokemon.com/us/pokemon-trainer-club/parents/sign-up")
74 print 'Signup Opened'
75 break
76 except:
77 tried += 1
78
79 form = br.select_form("verify-age")
80
81 # These are the form controls
82 #
83 # csrfmiddlwaretoken -> already set
84 # dob -> 1998-03-12
85 # country -> ['US']
86
87 dob = br.form.find_control("dob")
88 country = br.form.find_control("country")
89
90 dob.value = "1992-03-23"
91
92 tried = 0
93 while tried < 5:
94 try:
95 print 'Attempting to submit DOB'
96 br.submit()
97 print 'DOB submitted'
98 break;
99 except:
100 tried += 1
101
102 form = br.select_form("create-account")
103
104 two_word_name = "false"
105
106 while(two_word_name == "false"):
107 fake_name = fake.name()
108 try:
109 first_name, last_name = fake_name.split()
110 two_word_name = "true"
111 except:
112 two_word_name = "false"
113
114 print first_name, last_name
115 myEmail = "pokemongomapsteam+" + generateStr(5) + "@gmail.com"
116
117 username = br.form.find_control("username")
118 password = br.form.find_control("password")
119 confirm_password = br.form.find_control("confirm_password")
120 email = br.form.find_control("email")
121 confirm_email = br.form.find_control("confirm_email")
122 terms = br.form.find_control("terms")
123
124 username.value = myAccount
125 password.value = myPassword
126 confirm_password.value = myPassword
127 email.value = myEmail
128 confirm_email.value = myEmail
129 terms.items[0].selected = True
130
131 while tried < 5:
132 print 'Attempting to create account with email ' + myEmail
133 try:
134 br.submit()
135 br.close()
136 print 'Successfully created account with email ' + myEmail
137 with open("accounts.csv", "a") as account_file:
138 account_file.write("%s,%s,%s\n" % (myAccount, myPassword, myEmail))
139 break
140 except:
141 tried += 1
142
143
144for i in range(NUM_ACCOUNTS):
145 createAccount(Factory.create())
146
147verifyAccounts()