jessek / hashdeep

Other
710 stars 132 forks source link

Windows builds don't work with long paths #395

Open superbonaci opened 4 years ago

superbonaci commented 4 years ago

Example created with Windows Powershell 7 (pwsh.exe). Powershell is able to traverse the directory tree and get the checksum:

PS D:\> Get-Host | Select-Object Version
Version
-------
5.1.18362.752
PS D:\> New-Item -path "D:\+aaaaa\bbbbbbbbbb+bbbbbb\cccc (ccccc ccccc cccc c)\ddd dddd _ddddddddddddd dddddddddd dd ddddd\eeeeeeee eee-eee\8. ffffffff fffffffff ffffff (FFFFFF)\ggggggggg gggg GGGGGGG (GGGGGG)\hhhhhhh hhhh hhhhhhh + hhhhhhhh hhhhhhhhh HHHHHHH\" -type directory
PS D:\> Set-Content "D:\+aaaaa\bbbbbbbbbb+bbbbbb\cccc (ccccc ccccc cccc c)\ddd dddd _ddddddddddddd dddddddddd dd ddddd\eeeeeeee eee-eee\8. ffffffff fffffffff ffffff (FFFFFF)\ggggggggg gggg GGGGGGG (GGGGGG)\hhhhhhh hhhh hhhhhhh + hhhhhhhh hhhhhhhhh HHHHHHH\iiiiiii iiii iiiiii (IIIIII) - IIIIIIIII.txt" "sampletext"
PS D:\> Get-FileHash "D:\+aaaaa\bbbbbbbbbb+bbbbbb\cccc (ccccc ccccc cccc c)\ddd dddd _ddddddddddddd dddddddddd dd ddddd\eeeeeeee eee-eee\8. ffffffff fffffffff ffffff (FFFFFF)\ggggggggg gggg GGGGGGG (GGGGGG)\hhhhhhh hhhh hhhhhhh + hhhhhhhh hhhhhhhhh HHHHHHH\iiiiiii iiii iiiiii (IIIIII) - IIIIIIIII.txt" -Algorithm MD5 | Format-List

Algorithm : MD5
Hash      : 95CDDCB8F0BBB69BF0F66EFF69B2E182
Path      : D:\+aaaaa\bbbbbbbbbb+bbbbbb\cccc (ccccc ccccc cccc c)\ddd dddd _ddddddddddddd dddddddddd dd
            ddddd\eeeeeeee eee-eee\8. ffffffff fffffffff ffffff (FFFFFF)\ggggggggg gggg GGGGGGG (GGGGGG)\hhhhhhh
            hhhh hhhhhhh + hhhhhhhh hhhhhhhhh HHHHHHH\iiiiiii iiii iiiiii (IIIIII) - IIIIIIIII.txt

Now try with hashdeep (windows builds), for some reason the file is located but checksum is not generated:

PS D:\> D:\md5\md5deep-4.4\md5deep64.exe -j 0 -r "D:\+aaaaa\bbbbbbbbbb+bbbbbb\cccc (ccccc ccccc cccc c)\ddd dddd _ddddddddddddd dddddddddd dd ddddd\eeeeeeee eee-eee\8. ffffffff fffffffff ffffff (FFFFFF)\ggggggggg gggg GGGGGGG (GGGGGG)\hhhhhhh hhhh hhhhhhh + hhhhhhhh hhhhhhhhh HHHHHHH\iiiiiii iiii iiiiii (IIIIII) - IIIIIIIII.txt"
: No such file or directory
PS D:\> D:\md5\md5deep-4.4\md5deep64.exe -j 0 -r "D:\+aaaaa\bbbbbbbbbb+bbbbbb\cccc (ccccc ccccc cccc c)\ddd dddd _ddddddddddddd dddddddddd dd ddddd\eeeeeeee eee-eee\8. ffffffff fffffffff ffffff (FFFFFF)\ggggggggg gggg GGGGGGG (GGGGGG)\hhhhhhh hhhh hhhhhhh + hhhhhhhh hhhhhhhhh HHHHHHH\"
D:\+aaaaa\bbbbbbbbbb+bbbbbb\cccc (ccccc ccccc cccc c)\ddd dddd _ddddddddddddd dddddddddd dd ddddd\eeeeeeee eee-eee\8. ffffffff fffffffff ffffff (FFFFFF)\ggggggggg gggg GGGGGGG (GGGGGG)\hhhhhhh hhhh hhhhhhh + hhhhhhhh hhhhhhhhh HHHHHHH\iiiiiii iiii iiiiii (IIIIII) - IIIIIIIII.txt: No such file or directory
superbonaci commented 4 years ago

It happens only using the windows build under Powershell. With Command Prompt (cmd.exe) doesn't work either. If you use Cygwin with its own package works fine (you can call with or without the .exe is the same file):

