hashrat(1) | hashing tool supporting several hashes and recursivity | hashrat(1) |
hashrat - hashing tool supporting several hashes and recursivity
hashrat [options] [paths to hash] hashrat -c [options] [input file of hashes]
Hashrat is a hash-generation utility that supports the md5, sha1, sha256, sha512, whirlpool, jh-224, jh256, jh-384 and jh-512 hash functions, and also the HMAC versions of those functions. It can output in traditional format (same as md5sum and shasum and the like) or it's own format.
Hashes can be output in octal, decimal, hexadecimal, uppercase hexadecimal and various types of base32 and base64.
Hashrat also supports directory recursion, hashing entire devices, and generating a hash for an entire directory. It has a CGI mode that can be used as a web-page to lookup hashes.
Hashrat can also detect if it's being run under any of the following names (e.g., via symlinks):
Hashrat can be used to generate strong passwords for websites. So, you don't have to remember the strong password, if it be always regenerate with hashrat. You need to remember a handful of moderately decent passwords, i.e., things that I can't find by grepping in the '10,000 most popular passwords' list[1], and an additional personal pin. Now, you need to combine the website name, one of passwords, and the personal pin, into a string and feed them into hashrat:
$ echo "facebook.com password 1234" | hashrat -sha1 -64Obviously, a good password isn't 'password' and a good pin isn't '1234', but you get the idea. This gives a 28-character string that should take "8.02 trillion centuries" to crack with a "massive cracking array", according to Steve Gibson's Password haystacks utility[2]. This is what I then use as my password. Unfortunately some websites won't take a 28-character password, and for these you can truncate to the appropriate length (using the -n flag), but the results are still stronger than anything you could remember, and nothing needs storing on disk (as with password managers).
There are some dangers to using the 'echo' method shown above if you are on a shared machine, or if someone gets hold of your computer/harddrive. On a shared machine someone could type 'ps ax' to see all commands running, and if they time it right, they might see your command-line with your password in it. Another danger lies in using a shell (like bash) that will record your typed commands so you can recall them later. Bash stores this information on disk in the file .bash_history, so if you use the 'echo' method shown above your password will be saved on disk. To combat this hashrat has line mode:
$ hashrat -sha1 -64 -linesThis reads lines from stdin, so type into hashrat and then press ENTER, and you'll be given the hash of the line you typed. By this method your password is neither visible in 'ps ax', nor is ever stored on disk.
A -lines will produce a different hash to the 'echo' method listed above, because it strips any trailing whitespace off the lines read. If you want strict compatibility with 'echo' (by default echo adds a newline to the end of the text to output) then use rawlines mode:
$ hashrat -sha1 -64 -rawlinesFinally, you can prevent shoulder-surfers seeing you type your password by using the -hide-input or -star-input options to hide what you type.
[1] https://github.com/discourse/discourse/blob/master/lib/common_passwords/10k-common-passwords.txt [2] https://www.grc.com/haystack.htm
Like md5sum/shasum etc, hashrat can be used to detect changes in files that might indicate malicious activity. For instance, in order to get early warning of malware like cryptolocker (that encrypts files on a users disk, or on network shares, and then demands a ransom for file recovery) you can scatter about the disk a number of Canary files that should not change. You need record their hashes and regularly check them. If they change, you will know something is going on.
Hashes generated by hashrat can be output to a file, or stored in extended file attributes, or in a memcached server.
$ hashrat -sha256 -r . > /tmp/files.sha256 $ hashrat -sha256 -r . -xattr $ hashrat -sha256 -r . -memcachedSimilarly these can then be used to check files later:
$ cat /tmp/files.sha256 | hashrat -c -sha256 $ hashrat -C . -sha256 -xattr $ hashrat -C /tmp -sha256 -memcachedNote that -c checks only check the files in the supplied list. The -C flag instead checks all files in a directory (supplied on command line) and expects to find those in the list. This means that -C can find new files that aren't in the list, whereas -c can't.
Using the -m flag hashrat can be told to read a range of hashes from stdin, and then search for files matching those hashes. For Example:
$ cat APT1-AppendixE-MD5s.txt | hashrat -r -m /usrThe last command will search recursively under /usr for files with hashes matching those in APT1-AppendixE-MD5s.txt. The input on stdin must begin with a hash, anything written after the hash will be treated as a comment to be displayed if a file matching the hash is found.
Hashtypes other than md5 can be used thusly:
$ cat sha1-list.lst | hashrat -r -sha1 -m /usrHashes can also be loaded into a memcached server, so that the same file list can be checked on a number of machines, without needing to store the hashlist on those machines. First you need load the hashes:
$ cat APT1-AppendixE-MD5s.txt | hashrat -lm -memcached 192.168.1.5The last line loads the hashes to a memcached server at 192.168.1.5. You can then search against the memcached server by:
$ hashrat -r -m -memcached 192.168.1.5 /usr
Using the -dups flag (usually in combination with the -r recursive flag) hashrat can be set to search for duplicate files and output any found to stdout.
Hashrat outputs a file's name, type, mode, mtime, uid, gid and size, along with a hash. This allows it to be used as a kind of 'ls' by ftp style programs, listing all the details of a file, but with the added feature of a hash.
If run with the '-net' option, hashrat will treat paths starting with 'http://' or 'ssh://' differently, connecting to the target machine and pulling files off it (hashrat assumes there is no hashing program on the remote machine, and that it must therefore download the files to hash them). For ssh paths wildcars are supported:
hashrat -net ssh://username:password@server/usr/bin/*
Hashrat can be used as a TOTP authenticator, and defaults to google-authenticator compatible codes.
hashrat -totp 3EK4LIB2553CUPA7DBXJMMKDCYTEA2IZA
Hookscripts, defined using the -h or -hook command-line options, are scripts that are run for each hashed item. -h and -hook options take an argument that is the path to the script. Hookscripts behave differently in different modes:
If hashrat is run with the -cgi flag, or if it's run with a name of hashrat.cgi (either by renaming the hashrat executable, or via a symbolic link) it will output a webpage that allows users to look up hashes over the web. This allows to look-up your strong passwords even if you don't have access to a local version of hashrat.
CGI Mode can be configured using an options file. The file path is passed in the url, like this:
hashrat.cgi?OptionsFile=/etc/hashrat.options
If an options file is used, then CGI mode uses the options in the file as its defaults. The options file contains the following :
HashType=sha256 Encoding=base64 LineEnding=none OutputLength=12 SegmentLength=4 SegmentChar=+ NoOptions=Y
Hashrat can be used as a TOTP (Time-based One Time Password) authenticator and defaults to google-authenticator compatible codes. The simplest use case is:
hashrat -totp <secret>
It's possible to change the hash, period/lifetime and number of digits in the TOTP code like so:
hashrat -totp 3EK4LIB2553CUPA7DB -sha256 -period 90 -digits 8
Hashes produced in standard-in input mode and TOTP codes can be pushed to the system clipboard using the `-clip` option. This option first tries to find a command that can set the clipboard, searching for one of 'xsel', 'xclip' or 'pbcopy'. If it can't find any of these, it falls back to using xterm's built in clipboard setting method.
Alternatively the `-xsel` option only attempts to use the xterm clipboard setting method.
The default list of clipboard commands can be overridden using the `-clipcmd` option.
Hashes produced in standard-in input mode and TOTP codes can be displayed as qrcodes using the `-qr` or `-qrcode` options. These options require the "qrencode" utility to be installed, and also an image viewer that can be used to display the qrcode image.
By default hashrat searches for the following image viewers:
imlib2_view,fim,feh,display,xv,phototonic,qimageviewer,pix,sxiv,qimgv,qview,nomacs,geeqie,ristretto,mirage,fotowall,links -g
The default list of image viewers can be overridden using the `-viewcmd` option.
Hashrat can use extended filesystem attributes where these are supported. This allows a hash to be stored in the filesystem metadata of the target file. This can then be used for checking hashes, or for caching hashes to produce faster output during hashing runs. There are two types of filesystem attribute, trusted attributes, which can only be set and read by root, and user attributes, which can be set and read by any user that has the appropriate permissions for the file.
Hashes can be stored against files by using the -xattr option to set user attributes:
$ hashrat -sha256 -r . -xattrAnd using the -txattr flag to set trusted attributes (you must be root to set trusted attributes):
# hashrat -sha256 -r . -txattrWhen checking either flag can be used, but hashrat will always use trusted attributes when running as root, if those are available, otherwise it will fall back to user attributes.
$ hashrat -c -sha256 -r . -xattrThe -cache option allows using stored hashes rather than regenerating hashes. It only considers hashes stored in user attributes at current.
$ hashrat -r . -cacheThis makes getting a report of hashes considerably faster, but it runs the risk that the hashes may not be accurate. Hashrat will only output a hash stored in file attributes if the storage time of the hash is younger than the modify time (mtime) of the file, however, this means an attacker could change the modify time of the file to hide changes they've made. Thus this feature should not be used for security checking purposes (but should be safe for uses like finding files that have changed and need to be backed up, for instance).
The hashrat was written by Colum Paget <colums.projects@gmail.com>.
This manual page was written by Joao Eriberto Mota Filho <eriberto@debian.org> for the Debian project (but may be used by others).
Jan 2015 | HASHRAT 1.19 |