Python Forum
Speeding up Brute force password guesser
Thread Rating:
  • 3 Vote(s) - 3.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Speeding up Brute force password guesser
#1
Hi, I'm new to python and was wondering how I could speed up my brute force password guesser. I just started python this summer so sorry if it isn't very python-ish

Here's my code:

#imports (im not insulting your inteligence, im just new. :) )

import string, time

#sets printables

var = 3
if var == 1:
   printable = list(string.printable)
   for i in range(5):
       del printable[-1]
elif var == 2:
   printable = list(str(string.ascii_uppercase + string.ascii_lowercase))
elif var == 3:
   printable = list(string.ascii_lowercase)

#variable assignment

password = raw_input("What is the password? -> ")
guess = [printable[0]]
place = 0
limit = 8
correct = False

#sees if the current guess is correct, returns true if so

def ispass():
   if "".join(guess) == password:
       return True
   else:
       return False

#reverts all elements of guess list to first element of printables

def zitup():
   for i in range(len(guess)):
       guess[i] = printable[0]
   guess.append(printable[0])

#moves inncorrect guess to the next string

def next():
   if guess[place] == printable[-1]:
       guess[place] = printable[0]
   else:
       try:
           guess[place] = printable[printable.index(guess[place])+1]
       except ValueError:
           print(guess, place)
#if ispass() returns false detects if all elements of guess are the last element of printable, if so exicutes zitup(), else sets the next non last element of printables to the next possible element

while len(guess) < limit:
   correct = ispass()
   if correct:
       break
   else:
       place = len(guess)-1
       while guess[place] == printable[-1] and place > -1:
           guess[place] = printable[0]
           place += -1
       if place < 0:
           zitup()
           print("Char added")
       else:
           next()

#prints correct guess, or incorrect if len(guess) exceded limit

print("The password is: " + "".join(guess))
Reply


Messages In This Thread
Speeding up Brute force password guesser - by Gamervote - Jul-19-2017, 10:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need an alternative to brute force optimization loop jmbonni 5 1,288 Dec-07-2023, 12:28 PM
Last Post: RockBlok
  Speeding up code using cache Peter 1 578 Jul-29-2023, 04:52 AM
Last Post: bowlofred
  Solving an equation by brute force within a range alexfrol86 3 2,881 Aug-09-2022, 09:44 AM
Last Post: Gribouillis
  force a program to exit ? Armandito 3 2,612 May-12-2022, 04:03 PM
Last Post: Gribouillis
  How to use scipy.optimization.brute for multivariable function Shiladitya 9 6,384 Oct-28-2020, 10:40 PM
Last Post: scidam
  best way to force an exception Skaperen 2 2,102 Oct-21-2020, 05:59 AM
Last Post: Gribouillis
  I need advise with developing a brute forcing script fatjuicypython 11 5,229 Aug-21-2020, 09:20 PM
Last Post: Marbelous
  Force calculation result as decimal vercetty92 4 2,929 Mar-20-2019, 02:27 PM
Last Post: vercetty92
  Password Brute Force 2skywalkers 9 5,471 Oct-18-2018, 02:35 PM
Last Post: buran
  Brute Force Password Guesser 2skywalkers 1 3,221 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