Olá, Estou aprendendo Python, sou bem iniciante e meu objetivo com este script é:
- Pegar o conteudo do arquivo wl.txt, ler linha a linha e usar com o comando crypt.crypt
- Comparar a hash gerada com um salt já definido e comparar esta com uma hash que declarei dentro do arquivo.
- Se o resultado da hash for igual ao hash que eu defini dentro do arquivo, que apareça a mensagem "Senha Encontrada"
Segue meu codigo:
#!/usr/bin/python
import crypt
import sys
# The password is 123456789 and the salt $1$1234$
# Hash $1$1234$iePzeiQ11EHTph.AjL0GM.
hash = r"$1$1234$iePzeiQ11EHTph.AjL0GM."
salt = r"$1$1234$"
with open('wl.txt') as file:
for password in file.readlines():
print ("Trying ...: %s" %(password))
newhash = crypt.crypt(password, salt)
print newhash
if (newhash == hash):
print ("Password found: %s" %(password))
else:
print "Password not found!"
Saida:
┌──(nag㉿kali)-[~]
└─$ python2 hash.py
Trying ...: 123456
$1$1234$8acUSdjZh2kFpS8HkRvvD1
Password not found!
Trying ...: aaa
$1$1234$anGF2igSbkWXaDyzTS3PS.
Password not found!
Trying ...: bbb
$1$1234$PHMaanM3Bt1Xuq8nx0eDu/
Password not found!
Trying ...: ccc
$1$1234$UyV97kO.cYwUbb3aC3x9d.
Password not found!
Trying ...: ddd
$1$1234$Ej0sL587fdyknWC7zJBrG/
Password not found!
Trying ...: eee
$1$1234$7fNlaEimk/x0WCNcHpkIi.
Password not found!
Trying ...: 123456789
$1$1234$MwVqxKiIuhUo7IeS3fMCt0
Password not found!
Obrigado a todos que puderem ajudar.