Skip to content

Commit

Permalink
v1.23
Browse files Browse the repository at this point in the history
  • Loading branch information
ColumPaget committed Dec 10, 2024
1 parent 7a9abfb commit 239241a
Show file tree
Hide file tree
Showing 123 changed files with 5,312 additions and 2,713 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.23 (2024-12-10)
* Add '-rename' option that inserts a hash into filenames.
* Filenames in 'duplicates' option are now contained in '[]', to allow extracting them with 'cut'.

v1.22 (2024-07-18)
* if '-cache' option is used with '-xattr', then do not update files where xattr hash matches the file (feature request from https://github.com/eatnumber1).

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CC = gcc
CFLAGS = -g -O2
LIBS = libUseful-5/libUseful.a -lssl -lcrypto -lz -lc
INSTALL=/usr/bin/install -c
LIBS = libUseful-5/libUseful.a -lssl -lcrypto -lz
INSTALL=/bin/install -c
prefix=/usr/local
bindir=$(prefix)${exec_prefix}/bin
FLAGS=$(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_LIBC=1 -DUSE_XATTR=1 -DHAVE_LIBZ=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBSSL=1
FLAGS=$(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBZ=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBSSL=1
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
EXE=hashrat

Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ OPTIONS
-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
-exec In CHECK or MATCH mode only examine executable files.
-dups Search for duplicate files.
-rename Rename files to include a hash in their name. Filename format is '<name>-<hash>.<extn>'
-n <length> Truncate hashes to <length> bytes
-segment <length> Break hash up into segments of <length> chars seperated by '-'
-c CHECK hashes against list from file (or stdin)
Expand Down Expand Up @@ -486,6 +487,31 @@ The default list of image viewers can be overridden using the `-viewcmd` option.



RENAME FILES
============

The '-rename' option allows renaming files to include a hash in their filename. The filename format is '<name>-<hash>.<extn>'. For example:


```
hashrat -p64 -md5 -rename main.c
```

Will rename 'main.c' to 'main-gAmHI2oarRmpiXkE7MVK90.c', where 'gAmHI2oarRmpiXkE7MVK90' is it's MD5 has encoded with the 'p64' base-64 encoding scheme.

The standard '-64' encoding scheme uses the '/' character, which is not allowed in a filename and results in renames failing. Thus the '-p64' or '-r64' encoding schemes should be used.


Using the '-r' flag entire directories of files can be renamed in this manner:

```
hashrat -p64 -md5 -rename -r myfiles
```



EXTENDED FILESYSTEM ATTRIBUTES (XATTR)
======================================

Expand Down
5 changes: 2 additions & 3 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ TestHash z85 "ZEROMQ85 encoding" "=SI2F3[n}kp9Zn?Ra>yK"
Title "Testing Misc. Features"

HR_OUT=`./hashrat -version`
if [ "$HR_OUT" = "version: 1.22" ]
if [ "$HR_OUT" = "version: 1.23" ]
then
OkayMessage "Version (-version) works"
else
Expand Down Expand Up @@ -269,7 +269,7 @@ else
fi

HR_OUT=`./hashrat -r -dups tests`
if [ "$HR_OUT" = "DUPLICATE: tests/quotes.txt of tests/duplicate.txt " ]
if [ "$HR_OUT" = "DUPLICATE: [tests/quotes.txt] of [tests/duplicate.txt] " ]
then
OkayMessage "Finding duplicate files works"
else
Expand All @@ -295,7 +295,6 @@ TestExitCodes "6ec9de513a8ff1768eb4768236198cf3" "tests/help.txt" "" "HashFile"
TestExitCodes "tests" "libUseful-5" "-r -dups" "FindDuplicates"
TestExitCodes "6ec9de513a8ff1768eb4768236198cf3" "tests/help.txt" "-cf" "CheckHash"
TestExitCodes "6ec9de513a8ff1768eb4768236198cf3" "tests/help.txt" "-m -r ." "Locate"
TestExitCodes "tests" "libUseful-5" "-r -dups" "FindDuplicates"

echo
echo
Expand Down
2 changes: 2 additions & 0 deletions command-line-args.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ HashratCtx *CommandLineParseArgs(int argc, char *argv[])
else if (strcmp(arg,"-m")==0) Ctx->Action = ACT_FINDMATCHES;
else if (strcmp(arg,"-lm")==0) Ctx->Action = ACT_LOADMATCHES;
else if (strcmp(arg,"-dups")==0) Ctx->Action = ACT_FINDDUPLICATES;
else if (strcmp(arg,"-rename")==0) Ctx->Action = ACT_RENAME;
else if (strcmp(arg,"-B")==0) Ctx->Action = ACT_BACKUP;
else if (strcmp(arg,"-cB")==0) Ctx->Action = ACT_CHECKBACKUP;
else if (strcmp(arg,"-cgi")==0) Ctx->Action = ACT_CGI;
Expand Down Expand Up @@ -503,6 +504,7 @@ void CommandLinePrintUsage()
printf(" %-15s %s\n","-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");
printf(" %-15s %s\n","-exec", "In CHECK or MATCH mode only examine executable files.");
printf(" %-15s %s\n","-dups", "Search for duplicate files.");
printf(" %-15s %s\n","-rename", "Rename files to <name>-<hash>.<extn>.");
printf(" %-15s %s\n","-n <length>", "Truncate hashes to <length> bytes");
printf(" %-15s %s\n","-segment <length>", "Break hash up into segments of <length> chars seperated by '-'");
printf(" %-15s %s\n","-c", "CHECK hashes against list from file (or stdin)");
Expand Down
3 changes: 2 additions & 1 deletion common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "libUseful-5/libUseful.h"
#include "glob.h"

#define VERSION "1.22"
#define VERSION "1.23"

#define ACT_NONE 0
#define ACT_HASH 1
Expand All @@ -28,6 +28,7 @@
#define ACT_CHECKBACKUP 25
#define ACT_OTP 26
#define ACT_LIST_TYPES 27
#define ACT_RENAME 28

#define FLAG_NEXTARG 1
//Two flags with the same values, but used in different contexts
Expand Down
Loading

0 comments on commit 239241a

Please sign in to comment.