[Forensics-changes] [hashrat] 01/02: Import Upstream version 1.8.7+dfsg
Giovani Augusto Ferreira
giovani at moszumanska.debian.org
Tue Aug 29 02:46:37 UTC 2017
This is an automated email from the git hooks/post-receive script.
giovani pushed a commit to branch debian
in repository hashrat.
commit b8daff5b95d492f1a4f90571b919f49bee1bcd50
Author: Giovani Augusto Ferreira <giovani at debian.org>
Date: Mon Aug 28 23:45:24 2017 -0300
Import Upstream version 1.8.7+dfsg
---
check.sh | 2 +-
command-line-args.c | 30 ++++++++++++++++--------------
common.h | 7 +------
files.c | 28 +++++++++++++++++++++-------
hashrat.1 | 4 ++--
libUseful-2.5/GeneralFunctions.c | 1 -
main.c | 7 ++++---
7 files changed, 45 insertions(+), 34 deletions(-)
diff --git a/check.sh b/check.sh
index c058576..038f7ed 100755
--- a/check.sh
+++ b/check.sh
@@ -137,7 +137,7 @@ TestHash z85 "ZEROMQ85 encoding" "wX%ElWFTQ9+Z=X4h"
Title "Testing Misc. Features"
HR_OUT=`./hashrat -version`
-if [ "$HR_OUT" = "version: 1.8.3" ]
+if [ "$HR_OUT" = "version: 1.8.7" ]
then
OkayMessage "Version (-version) works"
else
diff --git a/command-line-args.c b/command-line-args.c
index 1b73ead..fb2f7d0 100644
--- a/command-line-args.c
+++ b/command-line-args.c
@@ -12,6 +12,8 @@
void AddIncludeExclude(HashratCtx *Ctx, int Type, const char *Item)
{
ListNode *Node;
+char *Token=NULL;
+const char *ptr;
//if we get given an include with no previous excludes, then
//set CTX_EXCLUDE as the default
@@ -21,8 +23,15 @@ if (! IncludeExclude)
if (Type==CTX_INCLUDE) Ctx->Flags |= CTX_EXCLUDE;
}
-Node=ListAddItem(IncludeExclude, CopyStr(NULL, Item));
-Node->ItemType=Type;
+ptr=GetToken(Item, ",",&Token, GETTOKEN_QUOTES);
+while (ptr)
+{
+ Node=ListAddItem(IncludeExclude, CopyStr(NULL, Token));
+ Node->ItemType=Type;
+ ptr=GetToken(ptr, ",",&Token, GETTOKEN_QUOTES);
+}
+
+DestroyString(Token);
}
@@ -93,22 +102,15 @@ return(ParseFlags);
void CommandLineSetCtx(int argc, char *argv[], int pos, HashratCtx *Ctx, int Flag, int Encoding)
{
if (Encoding > 0) Ctx->Encoding=Encoding;
-Ctx->Flags |= Flag;
strcpy(argv[pos],"");
-if (Flag == CTX_INCLUDE)
+if ((Flag==CTX_INCLUDE) || (Flag==CTX_EXCLUDE))
{
pos++;
- AddIncludeExclude(Ctx,CTX_INCLUDE, argv[pos]);
+ AddIncludeExclude(Ctx, Flag, argv[pos]);
strcpy(argv[pos],"");
}
-else if (Flag == CTX_EXCLUDE)
-{
- pos++;
- AddIncludeExclude(Ctx,CTX_EXCLUDE, argv[pos]);
- strcpy(argv[pos],"");
-}
-
+else Ctx->Flags |= Flag;
}
@@ -524,8 +526,8 @@ printf(" %-15s %s\n","-tag", "Output hashes in bsdsum format");
printf(" %-15s %s\n","--tag", "Output hashes in bsdsum format");
printf(" %-15s %s\n","-r", "Recurse into directories when hashing files");
printf(" %-15s %s\n","-f <listfile>", "Hash files listed in <listfile>");
-printf(" %-15s %s\n","-i <pattern>", "Only hash items matching <pattern>");
-printf(" %-15s %s\n","-x <pattern>", "Exclude items matching <pattern>");
+printf(" %-15s %s\n","-i <patterns>", "Only hash items matching a comma-seperated list of shell patterns");
+printf(" %-15s %s\n","-x <patterns>", "Exclude items matching a comma-sepearted list of shell patterns");
printf(" %-15s %s\n","-n <length>", "Truncate hashes to <length> bytes");
printf(" %-15s %s\n","-c", "CHECK hashes against list from file (or stdin)");
printf(" %-15s %s\n","-cf", "CHECK hashes against list but only show failures");
diff --git a/common.h b/common.h
index 51b47c7..0c4b26b 100644
--- a/common.h
+++ b/common.h
@@ -59,11 +59,6 @@
#define CTX_INCLUDE 16384
#define CTX_EXCLUDE 32768
-#define INEX_INCLUDE 1
-#define INEX_EXCLUDE 2
-#define INEX_INCLUDE_DIR 3
-#define INEX_EXCLUDE_DIR 4
-
#define RESULT_PASS 1
#define RESULT_FAIL 2
#define RESULT_WARN 4
@@ -77,7 +72,7 @@
#define IGNORE -1
-#define VERSION "1.8.3"
+#define VERSION "1.8.7"
typedef struct
diff --git a/files.c b/files.c
index 5c6de63..c042f0b 100644
--- a/files.c
+++ b/files.c
@@ -52,7 +52,7 @@ char *mptr, *dptr;
int result=TRUE;
if (Ctx->Flags & CTX_EXCLUDE) result=FALSE;
-if (S_ISDIR(FStat->st_mode)) result=TRUE;
+if (FStat && S_ISDIR(FStat->st_mode)) result=TRUE;
Curr=ListGetNext(IncludeExclude);
while (Curr)
@@ -60,35 +60,48 @@ while (Curr)
mptr=(char *) Curr->Item;
dptr=Path;
- if (*mptr!='/')
+ //if match pattern doesn't start with '/' then we want to strip that off the current path
+ //so that we can match against it. However if the match pattern contains no '/' at all, then
+ //it's a file name rather than a path, in which case we should use basename on both it and
+ //the current path
+ if (*mptr != '/')
{
+ if (strchr(mptr,'/'))
+ {
+ if (*dptr=='/') dptr++;
+ }
+ else
+ {
mptr=GetBasename(mptr);
dptr=GetBasename(Path);
+ }
}
switch (Curr->ItemType)
{
- case INEX_INCLUDE:
+ case CTX_INCLUDE:
if (fnmatch(mptr,dptr,0)==0) result=TRUE;
break;
- case INEX_EXCLUDE:
+ case CTX_EXCLUDE:
if (fnmatch(mptr,dptr,0)==0) result=FALSE;
break;
+/*
case INEX_INCLUDE_DIR:
if (strncmp(mptr,dptr,StrLen(mptr))==0) result=TRUE;
break;
case INEX_EXCLUDE_DIR:
if (strncmp(mptr,dptr,StrLen(mptr))==0) result=FALSE;
+ printf("FNMD: [%s] [%s] %d\n",mptr,dptr,result);
break;
+*/
}
Curr=ListGetNext(Curr);
}
-
return(result);
}
@@ -314,6 +327,8 @@ int ConsiderItem(HashratCtx *Ctx, char *Path, struct stat *FStat)
int Type;
Type=FileType(Path, Flags, FStat);
+ if (! IsIncluded(Ctx, Path, FStat)) return(CTX_EXCLUDE);
+
switch (Type)
{
case FT_SSH:
@@ -333,7 +348,6 @@ int ConsiderItem(HashratCtx *Ctx, char *Path, struct stat *FStat)
else if (FStat->st_dev != StartingFS) return(CTX_ONE_FS);
}
if ((Ctx->Flags & CTX_EXES) && (! (FStat->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))) return(CTX_EXCLUDE);
- if (! IsIncluded(Ctx,Path, FStat)) return(CTX_EXCLUDE);
}
return(0);
@@ -620,7 +634,7 @@ int result=FALSE;
int ProcessItem(HashratCtx *Ctx, char *Path, struct stat *Stat)
{
char *HashStr=NULL;
-int result=FALSE;
+int result=FALSE, Flags;
switch (ConsiderItem(Ctx, Path, Stat))
{
diff --git a/hashrat.1 b/hashrat.1
index 716be00..cf62168 100644
--- a/hashrat.1
+++ b/hashrat.1
@@ -140,11 +140,11 @@ Hash files listed in <listfile>.
.TP
.B
\fB-i\fP <pattern>
-Only \fIhash\fP items matching <pattern>.
+Only \fIhash\fP items matching a comma-seperated list of shell patterns. Please be aware that -i does not yet work on directories, only files.
.TP
.B
\fB-x\fP <pattern>
-Exclude items matching <pattern>.
+Exclude items matching a comma-seperated list of shell patterns. Works on both directories and files.
.TP
.B
\fB-n\fP <length>
diff --git a/libUseful-2.5/GeneralFunctions.c b/libUseful-2.5/GeneralFunctions.c
index 2680c77..dddb66c 100644
--- a/libUseful-2.5/GeneralFunctions.c
+++ b/libUseful-2.5/GeneralFunctions.c
@@ -131,7 +131,6 @@ for (ptr=Bytes; ptr < end; )
//so for the last chracter
RetStr=CatStrLen(RetStr,Buff,ptr-block);
}
-printf("\n");
return(RetStr);
}
diff --git a/main.c b/main.c
index 3594eac..af74c61 100644
--- a/main.c
+++ b/main.c
@@ -109,11 +109,12 @@ int i, result=IGNORE;
{
if (StrValid(argv[i]))
{
- if (StatFile(Ctx, argv[i],&Stat)==0)
+ if (StatFile(Ctx, argv[i],&Stat)==0) result=ProcessItem(Ctx, argv[i], &Stat);
+ else
{
- result=ProcessItem(Ctx, argv[i], &Stat);
+ if (result==IGNORE) result=0;
+ fprintf(stderr,"ERROR: File '%s' not found\n",argv[i]);
}
- else fprintf(stderr,"ERROR: File '%s' not found\n",argv[i]);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/hashrat.git
More information about the forensics-changes
mailing list