Commit 02ec8f1f by devttys0

Minor updates to rehash

parent 23225665
...@@ -7,6 +7,8 @@ import binwalk.hashmatch as hashmatch ...@@ -7,6 +7,8 @@ import binwalk.hashmatch as hashmatch
from binwalk.compat import * from binwalk.compat import *
from getopt import GetoptError, gnu_getopt as GetOpt from getopt import GetoptError, gnu_getopt as GetOpt
DEFAULT_CUTOFF = 50
def usage(fd): def usage(fd):
fd.write("\n") fd.write("\n")
fd.write('Diff files or directories using Context Triggered Piecewise Hashing ("fuzzy" hashing).\n') fd.write('Diff files or directories using Context Triggered Piecewise Hashing ("fuzzy" hashing).\n')
...@@ -21,10 +23,10 @@ def usage(fd): ...@@ -21,10 +23,10 @@ def usage(fd):
fd.write("\n") fd.write("\n")
fd.write("Diffing Options:\n") fd.write("Diffing Options:\n")
fd.write("\t-d, --diff Show files that are different (default)\n") fd.write("\t-d, --diff Only show files that are different\n")
fd.write("\t-s, --same Show files that are the same\n") fd.write("\t-s, --same Only show files that are the same\n")
fd.write("\t-S, --strings Diff strings inside files instead of the entire file\n") fd.write("\t-S, --strings Diff strings inside files instead of the entire file\n")
fd.write("\t-c, --cutoff=<n> Set the cutoff percentage (default: 50%)\n") fd.write("\t-c, --cutoff=<n> Set the cutoff percentage (default: %d%)\n" % DEFAULT_CUTOFF)
fd.write("\t-m, --max=<n> Quit after n number of matches\n") fd.write("\t-m, --max=<n> Quit after n number of matches\n")
fd.write("\n") fd.write("\n")
...@@ -74,9 +76,9 @@ def main(): ...@@ -74,9 +76,9 @@ def main():
strings = False strings = False
symlinks = False symlinks = False
name = False name = False
same = False same = None
cutoff = None
max_results = None max_results = None
cutoff = 0
short_options = "acdf:hlm:no:qSstx:X:y:Y:" short_options = "acdf:hlm:no:qSstx:X:y:Y:"
long_options = [ long_options = [
...@@ -149,6 +151,11 @@ def main(): ...@@ -149,6 +151,11 @@ def main():
if opt not in arguments and opt not in options and not opt.startswith('-'): if opt not in arguments and opt not in options and not opt.startswith('-'):
file_list.append(opt) file_list.append(opt)
if same is None:
same = True
elif cutoff == 0:
cutoff = DEFAULT_CUTOFF
if include_files: if include_files:
matches[True] = include_files matches[True] = include_files
if exclude_files: if exclude_files:
......
...@@ -26,7 +26,7 @@ class HashMatch(object): ...@@ -26,7 +26,7 @@ class HashMatch(object):
# Files smaller than this won't produce meaningful fuzzy results (from ssdeep.h) # Files smaller than this won't produce meaningful fuzzy results (from ssdeep.h)
FUZZY_MIN_FILE_SIZE = 4096 FUZZY_MIN_FILE_SIZE = 4096
FUZZY_DEFAULT_CUTOFF = 50 FUZZY_DEFAULT_CUTOFF = 0
def __init__(self, cutoff=None, strings=False, same=False, symlinks=False, name=False, max_results=None, display=False, log=None, csv=False, quiet=False, format_to_screen=False, abspath=False, matches={}, types={}): def __init__(self, cutoff=None, strings=False, same=False, symlinks=False, name=False, max_results=None, display=False, log=None, csv=False, quiet=False, format_to_screen=False, abspath=False, matches={}, types={}):
''' '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment