2017-08-24 3 views
-1

Ich bin auf der Suche nach einem Skript zum Parsen durch eine Textdatei und Erstellen von MD4-Hashes jedes Wortes in der Textdatei. Ich möchte, dass die Ausgabe an eine andere Textdatei gesendet wird. Das ist, was ich habe, so weit:Erstelle Regenbogen-Tabelle aus Wörtern in Textdatei mit Python

import hashlib 
passwd = open(list.txt) 
lines = passwd.readlines() 
passwd.close() 

hash_object = hashlib.md4(passwd.encode() 
print(hash_object.hexdigest()) 
+0

können Sie ein Beispiel für list.txt angeben, wie definieren Sie ein Wort und welche Art von Ausgabe möchten Sie (wie alle Wörter in einer Zeile, jedes Wort in der neuen Zeile)? – ands

Antwort

0

Ich möchte etwas tun:

from Crypto.Hash import MD4 

with open('result.txt', 'w') as result: 
    for word in open('list.txt').read().split(): 
     h = MD4.new() 
     h.update(bytes(word, 'utf-8')) 
     result.write(word + ':' + h.hexdigest() + '\n') 

Ihre "Frage" ist nicht klar, so vermute ich hier ...

Für eine Eingabedatei wie:

password 
sample 
hello 

Die Ausgabedatei (result.txt) wird wie:

password:8a9d093f14f8701df17732b2bb182c74 
sample:acc4d5991ef52ee9ced7ae04a3e79dbb 
hello:866437cb7a794bce2b727acc0362ee27 

Credits

0

Für MD4 Hash benötigen Sie Crypto-Modul @DRPK.

pip install Crypto 

Oder laden Sie es von:

können Sie dieses Paket von pip Befehl wie folgt installieren

https://pypi.python.org/pypi/pycrypto 

Lets für Hauptcode gehen:

from Crypto.Hash import MD4 

your_file_path = "your_target_file" # change this item with your own address ... 
your_result_path = "your_result_file" # change this item with your own address ... 

def md4_of_each_words(your_file_path): 


    md4_hash = MD4.new() 

    with open(your_file_path, "r") as raw_data: 
     read_raw_data = raw_data.read() 

    make_a_list = read_raw_data.split('\n') 

    for lines in make_a_list: 

     if not lines.replace(" ", '').replace("\t", "") == "": 
      words_list = lines.split(' ') 

      for words in words_list: 

       if not words.replace(" ", "").replace("\t", "") == "": 

        # Calculate MD4 Hash For Each Valid Words 
        md4_hash.update(words) 
        last_md4 = md4_hash.hexdigest() + "\n" 

        with open(your_result_path, "a") as md4_list: 
         md4_list.write(words + last_md4) 

       else: 
        pass 
     else: 
      pass 

    return "Completed." 

md4_of_each_words(your_file_path) 

Good Luck

1

Hier Sie Gehen Sie, versuchen Sie das:

# Create NTLM Rainbow Table from word dictionary 
import hashlib,binascii 

with open('NTLM_Rainbow_Table.txt', 'w') as result: #What my output file will be called; in current directory 
    for word in open('dictionary.txt').read().split(): #what my dictionary file is called; in current directory 
     h = hashlib.new('md4', word.encode('utf-16le')).digest() #Before hashing the passwords are stored as UTF_16_LE. 
     result.write(word + ':' + binascii.hexlify(h) + '\n') 

Ich führe gerade Python 2.7.13 in Kali Linux.

Dank an @DRPK. Dein Skript rockt!

Verwandte Themen