$ uname -r -o -m
3.1.4(0.340/5/3) x86_64 Cygwin
$ cygcheck.exe -v -l md5deep
Package: md5deep-4.4-1
    /usr/bin/hashdeep.exe
    /usr/bin/md5deep.exe
    /usr/bin/sha1deep.exe
    /usr/bin/sha256deep.exe
    /usr/bin/tigerdeep.exe
    /usr/bin/whirlpooldeep.exe
    /usr/share/doc/md5deep/AUTHORS
    /usr/share/doc/md5deep/ChangeLog
    /usr/share/doc/md5deep/COPYING
    /usr/share/doc/md5deep/NEWS
    /usr/share/doc/md5deep/TODO
    /usr/share/man/man1/hashdeep.1.gz
    /usr/share/man/man1/md5deep.1.gz
    /usr/share/man/man1/sha1deep.1.gz
    /usr/share/man/man1/sha256deep.1.gz
    /usr/share/man/man1/tigerdeep.1.gz
    /usr/share/man/man1/whirlpooldeep.1.gz
$ which md5deep
/usr/bin/md5deep
$ md5deep -hh
md5deep version 4.4 by Jesse Kornblum and Simson Garfinkel.
$ md5deep [OPTION]... [FILES]...
See the man page or README.txt file or use -hh for the full list of options
-p <size> - piecewise mode. Files are broken into blocks for hashing
-r        - recursive mode. All subdirectories are traversed
-e        - show estimated time remaining for each file
-s        - silent mode. Suppress all error messages
-z        - display file size before hash
-m <file> - enables matching mode. See README/man page
-x <file> - enables negative matching mode. See README/man page
-M and -X are the same as -m and -x but also print hashes of each file
-w        - displays which known file generated a match
-n        - displays known hashes that did not match any input files
-a and -A add a single hash to the positive or negative matching set
-b        - prints only the bare name of files; all path information is omitted
-l        - print relative paths for filenames
-t        - print GMT timestamp (ctime)
-i/I <size> - only process files smaller/larger than SIZE
-v        - display version number and exit
-d        - output in DFXML; -u - Escape Unicode; -W FILE - write to FILE.
-j <num>  - use num threads (default 8)
-Z - triage mode;   -h - help;   -hh - full help
-S        - Silent mode, but warn on bad hashes
-0        - use a NUL (\0) for newline.
-k        - print asterisk before filename
-u        - escape Unicode characters in filenames
-B        - verbose mode; repeat for more verbosity
-C        - OS X only --- use Common Crypto hash functions
-Fb       - I/O mode buffered; -Fu unbuffered; -Fm memory-mapped
-f <file> - take list of files to hash from filename
-o[bcpflsde] - expert mode. Only process certain types of files:
               b=block dev; c=character dev; p=named pipe
               f=regular file; l=symlink; s=socket; d=door e=Windows PE
-D <num>  - set debug level to nn
$ md5deep -r /cygdrive/d/+aaaaa/bbbbbbbbbb+bbbbbb/cccc\ \(ccccc\ ccccc\ cccc\ c\)/ddd\ dddd\ _ddddddddddddd\ dddddddddd\ dd\ ddddd/eeeeeeee\ eee-eee/8.\ ffffffff\ fffffffff\ ffffff\ \(FFFFFF\)/ggggggggg\ gggg\ GGGGGGG\ \(GGGGGG\)/hhhhhhh\ hhhh\ hhhhhhh\ +\ hhhhhhhh\ hhhhhhhhh\ HHHHHHH/
95cddcb8f0bbb69bf0f66eff69b2e182  /cygdrive/d/+aaaaa/bbbbbbbbbb+bbbbbb/cccc (ccccc ccccc cccc c)/ddd dddd _ddddddddddddd dddddddddd dd ddddd/eeeeeeee eee-eee/8. ffffffff fffffffff ffffff (FFFFFF)/ggggggggg gggg GGGGGGG (GGGGGG)/hhhhhhh hhhh hhhhhhh + hhhhhhhh hhhhhhhhh HHHHHHH/iiiiiii iiii iiiiii (IIIIII) - IIIIIIIII.txt
$ xxd -p /cygdrive/d/+aaaaa/bbbbbbbbbb+bbbbbb/cccc\ \(ccccc\ ccccc\ cccc\ c\)/ddd\ dddd\ _ddddddddddddd\ dddddddddd\ dd\ ddddd/eeeeeeee\ eee-eee/8.\ ffffffff\ fffffffff\ ffffff\ \(FFFFFF\)/ggggggggg\ gggg\ GGGGGGG\ \(GGGGGG\)/hhhhhhh\ hhhh\ hhhhhhh\ +\ hhhhhhhh\ hhhhhhhhh\ HHHHHHH/iiiiiii\ iiii\ iiiiii\ \(IIIIII\)\ -\ IIIIIIIII.txt
73616d706c65746578740d0a
superbonaci commented 4 years ago

Also needs checking the version for macOS: Install md5deep on Mac OSX