示例#1
0
文件: captcha.py 项目: eirmag/weboob
    def process(self):
        from aum.browser import AuMBrowser
        browser = AuMBrowser('')
        browser.openurl('/register2.php')
        c = Captcha(browser.openurl('/captcha.php'))

        for tile in c:
            checksum = tile.checksum()

            if checksum in self.hash:
                print 'Skipping %s' % self.hash[checksum]
                continue

            tile.display()
            print 'Checksum: %s' % checksum
            ntry = 2
            while ntry:
                sys.stdout.write('Enter the letter: ')
                l = sys.stdin.readline().strip()

                ntry -= 1
                if len(l) != 1:
                    print 'Error: please enter only one letter'
                elif l in self.hash.itervalues():
                    print 'Warning! This letter has already been catched!'
                else:
                    ntry = 0

            self.hash[checksum] = l
示例#2
0
    def activity_fakes(self):
        try:
            fakes = self.storage.get('priority_connection', 'fakes', default={})
            if len(fakes) == 0:
                return
            while 1:
                name = random.choice(fakes.keys())
                fake = fakes[name]
                try:
                    browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy)
                except (AdopteBanned,BrowserIncorrectPassword), e:
                    self.logger.warning('Fake %s can\'t login: %s' % (name, e))
                    continue

                profiles = browser.search_profiles(country="fr",
                                                   dist='10',
                                                   save=True)

                if not profiles:
                    continue

                id = profiles.pop()
                profile = browser.get_profile(id)
                # bad rate
                for i in xrange(4):
                    browser.rate(profile.get_id(), i, 0.6)
                # deblock
                browser.deblock(profile.get_id())
                return
        except BrowserUnavailable:
            # don't care
            pass
示例#3
0
    def check_godchilds(self):
        with self.browser:
            try:
                my_id = self.browser.get_my_id()
                nb_godchilds = self.browser.nb_godchilds()
            except AdopteWait:
                nb_godchilds = 0
            except BrowserUnavailable:
                # We'll check later
                return

        missing_godchilds = int(self.config['minimal']) - nb_godchilds

        self.logger.info('Missing godchilds: %s' % missing_godchilds)

        if missing_godchilds <= 0:
            return

        for i in xrange(missing_godchilds):
            registered = False
            while not registered:
                name = self.generate_name()
                password = self.generate_password()

                browser = AuMBrowser('%s@%s' % (name, self.config['domain']),
                                     proxy=self.browser.proxy)
                try:
                    browser.register(
                        password=password,
                        sex=1,  # s**t
                        birthday_d=random.randint(1, 28),
                        birthday_m=random.randint(1, 12),
                        birthday_y=random.randint(1975, 1990),
                        zipcode=75001,
                        country='fr',
                        godfather=my_id)
                except AccountRegisterError as e:
                    self.logger.warning('Unable to register account: %s' % e)
                except CaptchaError:
                    self.logger.warning('Unable to solve captcha... Retrying')
                else:
                    registered = True

                    # set nickname
                    browser.set_nickname(name.strip('_').capitalize())
                    # rate my own profile with good score
                    for i in xrange(4):
                        browser.rate(my_id, i, 5.0)

                    # save fake in storage
                    fake = {'username': browser.username, 'password': password}
                    self.storage.set('priority_connection', 'fakes', name,
                                     fake)
                    self.storage.save()
                    self.logger.info(
                        'Fake account "%s" created (godfather=%s)' %
                        (name, my_id))
示例#4
0
    def activity_fakes(self):
        try:
            fakes = self.storage.get('priority_connection', 'fakes', default={})
            if len(fakes) == 0:
                return
            while True:
                name = random.choice(fakes.keys())
                fake = fakes[name]
                try:
                    browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy)
                except (AdopteBanned,BrowserIncorrectPassword) as e:
                    self.logger.warning('Fake %s can\'t login: %s' % (name, e))
                    continue

                profiles = browser.search_profiles(country="fr",
                                                   dist='10',
                                                   save=True)

                if not profiles:
                    continue

                id = profiles.pop()
                profile = browser.get_profile(id)
                # bad rate
                for i in xrange(4):
                    browser.rate(profile.get_id(), i, 0.6)
                # deblock
                browser.deblock(profile.get_id())
                return
        except BrowserUnavailable:
            # don't care
            pass
示例#5
0
    def check_godchilds(self):
        with self.browser:
            try:
                my_id = self.browser.get_my_id()
                nb_godchilds = self.browser.nb_godchilds()
            except AdopteWait:
                nb_godchilds = 0
            except BrowserUnavailable:
                # We'll check later
                return

        missing_godchilds = int(self.config['minimal']) - nb_godchilds

        self.logger.info('Missing godchilds: %s' % missing_godchilds)

        if missing_godchilds <= 0:
            return

        for i in xrange(missing_godchilds):
            registered = False
            while not registered:
                name = self.generate_name()
                password = self.generate_password()

                browser = AuMBrowser('%s@%s' % (name, self.config['domain']), proxy=self.browser.proxy)
                try:
                    browser.register(password=   password,
                                     sex=        1,  # s**t
                                     birthday_d= random.randint(1, 28),
                                     birthday_m= random.randint(1, 12),
                                     birthday_y= random.randint(1975, 1990),
                                     zipcode=    75001,
                                     country=    'fr',
                                     godfather=  my_id)
                except AccountRegisterError as e:
                    self.logger.warning('Unable to register account: %s' % e)
                except CaptchaError:
                    self.logger.warning('Unable to solve captcha... Retrying')
                else:
                    registered = True

                    # set nickname
                    browser.set_nickname(name.strip('_').capitalize())
                    # rate my own profile with good score
                    for i in xrange(4):
                        browser.rate(my_id, i, 5.0)

                    # save fake in storage
                    fake = {'username': browser.username,
                            'password': password}
                    self.storage.set('priority_connection', 'fakes', name, fake)
                    self.storage.save()
                    self.logger.info('Fake account "%s" created (godfather=%s)' % (name, my_id))