예제 #1
0
파일: console.py 프로젝트: llpj/Pikaptcha
def entry():
    """Main entry point for the package console commands"""
    args = parse_arguments(sys.argv[1:])
    if args.recaptcha != None:
        captchabal = "Failed"
        while (captchabal == "Failed"):
            captchabal = openurl("http://2captcha.com/res.php?key=" +
                                 args.recaptcha + "&action=getbalance")
        print("Your 2captcha balance is: " + captchabal)
        print("This run will cost you approximately: " +
              str(float(args.count) * 0.003))

    username = args.username

    if args.inputtext != None:
        print("Reading accounts from: " + args.inputtext)
        lines = [line.rstrip('\n') for line in open(args.inputtext, "r")]
        args.count = len(lines)

    if (args.recaptcha != None
            and float(captchabal) < float(args.count) * 0.003):
        print(
            "It does not seem like you have enough balance for this run. Lower the count or increase your balance."
        )
        sys.exit()
    else:
        if (args.autoverify == True):
            with open(args.textfile, "a") as ulist:
                ulist.write("The following accounts use the email address: " +
                            args.plusmail + "\n")
                ulist.close()
        for x in range(0, args.count):
            print("Making account #" + str(x + 1))
            if ((args.username != None) and (args.count != 1)
                    and (args.inputtext == None)):
                if (args.startnum == None):
                    username = args.username + str(x + 1)
                else:
                    username = args.username + str(args.startnum + x)
            if (args.inputtext != None):
                username = ((lines[x]).split(":"))[0]
                args.password = ((lines[x]).split(":"))[1]
            try:
                try:
                    account_info = pikaptcha.random_account(
                        username, args.password, args.email, args.birthday,
                        args.plusmail, args.recaptcha, args.captchatimeout)

                    print('  Username:  {}'.format(account_info["username"]))
                    print('  Password:  {}'.format(account_info["password"]))
                    print('  Email   :  {}'.format(account_info["email"]))

                    # Accept Terms Service
                    accept_tos(account_info["username"],
                               account_info["password"], args.location)

                    # Verify email
                    if (args.autoverify == True):
                        email_verify(args.plusmail, args.googlepass)

                    # Append usernames
                    with open(args.textfile, "a") as ulist:
                        if args.outputformat == "pkgo":
                            ulist.write(" -u " + account_info["username"] +
                                        " -p " + account_info["password"] + "")
                        else:
                            ulist.write(account_info["username"] + ":" +
                                        account_info["password"] + "\n")

                        ulist.close()
                # Handle account creation failure exceptions
                except PTCInvalidPasswordException as err:
                    print('Invalid password: {}'.format(err))
                except (PTCInvalidEmailException,
                        PTCInvalidNameException) as err:
                    print('Failed to create account! {}'.format(err))
                except PTCException as err:
                    print(
                        'Failed to create account! General error:  {}'.format(
                            err))
            except Exception:
                import traceback
                print("Generic Exception: " + traceback.format_exc())
        with open(args.textfile, "a") as ulist:
            ulist.write("\n")
            ulist.close()
예제 #2
0
def entry():
    """Main entry point for the package console commands"""
    args = parse_arguments(sys.argv[1:])
    captchabal = None
    if args.recaptcha != None:
        captchabal = "Failed"
        while (captchabal == "Failed"):
            # captcha_id = s.post("http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(args.captcha_key, args.captcha_dsk, url)).text.split('|')[1]
            # captcha_id = str(captcha_id)
            captchabal = openurl("http://2captcha.com/res.php?key=" +
                                 args.recaptcha + "&action=getbalance")
        print("Your 2captcha balance is: " + captchabal)
        print("This run will cost you approximately: " +
              str(float(args.count) * 0.003))

    username = args.username
    currentPosition = args.dotmailPosition
    if args.inputtext != None:
        print("Reading accounts from: " + args.inputtext)
        lines = [line.rstrip('\n') for line in open(args.inputtext, "r")]
        args.count = len(lines)

    if _verify_settings({'args': args, 'balance': captchabal}):
        if (args.autoverify == True):
            with open(args.textfile, "a") as ulist:
                ulist.write(
                    "\nThe following accounts use the email address: " +
                    args.plusmail + "\n")
                ulist.close()
        numPasses = 0
        for x in range(0, args.count):
            print("Making account #" + str(x + 1))
            if ((args.username != None) and (args.count != 1)
                    and (args.inputtext == None)):
                if (args.startnum == None):
                    username = args.username + str(x + 1)
                else:
                    username = args.username + str(args.startnum + x)
            if (args.inputtext != None):
                username = ((lines[x]).split(":"))[0]
                args.password = ((lines[x]).split(":"))[1]
            try:
                try:
                    # todo:  Add in a check that verifies there is an @ sign
                    numChars = args.plusmail.find('@')
                    account_info = pikaptcha.random_account(
                        username, args.password, args.email, args.birthday,
                        args.plusmail, args.recaptcha, args.captchatimeout,
                        args.dotmail, numPasses, x, currentPosition)
                    if numPasses % 3 == 0:
                        if currentPosition + 1 == numChars:
                            currentPosition = 2
                            numPasses += 1
                        else:
                            currentPosition += 1
                    elif numPasses % 3 == 1:
                        if currentPosition + 1 == numChars:
                            currentPosition = 3
                            numPasses += 1
                        else:
                            currentPosition += 1
                    elif numPasses % 3 == 2:
                        if currentPosition + 1 == numChars:
                            currentPosition = 1
                            numPasses += 1
                        else:
                            currentPosition += 1

                    if account_info["username"] is not None:
                        print('  Username:  {}'.format(
                            account_info["username"]))
                        print('  Password:  {}'.format(
                            account_info["password"]))
                        print('  Email   :  {}'.format(account_info["email"]))
                        # Accept Terms Service
                        accept_tos(account_info["username"],
                                   account_info["password"], args.location,
                                   args.proxy)  # Verify email
                        if (args.autoverify == True):
                            email_verify(args.plusmail, args.googlepass)

                        # Append usernames
                        with open(args.textfile, "a") as ulist:
                            if args.outputformat == "pkgo":
                                ulist.write(" -u " + account_info["username"] +
                                            " -p " + account_info["password"] +
                                            "")
                            elif args.outputformat == "pkgocsv":
                                ulist.write("ptc," + account_info["username"] +
                                            "," + account_info["password"] +
                                            "\n")
                            else:
                                ulist.write(account_info["username"] + ":" +
                                            account_info["password"] + "\n")
                            ulist.close()
                            # Handle account creation failure exceptions
                except PTCInvalidPasswordException as err:
                    print('Invalid password: {}'.format(err))
                except (PTCInvalidEmailException,
                        PTCInvalidNameException) as err:
                    print('Failed to create account! {}'.format(err))
                except PTCException as err:
                    print('Failed to create account! General error:  {}'.
                          format(err))
            except Exception:
                import traceback
                print("Generic Exception: " + traceback.format_exc())

        with open(args.textfile, "a") as ulist:
            ulist.write("\n")
            ulist.close()