6
Once in a while, I take a complete snapshot of my drives with a command like the following.
> for %i in (%drives_hd%) do @dir %i:\/s/a/o>>File_List.txt
This gives detailed information (path, filename, date, and size) for all files on my system and is great for keeping tabs on the files without expending too much space (~50MB for ~500,000 files). The problem is that it does not contain hashes.
Obviously there are file-hashing tools, but they don’t give the other details, and there is no practical way to do the hash(es) separately and combine it/them with the directory listings.
I’m looking for a tool that can create a text file with complete details like with the dir
command, but also include file hashes (at least CRC(32), MD5, and SHA1). It should also be well written though so that it only reads each file once no matter how many hashes you ask it to do (ie., don’t read the whole file once for each hash type).
I’d prefer a CLI program, but a GUI one is okay, so long as it can be run from a script.
I’m even open to (Windows ports of) Linux tools.
I could find nothing with Google (though I am surprised such a useful tool is not more common), and have considered writing such a tool myself, but I’m hoping something already exists.
To make clear what I am looking for, see the below sample outputs.
Default dir
output:
Volume in drive C is C-WINDOWSXP
Volume Serial Number is 1234-5678
Directory of C:\
2007.07.05 04:05p <DIR> Documents and Settings
2011.05.04 07:38p <DIR> Program Files
2010.04.02 11:35p <DIR> WINDOWS
2011.10.09 10:45p 454 BOOT.INI
2002.08.28 10:08p 47,580 NTDETECT.COM
2002.08.29 02:05a 233,632 NTLDR
3 File(s) 281,666 bytes
Directory of C:\Documents and Settings
2003.11.12 03:08p <DIR> .
2003.11.12 03:08p <DIR> ..
2007.07.05 10:36p <DIR> Administrator
2007.07.05 04:21p <DIR> All Users
0 File(s) 0 bytes
Directory of C:\Documents and Settings\All Users
2003.11.12 03:08p <DIR> .
2003.11.12 03:08p <DIR> ..
2007.07.05 04:23p <DIR> Application Data
2011.06.23 03:23p <DIR> Documents
2011.01.09 12:56p 262,144 ntuser.dat
1 File(s) 262,144 bytes
...
Desired output:
Volume in drive C is C-WINDOWSXP
Volume Serial Number is 1234-5678
Directory of C:\
2007.07.05 04:05p <DIR> Documents and Settings
2011.05.04 07:38p <DIR> Program Files
2010.04.02 11:35p <DIR> WINDOWS
2011.10.09 10:45p 454 BOOT.INI d1183b26 fad47d7d255e1189dbef3003fba96868 39c9bbe3edad58a5bd091ea1db8f9b6cf03f9566
2002.08.28 10:08p 47,580 NTDETECT.COM a709deed 28a3ac957be5d239a3dd4f3d4cdbf3b8 f5625a158d92478c814df3b33a9ad5fcd5f8a956
2002.08.29 02:05a 233,632 NTLDR 0d7e47bd 9896e483e211b8cd1fa7bb32572f02ec c57426135d0419985681a674149c88e652c8ec63
3 File(s) 281,666 bytes
3 Dir(s)
Directory of C:\Documents and Settings
2003.11.12 03:08p <DIR> .
2003.11.12 03:08p <DIR> ..
2007.07.05 10:36p <DIR> Administrator
2007.07.05 04:21p <DIR> All Users
0 File(s) 0 bytes
2 Dir(s)
Directory of C:\Documents and Settings\All Users
2003.11.12 03:08p <DIR> .
2003.11.12 03:08p <DIR> ..
2007.07.05 04:23p <DIR> Application Data
2011.06.23 03:23p <DIR> Documents
2011.01.09 12:56p 262,144 ntuser.dat fc3d370a b3ea06755f614e2c18fc1de875b60126 8264549330d9dbef494264227be9fadffe653556
1 File(s) 262,144 bytes
2 Dir(s)
Like I said, I already know there are countless hashing tools (I’ve got dozens and even wrote a PHP script years ago). Also like I said, that is not what I am looking for because these programs you linked to do not list every file and directory and all their details like
dir
, nor can their outputs be easily integrated into a directory listing. Also, they do not perform multiple hashes with a single read. (I’d down-vote for not bothering to read the question, but it would only decrease my rep and have zero effect on yours.) – Synetech – 2011-12-26T05:47:38.783I did read your question... Windows does not include any built-in utilities for cryptographic hashes, so in practice, you could expand your script to use a utility like this (unless someone else knows of one that does EXACTLY what you want), and format the output as you'd like. Perhaps consider using Powershell and the System.Security.Cryptography.HashAlgorithm namespace from .Net? – Ƭᴇcʜιᴇ007 – 2011-12-26T16:26:01.463
I know there is no built-in command; that’s why I am asking if anyone knows of a tool. To repeat, yes, I can script something to incorporate the hashes from a separate hashing tool into the
dir
output, but like I said, that is not feasible. It would require significant processing of two or more files (which is a nightmare for 50MB files with 900K lines). Worse, doing it your way would require hashing each file once for each hash type (you hash 500GB of files, three times each!) As for PowerShell, if I were going to go to all that trouble, I would just write my own EXE like I said. – Synetech – 2011-12-27T20:52:45.660Sounds good, just keep in mind that each of the hashes will need to be calculated at some point, regardless if it's a script or an EXE. – Ƭᴇcʜιᴇ007 – 2011-12-28T04:25:28.143
1> keep in mind that each of the hashes will need to be calculated at some point Except that they shouldn’t. A hash takes an input stream and performs calculations on it. A poorly designed program would read the file (or other source), hash it, read the file again, hash it, and so on. A well-written program would read a block of data from the file and run it through each designated hashing function, read another block, hash, and so on until it reaches the end-of-file. – Synetech – 2011-12-29T20:34:24.810