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
Nov 07, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added gzip and lzma extractor plugins
parent
db3018c8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
0 deletions
+90
-0
extract.conf
src/binwalk/config/extract.conf
+5
-0
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
...
...
@@ -16,6 +16,11 @@
# o jffs2
# 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.
...
...
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
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
src/binwalk/plugins/zlibextract.py
View file @
11ad600c
...
...
@@ -31,6 +31,8 @@ class ZLIBExtractPlugin(binwalk.core.plugin.Plugin):
fpin
.
close
()
fpout
.
close
()
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
return
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