1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
| import sys
import time
import hashlib
fp = open ("C:\\Users\\damie\\Desktop\\Cours\\Sécurité Systeme et reseaux\\Mot de passe\\shadow.txt","r")
lignes = fp.readlines()
mdptab= []
#Afficher la date et heure
now = time.localtime(time.time())
print ("début de l'opération : " + time.asctime(now))
#Stockage dans le tableau mdptab de tous les mot de passe user trouvés dans le fichier shadow (3mots de passes)
for ligne in lignes:
chaine=ligne.split(":")
if len(chaine[1]) > 20 :
mdptab = mdptab+[chaine[1]]
#Algo force brut
import os
Alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789;@_#"
i = 0
#Mot de passe contenant au minimum 6 à 12 caractères
nbcarac = 5
while nbcarac <= 11 :
nbcarac = nbcarac + 1
print("Nb caractères : " + nbcarac )
if nbcarac == 6 :
for a in range(0,66):
for b in range(0,66):
for c in range(0,66):
for d in range(0,66):
for e in range(0, 66):
for f in range(0, 66):
Brute = Alpha[a] + Alpha[b] + Alpha[c] + Alpha[d] + Alpha[e] + Alpha[f]
hash_object = hashlib.md5(Brute.encode('utf-8')).hexdigest()
mdp = "$1$" + hash_object
print(mdp)
#On compare içi le mot de passe généré puis haché en md5 à ceux stocké dans tableau
for i in range(0, 2):
if mdp == mdptab[i]:
now = time.localtime(time.time())
print("Date de la trouvaille : " + time.asctime(now))
print ("MDP TROUVE : " + "crypté: " + mdp +" non crypté : "+Brute )
if nbcarac == 7:
for a in range(0, 66):
for b in range(0, 66):
for c in range(0, 66):
for d in range(0, 66):
for e in range(0, 66):
for f in range(0, 66):
for g in range(0, 66):
Brute = Alpha[a] + Alpha[b] + Alpha[c] + Alpha[d] + Alpha[e] + Alpha[f] + Alpha[g]
hash_object = hashlib.md5(Brute.encode('utf-8')).hexdigest()
mdp = "$1$" + hash_object
for i in range(0, 2):
if mdp == mdptab[i]:
now = time.localtime(time.time())
print("Date de la trouvaille : " + time.asctime(now))
print("MDP TROUVE : " + "crypté: " + mdp + " non crypté : " + Brute)
if nbcarac == 8:
for a in range(0, 66):
for b in range(0, 66):
for c in range(0, 66):
for d in range(0, 66):
for e in range(0, 66):
for f in range(0, 66):
for g in range(0, 66):
for h in range(0, 66):
Brute = Alpha[a] + Alpha[b] + Alpha[c] + Alpha[d] + Alpha[e] + Alpha[f] + Alpha[g] + Alpha[h]
hash_object = hashlib.md5(Brute.encode('utf-8')).hexdigest()
mdp = "$1$" + hash_object
for i in range(0, 2):
if mdp == mdptab[i]:
now = time.localtime(time.time())
print("Date de la trouvaille : " + time.asctime(now))
print("MDP TROUVE : " + "crypté: " + mdp + " non crypté : " + Brute)
if nbcarac == 9:
for a in range(0, 66):
for b in range(0, 66):
for c in range(0, 66):
for d in range(0, 66):
for e in range(0, 66):
for f in range(0, 66):
for g in range(0, 66):
for h in range(0, 66):
for i in range(0, 66):
Brute = Alpha[a] + Alpha[b] + Alpha[c] + Alpha[d] + Alpha[e] + Alpha[f] + Alpha[g] + Alpha[h] + Alpha[i]
hash_object = hashlib.md5(Brute.encode('utf-8')).hexdigest()
mdp = "$1$" + hash_object
for i in range(0, 2):
if mdp == mdptab[i]:
now = time.localtime(time.time())
print("Date de la trouvaille : " + time.asctime(now))
print("MDP TROUVE : " + "crypté: " + mdp + " non crypté : " + Brute)
if nbcarac == 10:
for a in range(0, 66):
for b in range(0, 66):
for c in range(0, 66):
for d in range(0, 66):
for e in range(0, 66):
for f in range(0, 66):
for g in range(0, 66):
for h in range(0, 66):
for i in range(0, 66):
for j in range(0, 66):
Brute = Alpha[a] + Alpha[b] + Alpha[c] + Alpha[d] + Alpha[e] + Alpha[f] + Alpha[g] + Alpha[h] + Alpha[i]+ Alpha[j]
hash_object = hashlib.md5(Brute.encode('utf-8')).hexdigest()
mdp = "$1$" + hash_object
for i in range(0, 2):
if mdp == mdptab[i]:
now = time.localtime(time.time())
print("Date de la trouvaille : " + time.asctime(now))
print("MDP TROUVE : " + "crypté: " + mdp + " non crypté : " + Brute)
if nbcarac == 11:
for a in range(0, 66):
for b in range(0, 66):
for c in range(0, 66):
for d in range(0, 66):
for e in range(0, 66):
for f in range(0, 66):
for g in range(0, 66):
for h in range(0, 66):
for i in range(0, 66):
for j in range(0, 66):
for k in range(0, 66):
Brute = Alpha[a] + Alpha[b] + Alpha[c] + Alpha[d] + Alpha[e] + Alpha[f] + Alpha[g] + Alpha[h] + Alpha[i] + Alpha[j] +Alpha[k]
hash_object = hashlib.md5(Brute.encode('utf-8')).hexdigest()
mdp = "$1$" + hash_object
for i in range(0, 2):
if mdp == mdptab[i]:
now = time.localtime(time.time())
print("Date de la trouvaille : " + time.asctime(now))
print("MDP TROUVE : " + "crypté: " + mdp + " non crypté : " + Brute)
if nbcarac == 12:
for a in range(0, 66):
for b in range(0, 66):
for c in range(0, 66):
for d in range(0, 66):
for e in range(0, 66):
for f in range(0, 66):
for g in range(0, 66):
for h in range(0, 66):
for i in range(0, 66):
for j in range(0, 66):
for k in range(0, 66):
for l in range(0, 66):
Brute = Alpha[a] + Alpha[b] + Alpha[c] + Alpha[d] + Alpha[e] + Alpha[f] + Alpha[g] + Alpha[h] + Alpha[i] + Alpha[j] + Alpha[k]+ Alpha[l]
hash_object = hashlib.md5(Brute.encode('utf-8')).hexdigest()
mdp = "$1$" + hash_object
for i in range(0, 2):
if mdp == mdptab[i]:
now = time.localtime(time.time())
print("Date de la trouvaille : " + time.asctime(now))
print("MDP TROUVE : " + "crypté: " + mdp + " non crypté : " + Brute) |
Partager