Update capstone and transplant io.ewf to the r2e repo

This commit is contained in:
pancake 2015-01-09 16:21:47 +01:00
parent 6ee5b5003c
commit 826477db9a
6 changed files with 4 additions and 246 deletions

28
configure vendored
View file

@ -22,8 +22,6 @@ DEBUGGER=1
USE_MAGIC=0
USE_CAPSTONE=0
USE_ZIP=0
HAVE_LIBVERSION=1
HAVE_EWF=1
WANT_OPENSSL=0
USE_RPATH=0
HAVE_LILEND=0
@ -167,8 +165,6 @@ Optional Features:
--with-sysmagic force to use system's magic
--with-syscapstone force to use system-wide capstone
--with-syszip force to use system's libzip and zlib
--without-libversion disable version library builds
--without-ewf disable EWF dependency
--with-openssl build with openssl if possible
--with-rpath use rpath to build
--with-little-endian force little endian
@ -232,8 +228,8 @@ echo "VERSION: 0.9.9-git"
echo "LANGS: c"
echo "REQUIRED: libdl"
echo "OPTIONAL: libmagic"
echo "PKG-CONFIG: capstone libewf openssl"
echo "FLAGS: --enable-cparse --disable-debugger --with-sysmagic --with-syscapstone --with-syszip --without-libversion --without-ewf --with-openssl --with-rpath --with-little-endian --with-big-endian --with-compiler=gcc --with-ostype=auto --without-pic --with-nonpic --with-libversion=xxx"
echo "PKG-CONFIG: capstone openssl"
echo "FLAGS: --enable-cparse --disable-debugger --with-sysmagic --with-syscapstone --with-syszip --with-openssl --with-rpath --with-little-endian --with-big-endian --with-compiler=gcc --with-ostype=auto --without-pic --with-nonpic --with-libversion=xxx"
exit 0
;;
--cache-file)
@ -282,8 +278,6 @@ echo "FLAGS: --enable-cparse --disable-debugger --with-sysmagic --with-sysca
"--with-sysmagic") USE_MAGIC="1"; ;;
"--with-syscapstone") USE_CAPSTONE="1"; ;;
"--with-syszip") USE_ZIP="1"; ;;
"--without-libversion") HAVE_LIBVERSION="0"; ;;
"--without-ewf") HAVE_EWF="0"; ;;
"--with-openssl") WANT_OPENSSL="1"; ;;
"--with-rpath") USE_RPATH="1"; ;;
"--with-little-endian") HAVE_LILEND="1"; ;;
@ -310,7 +304,7 @@ parse_options $1
shift
done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C CPARSE DEBUGGER HAVE_LIB_DL DL_LIBS LIL_ENDIAN BIG_ENDIAN BYTEORDER HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC USE_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_EWF EWF_CFLAGS EWF_LDFLAGS HAVE_PKGCFG_LIBEWF HAVE_LIBVERSION HAVE_EWF HAVE_LIB_GMP HAVE_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL USE_RPATH HAVE_LILEND HAVE_BIGEND HAVE_LIB_LUA5_1 USERCC USEROSTYPE WITHPIC WITHNONPIC LIBVERSION"
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C CPARSE DEBUGGER HAVE_LIB_DL DL_LIBS LIL_ENDIAN BIG_ENDIAN BYTEORDER HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC USE_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_GMP HAVE_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL USE_RPATH HAVE_LILEND HAVE_BIGEND HAVE_LIB_LUA5_1 USERCC USEROSTYPE WITHPIC WITHNONPIC LIBVERSION"
create_environ
@ -419,22 +413,6 @@ LIBZIP="-lrz"; fi
else
USE_LIB_ZIP="0"
LIBZIP="-lrz"; fi
check_library HAVE_LIB_EWF ewf 0
printf 'checking pkg-config flags for libewf... '
tmp=`pkg-config --cflags libewf 2>/dev/null`
if [ '!' $? = 0 ]; then echo no ; HAVE_PKGCFG_LIBEWF=0;
else
EWF_CFLAGS=$tmp;
tmp=`pkg-config --libs libewf 2>/dev/null`
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_LIBEWF=1;
EWF_LDFLAGS=$tmp; fi; fi
if [ "$HAVE_PKGCFG_LIBEWF" = "1" ]; then
HAVE_LIB_EWF="1"
else
HAVE_LIB_EWF="0"; fi
if [ "$HAVE_EWF" = "0" ]; then
HAVE_LIB_EWF="0"; fi
HAVE_LIB_GMP="0"
HAVE_GMP="0"
check_library HAVE_LIB_SSL ssl 0

