Script para verificar la clave de una DB y verificar si fue crackeada

d
Autor: Desconocido
Descripción: Script en Python para verificar la presencia de la clave en la DB y si fué crackeada.

#! /usr/bin/env python

from hashlib import sha1
import getpass

def get_hash(plaintext, offset=5):
  hashed = sha1(plaintext).hexdigest()
  return '0' * offset + hashed[offset:]

def check_database(database, plaintext):
  uncracked_hash = get_hash(plaintext, 0)
  cracked_hash = get_hash(plaintext)

  database.seek(0);
  line_count = 0

  for line in database:
    line_count += 1
    if uncracked_hash in line:
      print ">Found somethng on line: %d" % line_count
      return ">Warning: Your password hash is in the database but uncracked. :|"
    elif cracked_hash in line:
      print ">Found somethng on line: %d" % line_count
      return ">Warning: Your password hash is in the database and was cracked. :["

  print ">Checked all %d lines" % line_count
  return "All Clear: your password hash isn't in the database! :]"



def main():
  database = open("combo_not.txt")
  while(True):
    password = getpass.getpass("Input a password to check: \n").strip()

    print check_database(database, password) 
    print "\n\n"
    

if __name__ == "__main__":
    main()
Visto en Twitter

0 comentarios: