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
11ad600c
Commit
11ad600c
authored
10 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added gzip and lzma extractor plugins
parent
db3018c8
fix-entropy-graph-legend
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
1 deletions
+91
-1
extract.conf
src/binwalk/config/extract.conf
+6
-1
gzipextract.py
src/binwalk/plugins/gzipextract.py
+43
-0
lzmaextract.py
src/binwalk/plugins/lzmaextract.py
+40
-0
zlibextract.py
src/binwalk/plugins/zlibextract.py
+2
-0
No files found.
src/binwalk/config/extract.conf
View file @
11ad600c
...
@@ -15,7 +15,12 @@
...
@@ -15,7 +15,12 @@
# o cpio
# o cpio
# o jffs2
# o jffs2
# o Raw LZMA/deflate streams
# o Raw LZMA/deflate streams
#
#
# There are also alternative extractors for the following file formats, implemented as plugins:
#
# o gzip
# o lzma
#
#################################################################################################################
#################################################################################################################
# Assumes these utilities are installed in $PATH.
# Assumes these utilities are installed in $PATH.
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/plugins/gzipextract.py
0 → 100644
View file @
11ad600c
import
os
import
gzip
import
binwalk.core.plugin
class
GzipExtractPlugin
(
binwalk
.
core
.
plugin
.
Plugin
):
'''
Gzip extractor plugin.
'''
MODULES
=
[
'Signature'
]
BLOCK_SIZE
=
10
*
1024
def
init
(
self
):
# If the extractor is enabled for the module we're currently loaded
# into, then register self.extractor as a zlib extraction rule.
if
self
.
module
.
extractor
.
enabled
:
self
.
module
.
extractor
.
add_rule
(
txtrule
=
None
,
regex
=
"^gzip compressed data"
,
extension
=
"gz"
,
cmd
=
self
.
extractor
)
def
extractor
(
self
,
fname
):
fname
=
os
.
path
.
abspath
(
fname
)
outfile
=
os
.
path
.
splitext
(
fname
)[
0
]
try
:
fpout
=
open
(
outfile
,
"wb"
)
gz
=
gzip
.
GzipFile
(
fname
,
"rb"
)
while
True
:
data
=
gz
.
read
(
self
.
BLOCK_SIZE
)
if
data
:
fpout
.
write
(
data
)
else
:
break
gz
.
close
()
fpout
.
close
()
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
return
False
return
True
This diff is collapsed.
Click to expand it.
src/binwalk/plugins/lzmaextract.py
0 → 100644
View file @
11ad600c
import
os
import
lzma
import
binwalk.core.plugin
class
LZMAExtractPlugin
(
binwalk
.
core
.
plugin
.
Plugin
):
'''
Gzip extractor plugin.
'''
MODULES
=
[
'Signature'
]
def
init
(
self
):
# If the extractor is enabled for the module we're currently loaded
# into, then register self.extractor as a zlib extraction rule.
if
self
.
module
.
extractor
.
enabled
:
self
.
module
.
extractor
.
add_rule
(
txtrule
=
None
,
regex
=
"^lzma compressed data"
,
extension
=
"7z"
,
cmd
=
self
.
extractor
)
def
extractor
(
self
,
fname
):
fname
=
os
.
path
.
abspath
(
fname
)
outfile
=
os
.
path
.
splitext
(
fname
)[
0
]
try
:
fpin
=
open
(
fname
,
"rb"
)
compressed
=
fpin
.
read
()
fpin
.
close
()
decompressed
=
lzma
.
decompress
(
compressed
)
print
(
"Decompressed
%
d bytes"
%
len
(
decompressed
))
fpout
=
open
(
outfile
,
"wb"
)
fpout
.
write
(
decompressed
)
fpout
.
close
()
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
return
False
return
True
This diff is collapsed.
Click to expand it.
src/binwalk/plugins/zlibextract.py
View file @
11ad600c
...
@@ -31,6 +31,8 @@ class ZLIBExtractPlugin(binwalk.core.plugin.Plugin):
...
@@ -31,6 +31,8 @@ class ZLIBExtractPlugin(binwalk.core.plugin.Plugin):
fpin
.
close
()
fpin
.
close
()
fpout
.
close
()
fpout
.
close
()
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
except
Exception
as
e
:
return
False
return
False
...
...
This diff is collapsed.
Click to expand it.
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