Python Forum
brute force password from list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
brute force password from list
#9
my example in the previous post was for wavic.

Here is one for you, where the passwords.txt file is read line by line and once a match is found it returns the number (of attempts)
assumes python3

def guess_password(real):
    WORDLIST = "passwords.txt"
    with open(WORDLIST, 'r') as in_file: # open the file for read
       for attempt, line in enumerate(in_file, start=1): # read file line by line
            if line.strip() == real: # compare line, stripped of the cartridge return, with real
                return attempt # if match is found - return the number of attempts
    return None # no match after the file is exhausted - return None. You can skip this line, but for clarity let explicitly return None.
       
if __name__ == '__main__':
    my_guess = input("Enter password to crack: ") # take user input
    is_found = guess_password(my_guess) # call the function and get the result
    if is_found: # if function returned number, i.e. there is match and that evaluates to True
        print('password is {}. found in {} guesses.'.format(my_guess, is_found))
    else: # function return None (that evaluates to False)
        print('passowrd {} not found in the file.'.format(my_guess))
Reply


Messages In This Thread
brute force password from list - by petru - Apr-03-2017, 01:28 PM
RE: brute force password from list - by buran - Apr-03-2017, 01:34 PM
RE: brute force password from list - by petru - Apr-03-2017, 01:44 PM
RE: brute force password from list - by buran - Apr-03-2017, 02:02 PM
RE: brute force password from list - by wavic - Apr-03-2017, 05:28 PM
RE: brute force password from list - by buran - Apr-03-2017, 07:02 PM
RE: brute force password from list - by petru - Apr-04-2017, 11:30 AM
RE: brute force password from list - by wavic - Apr-03-2017, 09:09 PM
RE: brute force password from list - by buran - Apr-04-2017, 12:12 PM
RE: brute force password from list - by petru - Apr-04-2017, 02:00 PM
RE: brute force password from list - by buran - Apr-04-2017, 02:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need an alternative to brute force optimization loop jmbonni 5 1,326 Dec-07-2023, 12:28 PM
Last Post: RockBlok
  help me to make my password list in python >>> Oktay34riza 0 614 Dec-23-2022, 12:38 PM
Last Post: Oktay34riza
  Solving an equation by brute force within a range alexfrol86 3 2,937 Aug-09-2022, 09:44 AM
Last Post: Gribouillis
  force a program to exit ? Armandito 3 2,672 May-12-2022, 04:03 PM
Last Post: Gribouillis
  How to use scipy.optimization.brute for multivariable function Shiladitya 9 6,453 Oct-28-2020, 10:40 PM
Last Post: scidam
  best way to force an exception Skaperen 2 2,126 Oct-21-2020, 05:59 AM
Last Post: Gribouillis
  I need advise with developing a brute forcing script fatjuicypython 11 5,313 Aug-21-2020, 09:20 PM
Last Post: Marbelous
  Force calculation result as decimal vercetty92 4 2,964 Mar-20-2019, 02:27 PM
Last Post: vercetty92
  Password Brute Force 2skywalkers 9 5,558 Oct-18-2018, 02:35 PM
Last Post: buran
  Brute Force Password Guesser 2skywalkers 1 3,265 Oct-05-2018, 08:04 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020