View file

@ -45,17 +45,6 @@ IFAND HAVE_LIB_Z USE_ZIP {
LIBZIP = -lrz ; (( static linking to shlr/zip ))
}
CHKLIB ewf
PKGCFG EWF_CFLAGS EWF_LDFLAGS libewf
ARG_WITHOUT HAVE_LIBVERSION libversion disable version library builds ;
ARG_WITHOUT HAVE_EWF ewf disable EWF dependency ;
IF HAVE_PKGCFG_LIBEWF {
HAVE_LIB_EWF = 1 ;
}{
HAVE_LIB_EWF = 0 ;
}
IFNOT HAVE_EWF { HAVE_LIB_EWF = 0 ; }
(( TODO must deprecate
CHKLIB gmp
ARG_WITHOUT HAVE_GMP gmp disable GMP dependency ;

View file

@ -1,22 +0,0 @@
OBJ_EWF=io_ewf.o
STATIC_OBJ+=${OBJ_EWF}
TARGET_EWF=io_ewf.${EXT_SO}
ALL_TARGETS+=${TARGET_EWF}
ifeq (${HAVE_LIB_EWF},1)
CFLAGS+=${EWF_CFLAGS}
LDFLAGS+=${EWF_LDFLAGS}
endif
#/opt/local/include
ifeq (${WITHPIC},0)
LINKFLAGS+=../../util/libr_util.a
LINKFLAGS+=../../io/libr_io.a
else
LINKFLAGS+=-L../../util -lr_util
LINKFLAGS+=-L.. -lr_io
endif
${TARGET_EWF}: ${OBJ_EWF}
${CC_LIB} $(call libname,io_ewf) ${CFLAGS} -o ${TARGET_EWF} ${OBJ_EWF} ${LINKFLAGS}

View file

@ -1,186 +0,0 @@
/* radare - LGPL - Copyright 2007-2013 pancake */
// XXX: not yet tested
#include "r_io.h"
#include "r_lib.h"
#include <r_userconf.h>
#if HAVE_LIB_EWF
#include <sys/types.h>
#include <sys/ipc.h>
#include <libewf.h>
struct r_io_plugin_t r_io_plugin_ewf;
//#define EWF_FD 0x19b19b
typedef struct {
int fd;
libewf_handle_t *handle;
} RIOEwf;
#define RIOEWF_TO_FD(x) ((int)(size_t)(x))
#define RIOEWF_HANDLE(x) (((RIOEwf*)x->data)->handle)
#define RIOEWF_IS_VALID(x) ((x) && (x->data) && (x->plugin==&r_io_plugin_ewf))
static int ewf__write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
return libewf_handle_write_buffer (RIOEWF_HANDLE (fd),
(void*)buf, count, NULL);
}
static int ewf__read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
return libewf_handle_read_buffer (RIOEWF_HANDLE (fd), buf, count, NULL);
}
static int ewf__close(RIODesc *fd) {
if (RIOEWF_IS_VALID (fd)) {
libewf_handle_close (RIOEWF_HANDLE (fd), NULL);
return 0;
}
return -1;
}
static ut64 ewf__lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
if (RIOEWF_IS_VALID (fd)) {
size64_t media_size;
switch (whence) {
case SEEK_SET:
/* ignore */
break;
case SEEK_CUR:
offset += io->off;
break;
case SEEK_END:
if (libewf_handle_get_media_size (
RIOEWF_HANDLE (fd), &media_size, NULL))
offset = media_size - offset;
break;
}
libewf_handle_seek_offset (RIOEWF_HANDLE (fd), offset, whence, NULL);
return offset;
}
return (ut64)-1;
}
static int ewf__plugin_open(RIO *io, const char *pathname, ut8 many) {
if ((!strncmp (pathname, "ewf://", 6))
|| (!strncmp (pathname, "els://", 6)))
return R_TRUE;
return R_FALSE;
}
static RIODesc *ewf__open(RIO *io, const char *pathname, int rw, int mode) {
RIOEwf *rewf;
libewf_handle_t *ewf_h;
// XXX filename list should be dynamic. 1024 limit is ugly
const char *filenames[1024];
char *ptr,*optr;
ut8 hash[1024];
size64_t media_size;
uint32_t bytes_per_sector;
//uint64_t amount_of_sectors;
uint32_t error_granularity;
//uint32_t amount_of_acquiry_errors;
int8_t compression_level;
uint8_t media_type;
uint8_t media_flags;
uint8_t compress_empty_block;
uint8_t format;
int i;
if (!strncmp (pathname, "els://", 6)) {
FILE *fd = r_sandbox_fopen (pathname+6, "r");
ut64 len;
char *buf;
if (fd == NULL)
return NULL;
fseek (fd, 0, SEEK_END);
len = ftell (fd);
fseek(fd, 0, SEEK_SET);
buf = (char *)malloc (len);
fread (buf, len, 1, fd);
ptr = strchr (buf, '\n');
for (i=0, optr = buf; ptr&&(ptr=strchr(ptr, '\n')); optr=ptr) {
*ptr = '\0';
ptr++;
filenames[i++] = optr;
}
filenames[i] = NULL;
free (buf);
fclose (fd);
for (i=0; filenames[i]; i++)
eprintf ("%02x: %s)\n", i, filenames[i]);
} else {
filenames[0] = pathname + 6;
filenames[1] = NULL;
}
libewf_handle_initialize (&ewf_h, NULL);
if (libewf_handle_open (ewf_h, (char * const *)filenames, (int)1, rw?
LIBEWF_OPEN_READ_WRITE: LIBEWF_OPEN_READ, NULL) != 1)
return NULL;
#if 0
if( ((libewf_internal_plugin_t*)ewf_h)->header_values == NULL ) {
fprintf( stream, "\tNo information found in file.\n" );
} else {
libewf_get_header_value_examiner_name(ewf_h, hash, 128);
eprintf("ExaminerName: %s\n", hash);
libewf_get_header_value_case_number(ewf_h, hash, 128);
eprintf("CaseNumber: %s\n", hash);
}
#endif
libewf_handle_get_format (ewf_h, &format, NULL);
eprintf ("FormatVersion: %d\n", format);
libewf_handle_get_compression_values (ewf_h,
&compression_level, &compress_empty_block, NULL);
eprintf ("CompressionLevel: %d\n", compression_level);
libewf_handle_get_error_granularity (ewf_h, &error_granularity, NULL);
eprintf ("ErrorGranurality: %d\n", error_granularity);
//libewf_handle_get_number_of_sectors (ewf_h, &amount_of_sectors, NULL);
//eprintf ("AmountOfSectors: %"PFMT64d"\n", amount_of_sectors);
libewf_handle_get_bytes_per_sector (ewf_h, &bytes_per_sector, NULL);
eprintf ("BytesPerSector: %d\n", bytes_per_sector);
libewf_handle_get_media_size (ewf_h, &media_size, NULL);
eprintf ("MediaSize: %"PFMT64d"\n", media_size);
libewf_handle_get_media_type (ewf_h, &media_type, NULL);
eprintf ("MediaType: %d\n", media_type);
libewf_handle_get_media_flags (ewf_h, &media_flags, NULL);
eprintf ("MediaFlags: %d\n", media_flags);
libewf_handle_get_md5_hash (ewf_h, hash, 128, NULL);
eprintf ("CalculatedHash: %s\n", hash);
rewf = R_NEW (RIOEwf);
rewf->handle = ewf_h;
rewf->fd = RIOEWF_TO_FD (rewf);
return r_io_desc_new (&r_io_plugin_shm, rewf->fd, pathname, rw, mode, rewf);
}
RIOPlugin r_io_plugin_ewf = {
//void *plugin;
.name = "ewf",
.desc = "Forensic file formats (Encase, ..) (ewf://file, els://file)",
.license = "LGPL3",
.open = ewf__open,
.close = ewf__close,
.read = ewf__read,
.plugin_open = ewf__plugin_open,
//.plugin_fd = ewf__plugin_fd,
.lseek = ewf__lseek,
.system = NULL, // ewf__system,
.write = ewf__write,
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_IO,
.data = &r_io_plugin_ewf
};
#endif
#else
struct r_io_plugin_t r_io_plugin_ewf = {
.name = NULL,
.desc = NULL
};
#endif

View file

@ -145,7 +145,6 @@ fs.fb
fs.sfs
io.debug
io.rap
io.ewf
io.gzip
io.http
io.bfdbg

View file

@ -8,7 +8,7 @@ CS_TAR=
CS_URL=https://github.com/aquynh/capstone.git
CS_UPD=20150101
CS_BRA=next
CS_TIP=dc101c25b31bc547136a5dce59d6405ac3cce0f6
CS_TIP=4de9de683d9f33c1f901b4d63c0f006b85473f2c
.PHONY: capstone-sync capstone-build all clean mrproper libgdbr libwind