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
b7085a2f
Commit
b7085a2f
authored
Oct 24, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added internal cpio extractor
parent
61f12a77
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
16 deletions
+37
-16
extract.conf
src/binwalk/config/extract.conf
+1
-2
cpio.py
src/binwalk/plugins/cpio.py
+36
-14
No files found.
src/binwalk/config/extract.conf
View file @
b7085a2f
...
...
@@ -9,7 +9,7 @@
# For example '%%squashfs-root%%' will be replaced with 'squashfs-root-0'
# if 'squashfs-root' already exists.
#
# Some extractors are internal and not listed here, such as those for zlib
files
and raw LZMA/deflate streams.
# Some extractors are internal and not listed here, such as those for zlib
, cpio,
and raw LZMA/deflate streams.
#################################################################################################################
# Assumes these utilities are installed in $PATH.
...
...
@@ -43,7 +43,6 @@
# These were the extractors used from FMK that still need suitable replacements.
#^jffs2 filesystem:jffs2:/opt/firmware-mod-kit/src/jffs2/unjffs2 '%e'
#^ascii cpio archive:cpio:/opt/firmware-mod-kit/uncpio.sh '%e'
#^bff volume entry:bff:/opt/firmware-mod-kit/src/bff/bffxtractor.py '%e'
#^wdk file system:wdk:/opt/firmware-mod-kit/src/firmware-tools/unwdk.py '%e'
...
...
src/binwalk/plugins/cpio.py
View file @
b7085a2f
import
os
import
subprocess
import
binwalk.core.plugin
class
CPIOPlugin
(
binwalk
.
core
.
plugin
.
Plugin
):
'''
Ensures that ASCII CPIO archive entries only get extracted once.
Also provides an internal CPIO extraction wrapper around the Unix
cpio utility since no output directory can be provided to it directly.
'''
#
CPIO_OUT_DIR = "cpio-root"
CPIO_OUT_DIR
=
"cpio-root"
MODULES
=
[
'Signature'
]
#
def init(self):
#
if self.module.extractor.enabled:
#
self.module.extractor.add_rule(regex="^ascii cpio archive",
#
extension="cpio",
#
cmd=self.extractor)
def
init
(
self
):
if
self
.
module
.
extractor
.
enabled
:
self
.
module
.
extractor
.
add_rule
(
regex
=
"^ascii cpio archive"
,
extension
=
"cpio"
,
cmd
=
self
.
extractor
)
# def extractor(self, fname):
# out_dir = os.path.join(os.path.split(fname)[0], self.CPIO_OUT_DIR)
def
extractor
(
self
,
fname
):
fname
=
os
.
path
.
abspath
(
fname
)
out_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
fname
),
self
.
CPIO_OUT_DIR
)
# try:
# os.mkdir(out_dir)
# except OSError:
# return
try
:
fpin
=
open
(
fname
,
"rb"
)
fperr
=
open
(
os
.
devnull
,
"rb"
)
os
.
mkdir
(
out_dir
)
except
OSError
:
return
# # Lazy.
# os.system("cd '%s' && cpio -d -i --no-absolute-filenames < '%s' 2>&1 1>/dev/null" % (out_dir, fname))
try
:
curdir
=
os
.
getcwd
()
os
.
chdir
(
out_dir
)
except
OSError
:
return
try
:
subprocess
.
call
([
'cpio'
,
'-d'
,
'-i'
,
'--no-absolute-filenames'
],
stdin
=
fpin
,
stderr
=
fperr
,
stdout
=
fperr
)
except
OSError
:
pass
os
.
chdir
(
curdir
)
fpin
.
close
()
fperr
.
close
()
def
pre_scan
(
self
):
# Be sure to re-set this at the beginning of every scan
...
...
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