Advertisement
Guest User

ff

a guest
Jul 18th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. import urllib
  2. from urllib2 import urlopen, Request
  3. from string import join
  4. from random import choice, randrange
  5. from operator import xor
  6. from bs4 import BeautifulSoup
  7.  
  8. class AccountMaker(object):
  9.  
  10. header = {
  11. "User-Agent": "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"
  12. }
  13.  
  14. def __init__(self, username, password, email, color="random", amount=1):
  15. if len(username) > 12:
  16. print ("blah blah")
  17. elif len(username) < 3:
  18. print ("blah blah")
  19. elif amount != 1 and len(username) > 9:
  20. print ("blah blah")
  21. elif xor(type(amount) != int, amount < 1):
  22. print ("blah blah")
  23. else:
  24. self.username = username
  25. self.password = password
  26. self.email = email
  27. self.color = color if color != "random" else randrange(1, 13)
  28. self.amount = amount
  29.  
  30. self.create()
  31.  
  32. def generateRandomString(self, length=8):
  33. return join((choice("qwertyuiopasdfghjklzxcvbnm") for _ in range(length)), "")
  34.  
  35. def retrieveCookies(self):
  36. initialRequest = Request("https://secured.clubpenguin.com/penguin/create", headers=self.header)
  37.  
  38. initialResponse = urlopen(initialRequest)
  39.  
  40. cookie = initialResponse.info().getheader("Set-Cookie")
  41.  
  42. initialMarkup = initialResponse.read()
  43. initialResponse.close()
  44.  
  45. soup = BeautifulSoup(initialMarkup)
  46.  
  47. self.anonToken = soup.find("input", {"name": "anon_token"})["value"]
  48. self.formBuildId = soup.find("input", {"name": "form_build_id"})["value"]
  49.  
  50. randomString = self.generateRandomString()
  51. self.header["Cookie"] = "{0} playspanTRANSID=arthur-{1}; cpBROWSERID=vortexal-{1};".format(cookie, randomString)
  52. self.header["Content-Type"] = "application/x-www-form-urlencoded"
  53. self.header["Origin"] = "https://secured.clubpenguin.com"
  54. self.header["Referer"] = "https://secured.clubpenguin.com/penguin/create"
  55.  
  56. def register(self, username, email):
  57. self.retrieveCookies()
  58.  
  59. if username == "random":
  60. username = self.generateRandomString(randrange(5, 11))
  61.  
  62. if email == "random":
  63. randomLocal = self.generateRandomString()
  64. email = "{0}@gmail.com".format(randomLocal)
  65.  
  66. print ("Registering with {0} and {1}").format(username, email)
  67.  
  68. data = {
  69. "anon_token": self.anonToken,
  70. "color": self.color,
  71. "name": username,
  72. "pass": self.password,
  73. "pass_show": randrange(0, 1),
  74. "email": email,
  75. "email_confirm": email,
  76. "terms": 1,
  77. "op":"Next",
  78. "form_build_id": self.formBuildId,
  79. "form_id": "penguin_create_form"
  80. }
  81.  
  82. finalRequest = Request("https://secured.clubpenguin.com/penguin/create", urllib.urlencode
  83. (data), self.header)
  84. finalResponse = urlopen(finalRequest)
  85.  
  86. setCookieResponse = finalResponse.info().getheader("Set-Cookie")
  87. finalResponse.close()
  88.  
  89. if setCookieResponse != None:
  90. print ("Registration successful")
  91. else:
  92. print ("Registration failed")
  93.  
  94. del self.header["Cookie"], self.header["Content-Type"], \
  95. self.header["Origin"], self.header["Referer"]
  96.  
  97. def create(self):
  98. if self.amount > 1:
  99. for account in range(self.amount):
  100. if self.username == "random":
  101. self.register(self.username, self.email)
  102. else:
  103. self.register(self.username + str(account), self.email)
  104. else:
  105. self.register(self.username, self.email)
  106.  
  107. try:
  108. AccountMaker(username="random", password="ComplexPassword1", email="random", amount=20)
  109. except KeyboardInterrupt:
  110. print ("Stopping..")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement