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-gitdep
binwalk
Commits
bf87972e
Commit
bf87972e
authored
Dec 03, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added initial fuzzy hashing code.
parent
2d10ab63
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
fuzzyhash.py
src/binwalk/fuzzyhash.py
+29
-0
No files found.
src/binwalk/fuzzyhash.py
0 → 100644
View file @
bf87972e
import
ctypes
import
ctypes.util
from
binwalk.compat
import
*
class
FuzzyHash
(
object
):
# Requires libfuzzy.so
LIBRARY_NAME
=
"fuzzy"
# Max result is 148 (http://ssdeep.sourceforge.net/api/html/fuzzy_8h.html)
FUZZY_MAX_RESULT
=
150
def
__init__
(
self
):
self
.
lib
=
ctypes
.
cdll
.
LoadLibrary
(
ctypes
.
util
.
find_library
(
self
.
LIBRARY_NAME
))
def
compare_files
(
self
,
file1
,
file2
):
hash1
=
ctypes
.
create_string_buffer
(
self
.
FUZZY_MAX_RESULT
)
hash2
=
ctypes
.
create_string_buffer
(
self
.
FUZZY_MAX_RESULT
)
if
self
.
lib
.
fuzzy_hash_filename
(
str2bytes
(
file1
),
hash1
)
==
0
and
self
.
lib
.
fuzzy_hash_filename
(
str2bytes
(
file2
),
hash2
)
==
0
:
return
self
.
lib
.
fuzzy_compare
(
hash1
,
hash2
)
return
None
if
__name__
==
'__main__'
:
import
sys
print
(
FuzzyHash
()
.
compare_files
(
sys
.
argv
[
1
],
sys
.
argv
[
2
]))
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