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
5a52a5a8
Commit
5a52a5a8
authored
Dec 22, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up smart.Signature code, fixed Python3 ctypes bugs.
parent
881f0c18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
9 deletions
+11
-9
filter.py
src/binwalk/core/filter.py
+3
-3
smart.py
src/binwalk/core/smart.py
+0
-0
compression.py
src/binwalk/modules/compression.py
+2
-1
signature.py
src/binwalk/modules/signature.py
+2
-2
zlibvalid.py
src/binwalk/plugins/zlibvalid.py
+4
-3
No files found.
src/binwalk/core/filter.py
View file @
5a52a5a8
import
re
import
re
import
binwalk.core.common
as
common
import
binwalk.core.common
as
common
from
binwalk.core.smart
import
S
martS
ignature
from
binwalk.core.smart
import
Signature
from
binwalk.core.compat
import
*
from
binwalk.core.compat
import
*
class
Filter
:
class
Filter
:
...
@@ -32,7 +32,7 @@ class Filter:
...
@@ -32,7 +32,7 @@ class Filter:
self
.
grep_filters
=
[]
self
.
grep_filters
=
[]
self
.
show_invalid_results
=
show_invalid_results
self
.
show_invalid_results
=
show_invalid_results
self
.
exclusive_filter
=
False
self
.
exclusive_filter
=
False
self
.
smart
=
S
martS
ignature
(
self
)
self
.
smart
=
Signature
(
self
)
def
include
(
self
,
match
,
exclusive
=
True
):
def
include
(
self
,
match
,
exclusive
=
True
):
'''
'''
...
@@ -134,7 +134,7 @@ class Filter:
...
@@ -134,7 +134,7 @@ class Filter:
# Don't include quoted strings or keyword arguments in this search, as
# Don't include quoted strings or keyword arguments in this search, as
# strings from the target file may legitimately contain the INVALID_RESULT text.
# strings from the target file may legitimately contain the INVALID_RESULT text.
if
self
.
INVALID_RESULT
in
common
.
strip_quoted_strings
(
self
.
smart
.
_
strip_tags
(
data
)):
if
self
.
INVALID_RESULT
in
common
.
strip_quoted_strings
(
self
.
smart
.
strip_tags
(
data
)):
return
False
return
False
# There should be no non-printable characters in any of the data
# There should be no non-printable characters in any of the data
...
...
src/binwalk/core/smart.py
View file @
5a52a5a8
This diff is collapsed.
Click to expand it.
src/binwalk/modules/compression.py
View file @
5a52a5a8
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
os
import
os
import
ctypes
import
ctypes
import
ctypes.util
import
ctypes.util
from
binwalk.core.compat
import
str2bytes
from
binwalk.core.module
import
Option
,
Kwarg
,
Module
from
binwalk.core.module
import
Option
,
Kwarg
,
Module
class
Deflate
(
object
):
class
Deflate
(
object
):
...
@@ -46,7 +47,7 @@ class Deflate(object):
...
@@ -46,7 +47,7 @@ class Deflate(object):
def
decompress
(
self
,
data
):
def
decompress
(
self
,
data
):
description
=
None
description
=
None
decomp_size
=
self
.
tinfl
.
is_deflated
(
data
,
len
(
data
),
0
)
decomp_size
=
self
.
tinfl
.
is_deflated
(
str2bytes
(
data
)
,
len
(
data
),
0
)
if
decomp_size
>=
self
.
MIN_DECOMP_SIZE
:
if
decomp_size
>=
self
.
MIN_DECOMP_SIZE
:
description
=
self
.
DESCRIPTION
+
', uncompressed size >=
%
d'
%
decomp_size
description
=
self
.
DESCRIPTION
+
', uncompressed size >=
%
d'
%
decomp_size
...
...
src/binwalk/modules/signature.py
View file @
5a52a5a8
...
@@ -48,8 +48,8 @@ class Signature(Module):
...
@@ -48,8 +48,8 @@ class Signature(Module):
VERBOSE_HEADER_FORMAT
=
"
%
s
%
d"
VERBOSE_HEADER_FORMAT
=
"
%
s
%
d"
def
init
(
self
):
def
init
(
self
):
# Create S
martS
ignature and MagicParser class instances. These are mostly for internal use.
# Create Signature and MagicParser class instances. These are mostly for internal use.
self
.
smart
=
binwalk
.
core
.
smart
.
S
martS
ignature
(
self
.
config
.
filter
,
ignore_smart_signatures
=
self
.
dumb_scan
)
self
.
smart
=
binwalk
.
core
.
smart
.
Signature
(
self
.
config
.
filter
,
ignore_smart_signatures
=
self
.
dumb_scan
)
self
.
parser
=
binwalk
.
core
.
parser
.
MagicParser
(
self
.
config
.
filter
,
self
.
smart
)
self
.
parser
=
binwalk
.
core
.
parser
.
MagicParser
(
self
.
config
.
filter
,
self
.
smart
)
# If a raw byte sequence was specified, build a magic file from that instead of using the default magic files
# If a raw byte sequence was specified, build a magic file from that instead of using the default magic files
...
...
src/binwalk/plugins/zlibvalid.py
View file @
5a52a5a8
import
ctypes
import
ctypes
import
ctypes.util
import
ctypes.util
from
binwalk.core.compat
import
str2bytes
from
binwalk.core.common
import
BlockFile
from
binwalk.core.common
import
BlockFile
class
Plugin
(
object
):
class
Plugin
(
object
):
...
@@ -23,9 +24,9 @@ class Plugin(object):
...
@@ -23,9 +24,9 @@ class Plugin(object):
# If this result is a zlib signature match, try to decompress the data
# If this result is a zlib signature match, try to decompress the data
if
self
.
tinfl
and
result
.
file
and
result
.
description
.
lower
()
.
startswith
(
'zlib'
):
if
self
.
tinfl
and
result
.
file
and
result
.
description
.
lower
()
.
startswith
(
'zlib'
):
# Seek to and read the suspected zlib data
# Seek to and read the suspected zlib data
fd
=
self
.
module
.
config
.
open_file
(
result
.
file
.
name
,
offset
=
result
.
offset
)
fd
=
self
.
module
.
config
.
open_file
(
result
.
file
.
name
,
offset
=
result
.
offset
,
length
=
self
.
MAX_DATA_SIZE
)
#
BlockFile(result.file.name, offset=result.offset, swap=self.module.config.swap_size)
#
Python3 ctypes needs a bytes object, not a str
data
=
fd
.
read
(
self
.
MAX_DATA_SIZE
)
data
=
str2bytes
(
fd
.
read
(
self
.
MAX_DATA_SIZE
)
)
fd
.
close
()
fd
.
close
()
# Check if this is valid zlib data
# Check if this is valid zlib data
...
...
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