Skip to content

Commit 7e8a76c

Browse files
committed
v1.16
1 parent 0b3c057 commit 7e8a76c

File tree

223 files changed

+10058
-5100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+10058
-5100
lines changed

CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
v1.16 (2024-01-14)
2+
* Added base32 hash encoding
3+
* TOTP authentication support
4+
* Clipboard support using xsel, xclip or pbcopy
5+
* QRCode support using qrencode and an image viewer

Makefile

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
21
CC = gcc
32
CFLAGS = -g -O2
4-
LIBS = libUseful-4/libUseful.a
3+
LIBS = -lssl -lcrypto libUseful-5/libUseful.a
54
INSTALL=/bin/install -c
65
prefix=/usr/local
76
bindir=$(prefix)${exec_prefix}/bin
8-
FLAGS=$(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -D_FILE_OFFSET_BITS=64
9-
OBJ=common.o encodings.o command-line-args.o ssh.o http.o fingerprint.o include-exclude.o files.o filesigning.o xattr.o check-hash.o find.o memcached.o frontend.o cgi.o xdialog.o
7+
FLAGS=$(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBSSL=1
8+
OBJ=common.o encodings.o command-line-args.o ssh.o http.o fingerprint.o include-exclude.o files.o filesigning.o xattr.o check-hash.o find.o otp.o memcached.o frontend.o cgi.o xdialog.o output.o
109
EXE=hashrat
1110

1211
all: hashrat
1312

14-
hashrat: $(OBJ) main.c libUseful-4/libUseful.a
13+
hashrat: $(OBJ) main.c libUseful-5/libUseful.a
1514
$(CC) $(FLAGS) -o$(EXE) $(OBJ) main.c $(LIBS)
1615

17-
libUseful-4/libUseful.a:
18-
@cd libUseful-4; $(MAKE)
16+
libUseful-5/libUseful.a:
17+
@cd libUseful-5; $(MAKE)
1918

2019
common.o: common.h common.c
2120
$(CC) $(FLAGS) -c common.c
@@ -50,9 +49,15 @@ ssh.o: ssh.h ssh.c
5049
http.o: http.h http.c
5150
$(CC) $(FLAGS) -c http.c
5251

52+
otp.o: otp.h otp.c
53+
$(CC) $(FLAGS) -c otp.c
54+
5355
frontend.o: frontend.h frontend.c
5456
$(CC) $(FLAGS) -c frontend.c
5557

58+
output.o: output.h output.c
59+
$(CC) $(FLAGS) -c output.c
60+
5661
cgi.o: cgi.h cgi.c
5762
$(CC) $(FLAGS) -c cgi.c
5863

@@ -69,7 +74,7 @@ check: hashrat
6974
@./check.sh
7075

7176
clean:
72-
-rm -f *.o */*.o */*.a */*.so $(EXE)
77+
-rm -f *.o */*.o */*.a */*.so *.orig $(EXE)
7378
-rm -f config.log config.status */config.log */config.status
7479
-rm -fr autom4te.cache */autom4te.cache
7580

Makefile.in

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
21
CC = @CC@
32
CFLAGS = @CFLAGS@
43
LIBS = @LIBS@ @STATIC_LIBS@
54
INSTALL=@INSTALL@
65
prefix=@prefix@
76
bindir=$(prefix)@bindir@
87
FLAGS=$(LDFLAGS) $(CPPFLAGS) $(CFLAGS) @DEFS@
9-
OBJ=common.o encodings.o command-line-args.o ssh.o http.o fingerprint.o include-exclude.o files.o filesigning.o xattr.o check-hash.o find.o memcached.o frontend.o cgi.o xdialog.o
8+
OBJ=common.o encodings.o command-line-args.o ssh.o http.o fingerprint.o include-exclude.o files.o filesigning.o xattr.o check-hash.o find.o otp.o memcached.o frontend.o cgi.o xdialog.o output.o
109
EXE=hashrat
1110

1211
all: hashrat
1312

1413
hashrat: $(OBJ) main.c @STATIC_LIBS@
1514
$(CC) $(FLAGS) -o$(EXE) $(OBJ) main.c $(LIBS)
1615

17-
libUseful-4/libUseful.a:
18-
@cd libUseful-4; $(MAKE)
16+
libUseful-5/libUseful.a:
17+
@cd libUseful-5; $(MAKE)
1918

2019
common.o: common.h common.c
2120
$(CC) $(FLAGS) -c common.c
@@ -50,9 +49,15 @@ ssh.o: ssh.h ssh.c
5049
http.o: http.h http.c
5150
$(CC) $(FLAGS) -c http.c
5251

52+
otp.o: otp.h otp.c
53+
$(CC) $(FLAGS) -c otp.c
54+
5355
frontend.o: frontend.h frontend.c
5456
$(CC) $(FLAGS) -c frontend.c
5557

58+
output.o: output.h output.c
59+
$(CC) $(FLAGS) -c output.c
60+
5661
cgi.o: cgi.h cgi.c
5762
$(CC) $(FLAGS) -c cgi.c
5863

@@ -69,7 +74,7 @@ check: hashrat
6974
@./check.sh
7075

7176
clean:
72-
-rm -f *.o */*.o */*.a */*.so $(EXE)
77+
-rm -f *.o */*.o */*.a */*.so *.orig $(EXE)
7378
-rm -f config.log config.status */config.log */config.status
7479
-rm -fr autom4te.cache */autom4te.cache
7580

README.md

+84-14
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ OPTIONS
5050
-? Print this help
5151
--version Print program version
5252
-version Print program version
53-
-type <type> Use hash algorithmn <type>. Types can be chained together as a comma-seperated list.
5453
-md5 Use md5 hash algorithmn
5554
-sha1 Use sha1 hash algorithmn
5655
-sha256 Use sha256 hash algorithmn
@@ -62,10 +61,19 @@ OPTIONS
6261
-jh384 Use jh-384 hash algorithmn
6362
-jh512 Use jh-512 hash algorithmn
6463
-hmac HMAC using specified hash algorithm
64+
-totp <secret> TOTP code from supplied secret (defaults to google authenticator compatible code).
65+
-totp <url> TOTP code from supplied otpauth url.
66+
-digits <n> Produce TOTP code with <n> digits.
67+
-period <n> Produce TOTP code with period/lifetime of <n> seconds.
6568
-8 Encode with octal instead of hex
6669
-10 Encode with decimal instead of hex
6770
-H Encode with UPPERCASE hexadecimal
6871
-HEX Encode with UPPERCASE hexadecimal
72+
-32 Encode with base32 instead of hex
73+
-base32 Encode with base32 instead of hex
74+
-c32 Encode with Crockford base32 instead of hex
75+
-w32 Encode with word-safe base32 instead of hex
76+
-z32 Encode with zbase32 instead of hex
6977
-64 Encode with base64 instead of hex
7078
-base64 Encode with base64 instead of hex
7179
-i64 Encode with base64 with rearranged characters
@@ -86,52 +94,60 @@ OPTIONS
8694
-hid Show hidden (starting with .) files
8795
-hidden Show hidden (starting with .) files
8896
-f <listfile> Hash files listed in <listfile>
89-
-i <pattern> Only hash items matching <pattern>
90-
-x <pattern> Exclude items matching <pattern>
91-
-X <path> Exclude items listed in file <path>. Items in the file can be wildcards.
92-
-name <patterns> Only hash items matching a comma-seperated list of shell patterns (-name as in the 'find' command)
97+
-i <patterns> Only hash items matching a comma-seperated list of shell patterns
98+
-x <patterns> Exclude items matching a comma-sepearted list of shell patterns
99+
-X <file> Exclude items matching shell patters stored in <file>
100+
-name <patterns> Only hash items matching a comma-seperated list of shell patterns (-name aka 'find')
93101
-mtime <days> Only hash items <days> old. Has the same format as the find command, e.g. -10 is younger than ten days, +10 is older than ten, and 10 is ten days old
94102
-mmin <mins> Only hash items <min> minutes old. Has the same format as the find command, e.g. -10 is younger than ten mins, +10 is older than ten, and 10 is ten mins old
95103
-myear <years> Only hash items <years> old. Has the same format as the find command, e.g. -10 is younger than ten years, +10 is older than ten, and 10 is ten years old
96104
-exec In CHECK or MATCH mode only examine executable files.
97105
-dups Search for duplicate files.
98106
-n <length> Truncate hashes to <length> bytes
99-
-segment <length> Break has up into segments of <length> characters seperated by '-'
107+
-segment <length> Break hash up into segments of <length> chars seperated by '-'
100108
-c CHECK hashes against list from file (or stdin)
101-
-cf CHECK hashes but only show failures
102-
-C CHECK files against list from file (or stdin) can spot new files
103-
-Cf CHECK files but only show failures
109+
-cf CHECK hashes against list but only show failures
110+
-C <dir> Recursively CHECK directory against list of files on stdin
111+
-Cf <dir> Recursively CHECK directory against list but only show failures
104112
-m MATCH files from a list read from stdin.
105113
-lm Read hashes from stdin, upload them to a memcached server (requires the -memcached option).
106114
-memcached <server> Specify memcached server. (Overrides reading list from stdin if used with -m, -c or -cf).
107115
-mcd <server> Specify memcached server. (Overrides reading list from stdin if used with -m, -c or -cf).
108-
-h <script> Script to run when a file fails CHECK mode, or is found in MATCH mode. (see 'Hookscripts' below)
109-
-hook <script> Script to run when a file fails CHECK mode, or is found in MATCH mode. (see 'Hookscripts' below)
116+
-h <script> Script to run when a file fails CHECK mode, or is found in MATCH mode.
117+
-hook <script> Script to run when a file fails CHECK mode, or is found in FIND mode
110118
-color Use ANSI color codes on output when checking hashes.
111119
-strict Strict mode: when checking, check file mtime, owner, group, and inode as well as it's hash
112120
-S Strict mode: when checking, check file mtime, owner, group, and inode as well as it's hash
113121
-d dereference (follow) symlinks
114122
-fs Stay on one file system
123+
-dir DirMode: Read all files in directory and create one hash for them!
115124
-dirmode DirMode: Read all files in directory and create one hash for them!
116125
-devmode DevMode: read from a file EVEN OF IT'S A DEVNODE
117126
-lines Read lines from stdin and hash each line independantly.
118127
-rawlines Read lines from stdin and hash each line independantly, INCLUDING any trailing whitespace. (This is compatible with 'echo text | md5sum')
119128
-rl Read lines from stdin and hash each line independantly, INCLUDING any trailing whitespace. (This is compatible with 'echo text | md5sum')
120129
-cgi Run in HTTP CGI mode
121-
-xdialog Run in 'xdialog' (zenity, yad or qarama) mode.
122-
-dialog-types <types> Specify a list of dialog commands and use the first found on the system. Default is 'yad,zenity,qarma'.
130+
-cgi Run in HTTP CGI mode
131+
-xdialog Run in 'xdialog' (zenity, yad or qarama) mode
132+
-dialog-types <list> Specify a list of dialog commands and use the first found on the system. Default is 'yad,zenity,qarma'
123133
-iprefix <prefix> String to prefix all input before hashing
124134
-oprefix <prefix> Prefix to add to the front of output hashes
125135
-net Treat 'file' arguments as either ssh or http URLs, and pull files over the network and then hash them (Allows hashing of files on remote machines).
126136
URLs are in the format ssh://[username]:[password]@[host]:[port] or http://[username]:[password]@[host]:[port]..
127137
-idfile <path> Path to an ssh private key file to use to authenticate INSTEAD OF A PASSWORD when pulling files via ssh.
128138
-xattr Use eXtended file ATTRibutes. In hash mode, store hashes in the file attributes, in check mode compare against hashes stored in file attributes.
129-
-txattr Use TRUSTED eXtended file ATTRibutes. In hash mode, store hashes in 'trusted' file attributes. 'trusted' attributes can only be read and written by root.
139+
-txattr Use TRUSTED eXtended file ATTRibutes. In hash mode, store hashes in 'trusted' file attributes. 'trusted' attributes can only be read and written by root. Under freebsd this menas SYSTEM attributes.
130140
-attrs comma-separated list of filesystem attribute names to be set to the value of the hash.
131141
-cache Use hashes stored in 'user' xattr if they're younger than the mtime of the file. This speeds up outputting hashes.
132142
-u <types> Update. In checking mode, update hashes for the files as you go. <types> is a comma-separated list of things to update, which can be 'xattr' 'memcached' or a file name. This will update these targets with the hash that was found at the time of checking.
133143
-hide-input When reading data from stdin in linemode, set the terminal to not echo characters, thus hiding typed input.
134144
-star-input When reading data from stdin in linemode replace characters with stars.
145+
-xsel Update X11 clipboard and primary selections to the current hash. This works using Xterm command sequences. The xterm resource 'allowWindowOps' must be set to 'true' for this to work.
146+
-clip Update X11 clipboard to the current hash. This works using the 'xsel', 'xclip' or 'pbcopy' commands, or if none of those are installed falls back to Xterm clipboard as in the '-xsel' option .
147+
-qr Display the current hash as a qrcode. This requires the 'qrencode' command to be installed, and also an image viewer like fim, feh, or imagemagick display to be installed.
148+
-qrcode Display the current hash as a qrcode. This requires the 'qrencode' command to be installed, and also an image viewer like fim, feh, or imagemagick display to be installed.
149+
-clipcmd <cmds> Comma separated list of clipboard-setter commands to use instead of the defaults.
150+
-viewcmd <cmds> Comma separated list of image-viewer commands to use instead of the defaults.
135151
```
136152

137153

@@ -323,6 +339,16 @@ If run with the '-net' option, hashrat will treat paths starting with 'http://'
323339
hashrat -net ssh://username:password@server/usr/bin/*
324340
```
325341

342+
7) As a TOTP authenticator
343+
344+
Hashrat can be used as a TOTP authenticator, and defaults to google-authenticator compatible codes.
345+
```
346+
hashrat -otp 3EK4LIB2553CUPA7DBXJMMKDCYTEA2IZA
347+
```
348+
349+
350+
351+
326352
HOOKSCRIPTS
327353
===========
328354

@@ -372,6 +398,50 @@ SegmentChar=+
372398
NoOptions=Y
373399
```
374400

401+
402+
TOTP MODE
403+
=========
404+
405+
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:
406+
407+
```
408+
hashrat -totp <secret>
409+
```
410+
411+
It's possible to change the hash, period/lifetime and number of digits in the TOTP code like so:
412+
413+
414+
```
415+
hashrat -totp 3EK4LIB2553CUPA7DB -sha256 -period 90 -digits 8
416+
```
417+
418+
419+
CLIPBOARD OUTPUT
420+
================
421+
422+
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.
423+
424+
Alternatively the `-xsel` option only attempts to use the xterm clipboard setting method.
425+
426+
The default list of clipboard commands can be overridden using the `-clipcmd` option.
427+
428+
429+
430+
QRCODE OUTPUT
431+
=============
432+
433+
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.
434+
435+
By default hashrat searches for the following image viewers:
436+
437+
```
438+
imlib2_view,fim,feh,display,xv,phototonic,qimageviewer,pix,sxiv,qimgv,qview,nomacs,geeqie,ristretto,mirage,fotowall,links -g
439+
```
440+
441+
The default list of image viewers can be overridden using the `-viewcmd` option.
442+
443+
444+
375445
EXTENDED FILESYSTEM ATTRIBUTES (XATTR)
376446
======================================
377447

0 commit comments

Comments
 (0)