Commit 62e25031 by devttys0

Removed all C code from the project

parent fe18fbe3
export CC=@CC@
export CFLAGS=@CFLAGS@
export CPPFLAGS=@CPPFLAGS@
export SONAME=@SONAME@
export SOEXT=@SOEXT@
export prefix=@prefix@
export exec_prefix=@exec_prefix@
export LIBDIR=@libdir@
export INSTALL_OPTIONS=@INSTALL_OPTIONS@
export PLATFORM=@PLATFORM@
export BUILD_MAGIC=@BUILD_MAGIC@
export BUILD_FUZZY=@BUILD_FUZZY@
export PYLIBDIR="./binwalk/libs"
BUILD_C_LIBS=@BUILD_C_LIBS@
BUILD_BUNDLES=@BUILD_BUNDLES@
PYTHON=@PYTHON@
IDA_DIR?=@IDA_DIR@
SRC_DIR="./src"
SCRIPTS_DIR="$(SRC_DIR)/scripts"
SRC_C_DIR="$(SRC_DIR)/C"
SRC_BUNDLES_DIR="$(SRC_DIR)/bundles"
ifeq ($(strip $(prefix)),)
PREFIX=""
else
PREFIX="--prefix=$(DESTDIR)$(prefix)"
endif
.PHONY: all install build clean uninstall
all: build
install: build
$(PYTHON) ./setup.py install $(PREFIX)
ida: build
if [ "$(IDA_DIR)" != "" ] && [ -e "$(IDA_DIR)/plugins" ]; then cp $(SCRIPTS_DIR)/binida.py $(IDA_DIR)/plugins/; fi
if [ "$(IDA_DIR)" != "" ] && [ -e "$(IDA_DIR)/python/lib/python2.7" ]; then cp -R $(SRC_DIR)/binwalk $(IDA_DIR)/python/lib/python2.7/; fi
build:
if [ "$(BUILD_C_LIBS)" = "yes" ]; then make -C $(SRC_C_DIR); fi
if [ "$(BUILD_BUNDLES)" = "yes" ]; then make -C $(SRC_BUNDLES_DIR); fi
$(PYTHON) ./setup.py build
clean:
if [ "$(BUILD_C_LIBS)" = "yes" ]; then make -C $(SRC_C_DIR) clean; fi
if [ "$(BUILD_BUNDLES)" = "yes" ]; then make -C $(SRC_BUNDLES_DIR) clean; fi
$(PYTHON) ./setup.py clean
distclean: clean
if [ "$(BUILD_C_LIBS)" = "yes" ]; then make -C $(SRC_C_DIR) distclean; fi
if [ "$(BUILD_BUNDLES)" = "yes" ]; then make -C $(SRC_BUNDLES_DIR) distclean; fi
rm -rf Makefile config.* *.cache
uninstall:
$(PYTHON) ./setup.py uninstall --pydir=`find $(prefix)/lib -name binwalk | head -1` --pybin=`find $(prefix)/bin -name binwalk | head -1`
AC_PREREQ([2.65])
AC_INIT()
AC_PROG_CC
AC_LANG(C)
AC_TYPE_SIZE_T
AC_FUNC_MALLOC
AC_ARG_WITH([ida],
[AS_HELP_STRING([--with-ida=$HOME/ida], [define the IDA install path])],
[IDA_DIR=$withval],
[IDA_DIR=$HOME/ida])
AC_ARG_WITH([python],
[AS_HELP_STRING([--with-python=python], [explicitly install using the specified python interpreter (python2, python3, etc)])],
[PYTHON=$withval],
[PYTHON=python])
AC_ARG_ENABLE([clibs],
[AS_HELP_STRING([--disable-clibs], [do not build/install binwalk c libraries])],,
[BUILD_C_LIBS=yes])
AC_ARG_ENABLE([libmagic],
[AS_HELP_STRING([--enable-libmagic], [build/install the bundled libmagic library])],,
[BUILD_MAGIC=no])
CFLAGS="-Wall -fPIC $CFLAGS"
INSTALL_OPTIONS="-m644"
if test "$prefix" != "NONE"
then
echo "install prefix: $prefix"
fi
if test "$(uname)" == "Darwin"
then
SONAME="-install_name"
SOEXT="dylib"
else
SONAME="-soname"
SOEXT="so"
fi
if test "$BUILD_BUNDLES" == "no"
then
BUILD_MAGIC=no
fi
if test "$BUILD_MAGIC" != "no"
then
rm -rf $(ls ./src/bundles/file-*.tar.gz | sed -e 's/\.tar\.gz//')
(cd ./src/bundles && tar -zxvf file-*.tar.gz > /dev/null)
(cd ./src/bundles/file-*/ && ./configure) || exit 1
fi
AC_SUBST(BUILD_C_LIBS, $BUILD_C_LIBS)
AC_SUBST(BUILD_BUNDLES, $BUILD_BUNDLES)
AC_SUBST(BUILD_MAGIC, $BUILD_MAGIC)
AC_SUBST(PYTHON, $PYTHON)
AC_SUBST(IDA_DIR, $IDA_DIR)
AC_SUBST(SONAME, $SONAME)
AC_SUBST(SOEXT, $SOEXT)
AC_SUBST(PLATFORM, $(uname -s))
AC_SUBST(INSTALL_OPTIONS, $INSTALL_OPTIONS)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
LIB_DIR="../$(PYLIBDIR)"
.PHONY: all clean_libs clean distclean
all:
make -C compress
cp compress/*.$(SOEXT) $(LIB_DIR)
clean_libs:
rm -f $(LIB_DIR)/libcompress42.$(SOEXT)
clean: clean_libs
make -C compress clean
distclean: clean_libs
make -C compress distclean
About
-----
The libraries in this directory have been patched, extended, or otherwise modified from their original versions for use with binwalk.
Specifically, libcompress42` contains code taken from the ncompress Unix utility and turned into a library. It is similar to the liblzw library (also ripped from ncompress source), but supports decompression of arbitrary data buffers and includes several useful wrapper functions. To the author's knowledge, this functionality is not available elsewhere as a standard library.
Package mantainers should consult their particular distribution's rules on bundled code with regards to the above libraries.
Installation
------------
These libraries will be built and installed by default, unless the `--disable-clibs` option is provided to the configure script.
The libraries will be installed to the `lib` sub-directory of the binwalk Python module so as to not conflict with existing libraries on the system.
LIBNAME=libcompress42.$(SOEXT)
all: $(LIBNAME)
$(LIBNAME): compress42.o
$(CC) $(CFLAGS) $(CPPFLAGS) -shared -Wl,$(SONAME),$(LIBNAME) compress42.o -o $(LIBNAME) $(LDFLAGS)
chmod +x $(LIBNAME)
compress42.o:
$(CC) $(CFLAGS) $(CPPFLAGS) compress42.c -c
install:
mkdir -p $(DESTDIR)$(LIBDIR)
install $(INSTALL_OPTIONS) $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
uninstall:
rm -rf $(DESTDIR)$(LIBDIR)/$(LIBNAME)
.PHONY: clean distclean
clean:
rm -f *.o $(LIBNAME)
distclean: clean
Unix compress implementation of LZW (from debian source repository).
Used by the compressd plugin to validate potential compress'd candidates.
...@@ -19,10 +19,16 @@ class CompressdPlugin(binwalk.core.plugin.Plugin): ...@@ -19,10 +19,16 @@ class CompressdPlugin(binwalk.core.plugin.Plugin):
comp = None comp = None
def init(self): def init(self):
self.comp = binwalk.core.C.Library(self.COMPRESS42, self.COMPRESS42_FUNCTIONS) #self.comp = binwalk.core.C.Library(self.COMPRESS42, self.COMPRESS42_FUNCTIONS)
# This plugin is currently disabled due to the need to move away from supporting C
# libraries and into a pure Python project, for cross-platform support and ease of
# installation / package maintenance. A Python implementation will likely need to
# be custom developed in the future, but for now, since this compression format is
# not very common, especially in firmware, simply disable it.
self.comp = None
def scan(self, result): def scan(self, result):
if result.file and result.description.lower().startswith("compress'd data"): if self.comp and result.file and result.description.lower().startswith("compress'd data"):
fd = self.module.config.open_file(result.file.name, offset=result.offset, length=self.READ_SIZE) fd = self.module.config.open_file(result.file.name, offset=result.offset, length=self.READ_SIZE)
compressed_data = fd.read(self.READ_SIZE) compressed_data = fd.read(self.READ_SIZE)
fd.close() fd.close()
......
LIB_DIR="../$(PYLIBDIR)"
FILE_VERSION=`ls file-*.tar.gz | cut -d'-' -f2 | cut -d '.' -f1,2`
.PHONY: all clean_libs clean distclean
all:
if [ "$(BUILD_MAGIC)" = "yes" ]; then make -C file-$(FILE_VERSION)/src magic.h; fi # This must be done first for OSX, else MAGIC_VERSION is undefined
if [ "$(BUILD_MAGIC)" = "yes" ]; then make -C file-$(FILE_VERSION)/src libmagic.la; fi
if [ "$(BUILD_MAGIC)" = "yes" ]; then cp file-$(FILE_VERSION)/src/.libs/libmagic.$(SOEXT) $(LIB_DIR); fi
clean_libs:
rm -f $(LIB_DIR)/libmagic.$(SOEXT)
clean: clean_libs
if [ "$(BUILD_MAGIC)" = "yes" ]; then make -C file-$(FILE_VERSION) clean; fi
distclean: clean_libs
rm -rf ./file-$(FILE_VERSION)
About
-----
The libraries contained in this directory are provided for convenience of installation, and have not been modified.
Package maintainers can generally replace these libraries with standard libraries from their particular distribution's package repository, however, the root `INSTALL.md` file should be consulted first.
Installation
------------
These libraries are not built or installed by default, unless the `--enable-<libname>` option is provided to the configure script.
They will be installed into the `libs` sub-directory of the binwalk Python module, so as to not conflict with existing libraries on the system.
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
>7 byte x \b.%d >7 byte x \b.%d
# standard unix compress # standard unix compress
# Implemented in the compress binwalk plugin. # Disabled until a python alternative can be foudn for the compress binwalk plugin.
#0 string \x1f\x9d\x90 compress'd data, 16 bits #0 string \x1f\x9d\x90 compress'd data, 16 bits
# http://tukaani.org/xz/xz-file-format.txt # http://tukaani.org/xz/xz-file-format.txt
...@@ -165,8 +165,6 @@ ...@@ -165,8 +165,6 @@
0 string \xff\x06\x00\x00\x73\x4e\x61\x50\x70\x59 Snappy compression, stream identifier 0 string \xff\x06\x00\x00\x73\x4e\x61\x50\x70\x59 Snappy compression, stream identifier
0 string \x1f\x9d\x90 compress'd data, 16 bits
#0 beshort 0x7801 Zlib header, no compression #0 beshort 0x7801 Zlib header, no compression
0 beshort 0x789c Zlib compressed data, default compression 0 beshort 0x789c Zlib compressed data, default compression
0 beshort 0x78da Zlib compressed data, best compression 0 beshort 0x78da Zlib compressed data, best compression
......
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