Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
binwalk
Commits
a30e51e1
Commit
a30e51e1
authored
11 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Began implementation of strings hashing.
parent
7eebc482
master
…
v2.3.4
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.2.0
v2.1.1
v2.0.1
v2.0.0
v1.3.0
python27
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
6 deletions
+35
-6
hashmatch.py
src/binwalk/hashmatch.py
+35
-6
No files found.
src/binwalk/hashmatch.py
View file @
a30e51e1
...
...
@@ -20,12 +20,13 @@ class HashMatch(object):
FUZZY_DEFAULT_CUTOFF
=
50
def
__init__
(
self
,
cutoff
=
None
,
fuzzy
=
True
,
same
=
False
,
missing
=
False
,
symlinks
=
False
,
matches
=
{},
types
=
{}):
def
__init__
(
self
,
cutoff
=
None
,
fuzzy
=
True
,
s
trings
=
False
,
s
ame
=
False
,
missing
=
False
,
symlinks
=
False
,
matches
=
{},
types
=
{}):
'''
Class constructor.
@cutoff - The fuzzy cutoff which determines if files are different or not.
@fuzy - Set to True to do fuzzy hashing; set to False to do traditional hashing.
@fuzzy - Set to True to do fuzzy hashing; set to False to do traditional hashing.
@strings - Only hash strings inside of the file, not the entire file itself.
@same - Set to True to show files that are the same, False to show files that are different.
@missing - Set to True to show missing files.
@symlinks - Set to True to include symbolic link files.
...
...
@@ -36,6 +37,7 @@ class HashMatch(object):
'''
self
.
cutoff
=
cutoff
self
.
fuzzy
=
fuzzy
self
.
strings
=
strings
self
.
show_same
=
same
self
.
show_missing
=
missing
self
.
symlinks
=
symlinks
...
...
@@ -68,6 +70,7 @@ class HashMatch(object):
hash1
=
ctypes
.
create_string_buffer
(
self
.
FUZZY_MAX_RESULT
)
hash2
=
ctypes
.
create_string_buffer
(
self
.
FUZZY_MAX_RESULT
)
# TODO: Implement strings hashing
try
:
if
self
.
lib
.
fuzzy_hash_filename
(
str2bytes
(
file1
),
hash1
)
==
0
and
self
.
lib
.
fuzzy_hash_filename
(
str2bytes
(
file2
),
hash2
)
==
0
:
if
hash1
.
raw
==
hash2
.
raw
:
...
...
@@ -138,7 +141,35 @@ class HashMatch(object):
return
set
(
file_list
)
def
file
(
self
,
fname
,
directories
):
'''
Search for a particular file in multiple directories.
@fname - File to search for.
@directories - List of directories to search in.
Returns a list of tuple results.
'''
matching_files
=
[]
for
directory
in
directories
:
for
f
in
self
.
_get_file_list
(
directory
):
f
=
os
.
path
.
join
(
directory
,
f
)
m
=
self
.
files
(
fname
,
f
)
if
self
.
is_match
(
m
):
matching_files
.
append
((
m
,
f
))
return
matching_files
def
directories
(
self
,
dir1
,
dir2
):
'''
Search two directories for matching files.
@dir1 - First directory.
@dir2 - Second directory.
Returns a list of tuple results.
'''
results
=
[]
dir1_files
=
self
.
_get_file_list
(
dir1
)
...
...
@@ -161,14 +192,12 @@ class HashMatch(object):
return
results
def
find_file
(
self
,
fname
,
directories
):
pass
if
__name__
==
'__main__'
:
import
sys
hmatch
=
HashMatch
(
missing
=
True
)
for
(
match
,
fname
)
in
hmatch
.
directories
(
sys
.
argv
[
1
],
sys
.
argv
[
2
]):
#for (match, fname) in hmatch.directories(sys.argv[1], sys.argv[2]):
for
(
match
,
fname
)
in
hmatch
.
find_file
(
sys
.
argv
[
1
],
sys
.
argv
[
2
:]):
print
match
,
fname
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment