<< NMEAsync | index | SplitSecret >>

SHA1files

SHA1files is a 32 bits console application that computes the SHA1 digest of files under Windows.

The main applications are

    * integrity checks: detection of any change in a directory tree to make sure no file has been deleted/modified/added
    * duplicates checks: detection of duplicate files on disk (based on their actual content, not their name or location)

Usage is :

   SHA1files {/root= [/duplicates] [/ExcludeList=] | [/verify=]}
         /root=            the directory where to begin
         /ExcludeList=     exclude the files matching the lines contained
                              in this text file (wildcards allowed)
         /duplicates       show the duplicate files only
         /verify=          compare the files currently on disk against
                              this text file containing the captured output
                              of a previous run of SHA1files

         All parameters ARE case sensitive.
         The lines in the ExcludeList must match the FULL path ("*\SHA1files.*").

   SHA1files /root=c:\test
   SHA1files /root=c:\test /duplicates
   SHA1files /root=c:\test /ExcludeList=SHA1ExcludeList.txt
   SHA1files /root=c:\test > reference.txt
   SHA1files /verify=reference.txt

Duplicates check:

   SHA1files /root=c:\Webserver\DocumentsRoot /duplicates
   SHA1files /root=c:\Webserver\DocumentsRoot /ExcludeList=SHA1filesExclude.txt /duplicates

Integrity check:

   SHA1files /root=c:\Webserver\DocumentsRoot > c:\SHA1files\references.txt
   SHA1files /verify=c:\SHA1files\references.txt

To exclude specific files from the process, create a text file (say "SHA1filesExclude.txt") like

   c:\Webserver\DocumentsRoot\*.log
   c:\Webserver\DocumentsRoot\dir1\ExcludeMe.txt
   ...

then

   SHA1files /root=c:\Webserver\DocumentsRoot /ExcludeList=SHA1filesExclude.txt > c:\SHA1files\references.txt
   SHA1files /verify=c:\SHA1files\references.txt

SHA1files supports the Universal Naming Convention (UNC) and therefore references like \\servername\sharename\path\filename are valid.

The exclude file may contain wild cards, and each line must match the FULL path.

    *.log : OK
    *server.log : OK
    c:\WebServer\*\server.log : OK
    *\readme.* : OK
    readme.* : NOT OK

    '*' matches any sequence of characters (zero or more)
    '?' matches any character
    [SET] matches any character in the specified set
    [!SET] or [^SET] matches any character not in the specified set
    \ is allowed within a set to escape a character like ']' or '-'

A set is composed of characters or ranges; a range looks like character hyphen character (as in 0-9 or A-Z). [0-9a-zA-Z_] is the minimal set of characters allowed in the [..] pattern construct.

To suppress the special syntactic significance of any of `[]*?!^-\', and match the character exactly, precede it with a `\'.


The return value (errorlevel) returned by SHA1files in "verify" mode are as follows :

    * ReturnValue = 0
    * if "files missing", ReturnValue = ReturnValue + 1
    * if "files changed", ReturnValue = ReturnValue + 2
    * if "new files", ReturnValue = ReturnValue + 4
    * if 'suspect line(s)', ReturnValue = ReturnValue + 8
    * if 'missing VerifyFile', ReturnValue = ReturnValue + 16

Using these value, batch files can be used to take the required actions (generate alarms, copy images or html files to report status from a web server, etc.)


Here is an example of a simple batch file that can be used as starting point :

      @echo off
      SHA1files /verify=c:\SHA1files\references.txt

      if errorlevel 16 goto LABEL16
      if errorlevel  8 goto LABEL8
      if errorlevel  7 goto LABEL7
      if errorlevel  6 goto LABEL6
      if errorlevel  5 goto LABEL5
      if errorlevel  4 goto LABEL4
      if errorlevel  3 goto LABEL3
      if errorlevel  2 goto LABEL2
      if errorlevel  1 goto LABEL1

      echo No change detected
      goto END

      :LABEL16
      echo Error opening Verify file
      echo Aborting
      goto END

      :LABEL8
      echo Suspect line(s) detected
      echo Aborting
      goto END

      :LABEL7
      echo New file(s) detected
      echo Changed file(s) detected
      echo Missing file(s) detected
      goto END

      :LABEL6
      echo New file(s) detected
      echo Changed file(s) detected
      goto END

      :LABEL5
      echo New file(s) detected
      echo Missing file(s) detected
      goto END

      :LABEL4
      echo New file(s) detected
      goto END

      :LABEL3
      echo Changed file(s) detected
      echo Missing file(s) detected
      goto END

      :LABEL2
      echo Changed file(s) detected
      goto END

      :LABEL1
      echo Missing file(s) detected
      goto END

      :END

SHA1files is freeware.

Download SHA1files_1_6.zip (+ 25 Kb - December 15, 2005)

NMEAsync.xml

Help, comments and suggestions are welcome: write to Christophe DAVID .

<< NMEAsync | index | SplitSecret >>


printer friendly view
PDF

   
Google
 
Web www.christophedavid.org