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
ef67b406
Commit
ef67b406
authored
Jul 01, 2017
by
Craig Heffner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated CPIO extrctor to generate unique output file names
parent
007012ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
cpio.py
src/binwalk/plugins/cpio.py
+11
-5
No files found.
src/binwalk/plugins/cpio.py
View file @
ef67b406
import
os
import
subprocess
import
binwalk.core.common
import
binwalk.core.plugin
class
CPIOPlugin
(
binwalk
.
core
.
plugin
.
Plugin
):
'''
...
...
@@ -27,20 +27,21 @@ class CPIOPlugin(binwalk.core.plugin.Plugin):
def
extractor
(
self
,
fname
):
result
=
None
fname
=
os
.
path
.
abspath
(
fname
)
out_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
fname
),
self
.
CPIO_OUT_DIR
)
out_dir_base_name
=
os
.
path
.
join
(
os
.
path
.
dirname
(
fname
),
self
.
CPIO_OUT_DIR
)
out_dir
=
binwalk
.
core
.
common
.
unique_file_name
(
out_dir_base_name
)
try
:
fpin
=
open
(
fname
,
"rb"
)
fperr
=
open
(
os
.
devnull
,
"rb"
)
os
.
mkdir
(
out_dir
)
except
OSError
:
return
return
False
try
:
curdir
=
os
.
getcwd
()
os
.
chdir
(
out_dir
)
except
OSError
:
return
return
False
try
:
result
=
subprocess
.
call
(
...
...
@@ -93,16 +94,20 @@ class CPIOPlugin(binwalk.core.plugin.Plugin):
# found.
if
result
.
description
.
startswith
(
'ASCII cpio archive'
):
#
Validate the reported name length
#
Parse the reported name length and file size
file_size
=
self
.
_get_file_size
(
result
.
description
)
file_name
=
self
.
_get_file_name
(
result
.
description
)
file_name_length
=
self
.
_get_file_name_length
(
result
.
description
)
# The +1 is to include the terminating NULL byte
if
file_name_length
!=
len
(
file_name
)
+
1
:
# If the reported length of the file name doesn't match the actual
# file name length, treat this as a false positive result.
result
.
valid
=
False
return
# Instruct binwalk to skip the rest of this CPIO entry.
# We don't want/need to scan what's inside it.
result
.
jump
=
self
.
CPIO_HEADER_SIZE
+
file_size
+
file_name_length
self
.
consecutive_hits
+=
1
...
...
@@ -133,3 +138,4 @@ class CPIOPlugin(binwalk.core.plugin.Plugin):
# TODO: It would be better to jump to the end of this CPIO
# entry rather than make this assumption...
result
.
valid
=
False
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