Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.35 KB | None | 0 0
  1. from string import join
  2. from random import choice, randrange
  3. from urllib import urlencode
  4. from urllib2 import urlopen, Request, HTTPError
  5. from bs4 import BeautifulSoup
  6. from time import sleep
  7. from hashlib import md5
  8.  
  9. import json
  10. import requests
  11.  
  12.  
  13. class AccountGenerator():
  14.     header = {
  15.         "User-Agent": "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"
  16.     }
  17.  
  18.     def __init__(self):
  19.         self.email = "random"
  20.         self.name = "random"
  21.         self.pw = "penguin88"
  22.         self.color = randrange(1, 12)
  23.  
  24.     def run(self):
  25.         self.loadCaptchas()
  26.         self.registerPenguin()
  27.  
  28.     def loadCaptchas(self):
  29.         self.captchas = {}
  30.         self.captchas["watermelon"] = "ARRB8J8KQ9t7AAAAAElFTkSuQmCC"
  31.         self.captchas["balloon"] = "wuWB85cW2c5NQAAAABJRU5ErkJggg=="
  32.         self.captchas["pizza"] = "XMAAAAASUVORK5CYII="
  33.         self.captchas["popcorn"] = "yat7sdCF61QAAAABJRU5ErkJggg=="
  34.         self.captchas["igloo"] = "b+T94dZQb+IAAAAASUVORK5CYII="
  35.         self.captchas["cheese"] = "B0eBprJbn4wXAAAAAElFTkSuQmCC"
  36.  
  37.     def registerPenguin(self):
  38.         self.getRegisterData()
  39.  
  40.         if self.name == "random":
  41.             self.name = self.genRandomString(8)
  42.  
  43.         if self.email == "random":
  44.             self.email = self.genRandomString(8) + "@mailzi.ru"
  45.  
  46.         print "[{0}] Registering... ".format(self.name)
  47.  
  48.         try:
  49.             data = {
  50.                 "anon_token": self.anonToken,
  51.                 "color": str(self.color),
  52.                 "name": self.name,
  53.                 "pass": self.pw,
  54.                 "pass_show": "1",
  55.                 "email": self.email,
  56.                 "terms": "1",
  57.                 "captcha": str(self.captchaN),
  58.                 "op":"Create Your Penguin",
  59.                 "form_build_id": self.formBuildId,
  60.                 "form_id": "penguin_create_form"
  61.             }
  62.  
  63.             request = Request("https://secured.clubpenguin.com/penguin/create", urlencode(data), self.header)
  64.             response = urlopen(request)
  65.  
  66.             htmlData = response.read()
  67.             soup = BeautifulSoup(htmlData, "html.parser")
  68.            
  69.             setCookieResponse = response.info().getheader("Set-Cookie")
  70.             response.close()
  71.  
  72.             if setCookieResponse != None:
  73.                 print "[{0}] Registration successful".format(self.name)
  74.  
  75.         except HTTPError, err:
  76.             if err.code == 403:
  77.                 print "[{0}] Registration successful".format(self.name)
  78.             else:
  79.                 raise
  80.         finally:
  81.             self.activatePenguin()
  82.            
  83.     def activatePenguin(self):
  84.         print "[{0}] Activating...".format(self.name)
  85.         htmlData = requests.get("http://api.temp-mail.ru/request/mail/id/" + md5(self.email).hexdigest() + "/format/html").text
  86.         while "error" in htmlData or "502 Bad Gateway" in htmlData:
  87.             sleep(1)
  88.             htmlData = requests.get("http://api.temp-mail.ru/request/mail/id/" + md5(self.email).hexdigest() + "/format/html").text
  89.         soup = BeautifulSoup(htmlData, "html.parser")
  90.         for link in soup.find_all('a'):
  91.             if link.text == "Activate Penguin*":
  92.                 activationLink = link['href']
  93.                 break
  94.         htmlData = urlopen(Request(activationLink, headers=self.header)).read()
  95.         soup = BeautifulSoup(htmlData, "html.parser")
  96.         formBuildId = soup.find("input", {"name": "form_build_id"})["value"]
  97.         activateData = {
  98.             "chat_mode" : "standard",
  99.             "opt_in_cp" : "0",
  100.             "opt_in_disney" : "0",
  101.             "terms" : "1",
  102.             "privacy" : "1",
  103.             "op" : "Activate!",
  104.             "form_build_id" : formBuildId,
  105.             "form_id" : "penguin_activate"
  106.  
  107.         }
  108.         response = urlopen(Request(activationLink, urlencode(activateData), self.header))
  109.         if str(response.geturl()) != activationLink:
  110.             print "[{0}] Activation successful".format(self.name)
  111.             file = open("accounts.txt", "a")
  112.             file.write("{0}:{1}".format(self.name, self.pw))
  113.         else:
  114.             print "[{0}] Activation failed".format(self.name)
  115.         del self.header['Cookie']
  116.      
  117.     def getRegisterData(self):
  118.         request = Request("https://secured.clubpenguin.com/penguin/create", headers=self.header)
  119.         response = urlopen(request)
  120.  
  121.         cookie = response.info().getheader("Set-Cookie")
  122.         htmlData = response.read()
  123.  
  124.         response.close()
  125.  
  126.         soup = BeautifulSoup(htmlData, "html.parser")
  127.  
  128.         itemName = self.findBetween(htmlData, "item_name\":\"", "\",");
  129.         image1 = self.findBetween(htmlData, "\"images\":{\"1\":\"", "\",");
  130.         image1 = image1.rsplit('/',1)[-1]
  131.  
  132.         image2 = self.findBetween(htmlData, image1 + "\",\"2\":\"", "\",");
  133.         image2 = image2.rsplit('/',1)[-1]
  134.  
  135.         image3 = self.findBetween(htmlData, image2 + "\",\"3\":\"", "\"");
  136.         image3 = image3.rsplit('/',1)[-1]
  137.  
  138.         itemImage = self.captchas[itemName]
  139.         if(image1 == itemImage):
  140.             self.captchaN = 0
  141.         elif(image2 == itemImage):
  142.             self.captchaN = 1
  143.         elif(image3 == itemImage):
  144.             self.captchaN = 2
  145.  
  146.         self.anonToken = soup.find("input", {"name": "anon_token"})["value"]
  147.         self.formBuildId = soup.find("input", {"name": "form_build_id"})["value"]
  148.  
  149.         randomString = self.genRandomString()
  150.         self.header["Cookie"] = "{0} playspanTRANSID=arthur-{1}; cpBROWSERID=vortexal-{1};".format(cookie, randomString)
  151.         self.header["Origin"] = "https://secured.clubpenguin.com"
  152.         self.header["Referer"] = "https://secured.clubpenguin.com/penguin/create"
  153.  
  154.  
  155.  
  156.     def findBetween(self, s, first, last):
  157.         try:
  158.             start = s.index(first) + len(first)
  159.             end = s.index(last, start)
  160.             return s[start:end]
  161.         except ValueError:
  162.             return ""
  163.  
  164.     def safeFind(self, str, value):
  165.         try:
  166.             jsonObj = json.loads(str)
  167.             return jsonObj[value]
  168.         except ValueError, e:
  169.             return False
  170.         return False
  171.  
  172.     def genRandomString(self, length=8):
  173.         return join((choice("qwertyuiopasdfghjklzxcvbnm") for _ in range(length)), "")
  174.  
  175.  
  176.  
  177. while True:
  178.     a = AccountGenerator()
  179.     a.run()
  180.     print"\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement