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
1288135d
Commit
1288135d
authored
May 18, 2015
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change output directory to CWD; fixed entropy BLOCK_SIZE bug.
parent
94a70ba8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
entropy.py
src/binwalk/modules/entropy.py
+8
-1
extractor.py
src/binwalk/modules/extractor.py
+9
-10
No files found.
src/binwalk/modules/entropy.py
View file @
1288135d
...
...
@@ -171,6 +171,10 @@ class Entropy(Module):
else
:
block_size
=
self
.
block_size
# Make sure block size is greater than 0
if
block_size
<=
0
:
block_size
=
self
.
DEFAULT_BLOCK_SIZE
binwalk
.
core
.
common
.
debug
(
"Entropy block size (
%
d data points):
%
d"
%
(
self
.
DEFAULT_DATA_POINTS
,
block_size
))
while
True
:
...
...
@@ -301,13 +305,16 @@ class Entropy(Module):
# TODO: legend is not displayed properly when saving plots to disk
if
self
.
save_plot
:
# Save graph to CWD
out_file
=
os
.
path
.
join
(
os
.
getcwd
(),
os
.
path
.
basename
(
fname
))
# exporters.ImageExporter is different in different versions of pyqtgraph
try
:
exporter
=
exporters
.
ImageExporter
(
plt
.
plotItem
)
except
TypeError
:
exporter
=
exporters
.
ImageExporter
.
ImageExporter
(
plt
.
plotItem
)
exporter
.
parameters
()[
'width'
]
=
self
.
FILE_WIDTH
exporter
.
export
(
binwalk
.
core
.
common
.
unique_file_name
(
fnam
e
,
self
.
FILE_FORMAT
))
exporter
.
export
(
binwalk
.
core
.
common
.
unique_file_name
(
out_fil
e
,
self
.
FILE_FORMAT
))
else
:
plt
.
setLabel
(
'left'
,
self
.
YLABEL
,
units
=
self
.
YUNITS
)
plt
.
setLabel
(
'bottom'
,
self
.
XLABEL
,
units
=
self
.
XUNITS
)
...
...
src/binwalk/modules/extractor.py
View file @
1288135d
...
...
@@ -122,8 +122,6 @@ class Extractor(Module):
# Holds a dictionary of the last directory listing for a given directory; used for identifying
# newly created/extracted files that need to be appended to self.pending.
self
.
last_directory_listing
=
{}
# Set to the directory path of the first extracted directory; this allows us to track recursion depth.
self
.
base_recursion_dir
=
""
def
callback
(
self
,
r
):
# Make sure the file attribute is set to a compatible instance of binwalk.core.common.BlockFile
...
...
@@ -171,7 +169,7 @@ class Extractor(Module):
# If recursion was specified, and the file is not the same one we just dd'd
if
self
.
matryoshka
and
file_path
!=
dd_file_path
and
scan_extracted_files
:
# If the recursion level of this file is less than or equal to our desired recursion level
if
len
(
real_file_path
.
split
(
self
.
base_recursion_dir
)[
1
]
.
split
(
os
.
path
.
sep
))
<=
self
.
matryoshka
:
if
len
(
real_file_path
.
split
(
self
.
directory
)[
1
]
.
split
(
os
.
path
.
sep
))
<=
self
.
matryoshka
:
# If this is a directory and we are supposed to process directories for this extractor,
# then add all files under that directory to the list of pending files.
if
os
.
path
.
isdir
(
file_path
):
...
...
@@ -335,6 +333,11 @@ class Extractor(Module):
if
not
has_key
(
self
.
extraction_directories
,
path
):
basedir
=
os
.
path
.
dirname
(
path
)
basename
=
os
.
path
.
basename
(
path
)
# Make sure we put the initial extracted file in the CWD
if
self
.
directory
is
None
:
basedir
=
os
.
getcwd
()
outdir
=
os
.
path
.
join
(
basedir
,
'_'
+
basename
)
output_directory
=
unique_file_name
(
outdir
,
extension
=
'extracted'
)
...
...
@@ -347,9 +350,9 @@ class Extractor(Module):
output_directory
=
self
.
extraction_directories
[
path
]
# Set the initial base extraction directory for later determining the level of recusion
# TODO: This is no longer needed since self.directory has the same information. Update code accordingly.
if
not
self
.
base_recursion_dir
:
self
.
base_recursion_dir
=
os
.
path
.
realpath
(
output_directory
)
+
os
.
path
.
sep
if
self
.
directory
is
None
:
self
.
directory
=
os
.
path
.
realpath
(
output_directory
)
+
os
.
path
.
sep
return
output_directory
...
...
@@ -398,10 +401,6 @@ class Extractor(Module):
output_directory
=
self
.
build_output_directory
(
file_name
)
# Update self.directory with the first output_directory path
if
self
.
directory
is
None
:
self
.
directory
=
output_directory
# Extract to end of file if no size was specified
if
not
size
:
size
=
file_size
(
file_path
)
-
offset
...
...
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