Currently I’m in the process of simplifying a process for extracting Windows password hashes in security audits. Personally I want to make the process easier to generate a list of recovered users and their passwords when I do an audit. I think it would also be useful for other people who are trying to compare and generate large amounts of data.
So here’s the gist:
When I extract all of the data from the Windows system files, I simplify them down to the format user:hash, where the hash is an NTLM hash such as “a87f3a357d73085c45f9416be5787e86.”
I then will use oclHashcat and attempt to crack the hashes, whether it be dictionary or brute-force, it doesn’t matter. I generate an output of all of the recovered hashes, however Hashcat generates them in the format hash:password.
Now here’s my problem and what I would like some input on – I want to produce the output as user:password given the two input files. Considering that I can have hundreds of hashes yet only a few recovered passwords, there is no use of trying to order the lists.
I am unsure which data structure might benefit me the most. Arrays were too inefficient for large tables. I’ve looked into serialization and I’ve been exploring the use of Hash Maps and Hash Tables. Given the size of the hash, I haven’t had any luck implementing either of these methods, or I’m doing so incorrectly.
Currently I’m running the program like so:
program [user:hash file] [hash:password file] -o [user:password output]
And I’m effectively trying to run the program like so (briefly):
Load Files
// user:hash file
For each line, split by ':' delimiter
before delimiter = table1.user
after delimiter = table1.hash
// hash:password file
For each line, split by ':' delimiter
before delimiter = table2.hash
after delimiter = table2.password
// generate user:password file
Check each entry of table1 vs table2
if table1.hash = table2.hash
table1.user = output.user
table2.password = output.password
print to output "output.user:output.password"
I am only trying to figure out an efficient method for tracing through each line and extracting the necessary data into a data structure that I can easily trace through.
If I need to clarify anything, please let me know. Any help is appreciated!
I decided to go with a shell script, and I used an associated array to match the required data that I needed.
Note: Most of this program deals with the way my hash files are formatted. Look at the comments in the script.