Sinisterly
Python Brute Forcer - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Python (https://sinister.li/Forum-Python)
+--- Thread: Python Brute Forcer (/Thread-Python-Brute-Forcer)



Python Brute Forcer - DarkKnight - 08-04-2015

This is a Brute Forver i've been working on but still in progress.
Python 2.x

Supported password types
- MD5
- SHA1
- SHA224
- SHA384
- SHA512

Code:
from hashlib import md5,sha1,sha224,sha384,sha512 from sys import exit from optparse import OptionParser from datetime import datetime from random import randint import os.path class B3mB4m(object): def __init__(self, mybrutefile, password, typepassword): self.logo = r"" self.mybrutefile = mybrutefile self.password = password self.startime = datetime.now() self.catch = [] self.mythreads = [] self.type = typepassword self.lastone = "NOTNow" self.passwordexits = "" self.calculator( self.mybrutefile) def calculator(self, getmebaby): with open(getmebaby) as lickme: self.ammo = lickme.readlines() if len(self.ammo) < 1000000: self.lastone = "Now" self.warehouse( self.mybrutefile) else: if 1000000 <= len(self.ammo): if 1000000 < len(self.ammo) < 1000000: math = len(self.ammo) / 2 list1 = self.ammo[0:math] if len(self.ammo) % 2 != 0: padding = len(self.ammo) - math * 2 list2 = self.ammo[math:math*2+padding] else: list2 = self.ammo[math:math*2] self.mythreads = [list1,list2] elif 1000000 < len(self.ammo) < 1000000: math = len(self.ammo) / 4 list1 = self.ammo[0:math] list2 = self.ammo[math:math*2] list3 = self.ammo[math*2:math*3] if len(self.ammo) % 4 != 0: if len(self.ammo) % 4 == 1: list4 = self.ammo[math*3:math*4+3] elif len(self.ammo) % 4 == 2: list4 = self.ammo[math*3:math*4+2] elif len(self.ammo) % 4 == 3: list4 = self.ammo[math*3:math*4+1] else: list4 = self.ammo[math*3:math*4] self.mythreads = [list1,list2,list3,list4] else:#This is too much, my computer can't open it lol. math = len(self.ammo) / 10 list1 = self.ammo[0:math] list2 = self.ammo[math:math*2] list3 = self.ammo[math*2:math*3] list4 = self.ammo[math*3:math*4] list5 = self.ammo[math*4:math*5] list6 = self.ammo[math*5:math*6] list7 = self.ammo[math*6:math*7] list8 = self.ammo[math*7:math*8] list9 = self.ammo[math*8:math*9] if len(self.ammo) - math * 10 != 0: padding = len(self.ammo) - math * 10 list10 = self.ammo[math*9:math*10+padding] else: list10 = self.ammo[math*9:math*10] self.mythreads = [list1,list2,list3,list4,list5,list6,list7,list8,list9,list10] for x in xrange(0, len(self.mythreads)): if self.passwordexits == "True": self.lastone = "Now" elif self.mythreads[len(self.mythreads)-1:len(self.mythreads)][0] == self.mythreads[x]: self.lastone = "Now" self.warehouse( "Default", self.mythreads[x]) def warehouse(self, brutefile, ifsplitTEXT="Cache"): if brutefile != "Default": with open(brutefile, "r") as brute: for i in brute.readlines(): if self.type == "md5": storekey = "%s:%s" % (md5(i.strip()).hexdigest(), i.strip()) elif self.type == "sha1": storekey = "%s:%s" % (sha1(i.strip()).hexdigest(), i.strip()) elif self.type == "sha224": storekey = "%s:%s" % (sha224(i.strip()).hexdigest(), i.strip()) elif self.type == "sha256": storekey = "%s:%s" % (sha256(i.strip()).hexdigest(), i.strip()) elif self.type == "sha384": storekey = "%s:%s" % (sha384(i.strip()).hexdigest(), i.strip()) elif self.type == "sha512": storekey = "%s:%s" % (sha512(i.strip()).hexdigest(), i.strip()) self.catch.append(storekey) self.bruteforce() else: for i in set(ifsplitTEXT): if self.type == "md5": storekey = "%s:%s" % (md5(i.strip()).hexdigest(), i.strip()) elif self.type == "sha1": storekey = "%s:%s" % (sha1(i.strip()).hexdigest(), i.strip()) elif self.type == "sha224": storekey = "%s:%s" % (sha224(i.strip()).hexdigest(), i.strip()) elif self.type == "sha256": storekey = "%s:%s" % (sha256(i.strip()).hexdigest(), i.strip()) elif self.type == "sha384": storekey = "%s:%s" % (sha384(i.strip()).hexdigest(), i.strip()) elif self.type == "sha512": storekey = "%s:%s" % (sha512(i.strip()).hexdigest(), i.strip()) self.catch.append(storekey) self.bruteforce() def bruteforce(self): for i in set(self.catch): if self.passwordexits == "True": break if i.split(":")[0] == self.password: self.passwordexits = "True" self.passinfo = "Password : %s" % i.split(":")[1] self.timeinfo = "Finished %s lines in %s second .." % (str(len(self.ammo)),str((datetime.now() - self.startime))[0:7]) print self.logo print self.passinfo print self.timeinfo break if self.lastone == "Now": self.timeinfo = "Finished %s lines in %s second .." % (str(len(self.ammo)),str((datetime.now() - self.startime))[0:7]) self.logger() def logger(self): if self.passwordexits == "True": name = "%s.txt" % str(randint(0, 999999)) if os.path.isfile(name): name = "%s.txt" % str(randint(0, 999999)) else: name = name logs = open(name, "w") logs.write(self.logo+"\n") logs.write("\n"+self.passinfo) logs.write("\n"+self.timeinfo) logs.close() exit("LogFile : %s saved !" % (name)) else: print self.logo print self.timeinfo exit("Password not found in text !") if __name__ == '__main__': parser = OptionParser() parser.add_option('--file', action="store") parser.add_option('--password', action="store") parser.add_option('--type', action="store") parser.add_option('--passfile', action="store") options, args = parser.parse_args() helpinfo = """ Usage: python crack.py --password [Password] --type [PasswordType] --file [BruteFile] python crack.py --passfile [PasswordList] --type [PasswordType] --file [BruteFile] - [Not working yet] Support password types - MD5 - SHA1 - SHA224 - SHA384 - SHA512 """; if options.passfile: if not options.password or not options.type: print helpinfo exit() else: #Not working yet please just use single crack for a while .. with open(options.passfile, "r") as passlist: for password in passlist.readlines(): B3mB4m( options.file, password.strip(), options.type) else: if not options.password or not options.type or not options.file: print helpinfo exit() else: B3mB4m( options.file, options.password, options.type)

If you find it useful, plus rep me Smile


RE: Python Brute Forcer - Nightlife - 08-16-2015

Would you mind if i edited this abit for my own personal use? i wouldn't take credit of course.


RE: Python Brute Forcer - DarkKnight - 08-16-2015

(08-16-2015, 06:47 PM)Aurora Wrote: Would you mind if i edited this abit for my own personal use? i wouldn't take credit of course.

Sure mate.


RE: Python Brute Forcer - Nightlife - 08-17-2015

(08-16-2015, 07:08 PM)DarkKnight Wrote: Sure mate.

Thanks.


RE: Python Brute Forcer - Eclipse - 08-17-2015

You didn't make that for shit.

https://github.com/b3mb4m/BruteFORCE/blob/master/crack.py


RE: Python Brute Forcer - Nightlife - 08-17-2015

(08-17-2015, 08:01 PM)eclipse Wrote: You didn't make that for shit.

https://github.com/b3mb4m/BruteFORCE/blob/master/crack.py

Wow, i wouldn't of even cared but you could of at least gave credit or put in brackets that you don't deserve credit as it's not yours.. smh


RE: Python Brute Forcer - Inori - 08-19-2015

(08-17-2015, 08:01 PM)eclipse Wrote: You didn't make that for shit.

https://github.com/b3mb4m/BruteFORCE/blob/master/crack.py

I was about to give you some mad props, but ripping other people's code is strictly against the rules. As is asking for rep.