Commit 9eb51e30 by heffnercj

Fixed python2.6 file open bugs; fixed OSX library file extension bug.

parent d087d583
export CC=@CC@ export CC=@CC@
export CFLAGS=@CFLAGS@ export CFLAGS=@CFLAGS@
export SONAME=@SONAME@ export SONAME=@SONAME@
export SOEXT=@SOEXT@
export prefix=@prefix@ export prefix=@prefix@
export exec_prefix=@exec_prefix@ export exec_prefix=@exec_prefix@
export LIBDIR=@libdir@ export LIBDIR=@libdir@
......
LIBNAME=libcompress42.so LIBNAME=libcompress42.$(SOEXT)
all: clean $(LIBNAME) all: clean $(LIBNAME)
......
...@@ -600,6 +600,7 @@ ac_includes_default="\ ...@@ -600,6 +600,7 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS ac_subst_vars='LTLIBOBJS
INSTALL_OPTIONS INSTALL_OPTIONS
SOEXT
SONAME SONAME
LIBOBJS LIBOBJS
EGREP EGREP
...@@ -3278,14 +3279,18 @@ CFLAGS="-Wall -fPIC $CFLAGS" ...@@ -3278,14 +3279,18 @@ CFLAGS="-Wall -fPIC $CFLAGS"
if test "$(uname)" == "Darwin" if test "$(uname)" == "Darwin"
then then
SONAME="-install_name" SONAME="-install_name"
SOEXT="dylib"
INSTALL_OPTIONS="-m644" INSTALL_OPTIONS="-m644"
else else
SONAME="-soname" SONAME="-soname"
SOEXT="so"
INSTALL_OPTIONS="-D -m644" INSTALL_OPTIONS="-D -m644"
fi fi
SONAME=$SONAME SONAME=$SONAME
SOEXT=$SOEXT
INSTALL_OPTIONS=$INSTALL_OPTIONS INSTALL_OPTIONS=$INSTALL_OPTIONS
ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files Makefile"
......
...@@ -12,13 +12,16 @@ CFLAGS="-Wall -fPIC $CFLAGS" ...@@ -12,13 +12,16 @@ CFLAGS="-Wall -fPIC $CFLAGS"
if test "$(uname)" == "Darwin" if test "$(uname)" == "Darwin"
then then
SONAME="-install_name" SONAME="-install_name"
SOEXT="dylib"
INSTALL_OPTIONS="-m644" INSTALL_OPTIONS="-m644"
else else
SONAME="-soname" SONAME="-soname"
SOEXT="so"
INSTALL_OPTIONS="-D -m644" INSTALL_OPTIONS="-D -m644"
fi fi
AC_SUBST(SONAME, $SONAME) AC_SUBST(SONAME, $SONAME)
AC_SUBST(SOEXT, $SOEXT)
AC_SUBST(INSTALL_OPTIONS, $INSTALL_OPTIONS) AC_SUBST(INSTALL_OPTIONS, $INSTALL_OPTIONS)
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
AC_OUTPUT AC_OUTPUT
LIBNAME=libtinfl.so LIBNAME=libtinfl.$(SOEXT)
all: clean $(LIBNAME) all: clean $(LIBNAME)
......
from binwalk.common import *
from binwalk.plugins import * from binwalk.plugins import *
class Plugin: class Plugin:
...@@ -18,7 +19,7 @@ class Plugin: ...@@ -18,7 +19,7 @@ class Plugin:
def pre_scan(self, fd): def pre_scan(self, fd):
if self.enabled: if self.enabled:
self.fd = open(fd.name, 'rb') self.fd = BlockFile(fd.name, 'r')
def callback(self, results): def callback(self, results):
if self.fd: if self.fd:
......
import ctypes import ctypes
import ctypes.util import ctypes.util
from binwalk.common import *
from binwalk.plugins import * from binwalk.plugins import *
class Plugin: class Plugin:
...@@ -28,7 +29,7 @@ class Plugin: ...@@ -28,7 +29,7 @@ class Plugin:
def pre_scan(self, fd): def pre_scan(self, fd):
try: try:
if self.comp: if self.comp:
self.fd = open(fd.name, 'rb') self.fd = BlockFile(fd.name, 'r')
except: except:
pass pass
......
...@@ -13,7 +13,7 @@ class Plugin: ...@@ -13,7 +13,7 @@ class Plugin:
ENABLED = False ENABLED = False
SIZE = 33*1024 SIZE = 33*1024
# To prevent many false positives, only show data that decompressed to a reasonable size # To prevent many false positives, only show data that decompressed to a reasonable size
MIN_DECOMP_SIZE = 16*1024 MIN_DECOMP_SIZE = 32*1024
DESCRIPTION = "Deflate compressed data stream" DESCRIPTION = "Deflate compressed data stream"
def __init__(self, binwalk): def __init__(self, binwalk):
......
import ctypes import ctypes
import ctypes.util import ctypes.util
from binwalk.plugins import * from binwalk.plugins import *
from binwalk.common import BlockFile
class Plugin: class Plugin:
''' '''
...@@ -15,14 +16,14 @@ class Plugin: ...@@ -15,14 +16,14 @@ class Plugin:
self.tinfl = None self.tinfl = None
if binwalk.scan_type == binwalk.BINWALK: if binwalk.scan_type == binwalk.BINWALK:
# Add the zlib file to the list of magic files
binwalk.magic_files.append(binwalk.config.find_magic_file('zlib'))
# Load libtinfl.so # Load libtinfl.so
self.tinfl = ctypes.cdll.LoadLibrary(ctypes.util.find_library('tinfl')) self.tinfl = ctypes.cdll.LoadLibrary(ctypes.util.find_library('tinfl'))
# Add the zlib file to the list of magic files
binwalk.magic_files.append(binwalk.config.find_magic_file('zlib'))
def pre_scan(self, fd): def pre_scan(self, fd):
if self.tinfl: if self.tinfl:
self.fd = open(fd.name, 'rb') self.fd = BlockFile(fd.name, 'r')
def callback(self, result): def callback(self, result):
......
...@@ -4,6 +4,7 @@ import hashlib ...@@ -4,6 +4,7 @@ import hashlib
import csv as pycsv import csv as pycsv
from datetime import datetime from datetime import datetime
from binwalk.compat import * from binwalk.compat import *
from binwalk.common import BlockFile
class PrettyPrint: class PrettyPrint:
''' '''
...@@ -133,7 +134,7 @@ class PrettyPrint: ...@@ -133,7 +134,7 @@ class PrettyPrint:
''' '''
md5 = hashlib.md5() md5 = hashlib.md5()
with open(file_name, 'rb') as f: with BlockFile(file_name, 'r') as f:
for chunk in iter(lambda: f.read(128*md5.block_size), b''): for chunk in iter(lambda: f.read(128*md5.block_size), b''):
md5.update(chunk) md5.update(chunk)
......
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