Commit 7736d903 by devttys0

Updated documentation, cleaned up setup.py.

parent 4f83467d
...@@ -19,7 +19,7 @@ BASIC SCAN ...@@ -19,7 +19,7 @@ BASIC SCAN
with Binwalk() as bw: with Binwalk() as bw:
pprint.PrettyPrinter().pprint(bw.scan('firmware.bin')) pprint.PrettyPrinter().pprint(bw.scan('firmware.bin'))
The scan() method will return a dictionary of results, and may also be passed a list of files: The scan() method will return a list of results, and may also be passed a list of files:
from binwalk import Binwalk from binwalk import Binwalk
...@@ -30,7 +30,7 @@ BASIC SCAN ...@@ -30,7 +30,7 @@ BASIC SCAN
for result in results: for result in results:
print offset, result['description'] print offset, result['description']
Alternatively, a callback function may be specified. The callback function is called as soon as a match is found. Alternatively, a callback function may be specified. The callback function is called as soon as a valid signature is found.
It is passed two arguments: the offset at which the match was found, and a list of results dictionaries (one dictionary It is passed two arguments: the offset at which the match was found, and a list of results dictionaries (one dictionary
per result found at that offset): per result found at that offset):
...@@ -61,7 +61,6 @@ ADDING FILTERS ...@@ -61,7 +61,6 @@ ADDING FILTERS
binwalk.filter.exclude('jffs2') binwalk.filter.exclude('jffs2')
binwalk.scan('firmware') binwalk.scan('firmware')
binwalk.cleanup()
EXTRACTING FILES EXTRACTING FILES
...@@ -78,20 +77,18 @@ EXTRACTING FILES ...@@ -78,20 +77,18 @@ EXTRACTING FILES
# Extract results containing the string 'gzip' with a file extension of 'gz' and run the gunzip command # Extract results containing the string 'gzip' with a file extension of 'gz' and run the gunzip command
binwalk.extractor.add_rule('gzip:gz:gunzip %e') binwalk.extractor.add_rule('gzip:gz:gunzip %e')
# Extract 'gzip' and 'filesystem' results # Extract 'lzma' and 'filesystem' results
binwalk.extractor.add_rule(['gzip:gz', 'filesystem:fs']) binwalk.extractor.add_rule(['lzma:7z', 'filesystem:fs'])
binwalk.scan('firmware') binwalk.scan('firmware')
binwalk.cleanup()
To load the default extraction rules from the extract.conf file (such as with the --extract option): To load the default extraction rules from the extract.conf file (such as with the -e command line option):
from binwalk import Binwalk from binwalk import Binwalk
binwalk = Binwalk() binwalk = Binwalk()
binwalk.extractor.load_defaults() binwalk.extractor.load_defaults()
binwalk.scan('firmware.bin') binwalk.scan('firmware.bin')
binwalk.cleanup()
To enabled delayed file extraction (such as with the --delay option): To enabled delayed file extraction (such as with the --delay option):
...@@ -100,7 +97,6 @@ EXTRACTING FILES ...@@ -100,7 +97,6 @@ EXTRACTING FILES
binwalk = Binwalk() binwalk = Binwalk()
binwalk.extractor.enable_delayed_extract(True) binwalk.extractor.enable_delayed_extract(True)
binwalk.scan('firmware.bin') binwalk.scan('firmware.bin')
binwalk.cleanup()
To enable file cleanup after extraction (such as with the --rm option): To enable file cleanup after extraction (such as with the --rm option):
...@@ -109,5 +105,4 @@ EXTRACTING FILES ...@@ -109,5 +105,4 @@ EXTRACTING FILES
binwalk = Binwalk() binwalk = Binwalk()
binwalk.extractor.cleanup_extracted_files(True) binwalk.extractor.cleanup_extracted_files(True)
binwalk.scan('firmware.bin') binwalk.scan('firmware.bin')
binwalk.cleanup()
...@@ -2,6 +2,7 @@ BEFORE YOU START ...@@ -2,6 +2,7 @@ BEFORE YOU START
---------------------------------- ----------------------------------
Although binwalk supports Python 3, Python 2.7 is recommended. Although binwalk supports Python 3, Python 2.7 is recommended.
The following installation procedures assume that you are installing binwalk to be run using Python 2.7. The following installation procedures assume that you are installing binwalk to be run using Python 2.7.
If you want to use binwalk in Python 3, some package names and installation procedures may differ slightly. If you want to use binwalk in Python 3, some package names and installation procedures may differ slightly.
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
from __future__ import print_function from __future__ import print_function
import os import os
import sys import sys
import subprocess
from os import listdir, path from os import listdir, path
from distutils.core import setup from distutils.core import setup
...@@ -19,10 +18,6 @@ if "--yes" in sys.argv: ...@@ -19,10 +18,6 @@ if "--yes" in sys.argv:
else: else:
IGNORE_WARNINGS = False IGNORE_WARNINGS = False
def which(fname):
cmd = ["which", fname]
return subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.readline().strip()
def warning(lines, terminate=True, prompt=True): def warning(lines, terminate=True, prompt=True):
WIDTH = 115 WIDTH = 115
...@@ -107,11 +102,7 @@ fd = open("binwalk/magic/binwalk", "wb") ...@@ -107,11 +102,7 @@ fd = open("binwalk/magic/binwalk", "wb")
for magic in magic_files: for magic in magic_files:
fpath = path.join("magic", magic) fpath = path.join("magic", magic)
if path.isfile(fpath): if path.isfile(fpath):
data = open(fpath).read() fd.write(open(fpath, "rb").read())
try:
fd.write(data)
except TypeError:
fd.write(bytes(data, 'UTF-8'))
fd.close() fd.close()
# The data files to install along with the binwalk module # The data files to install along with the binwalk module
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment