[Forensics-changes] [yara] 149/407: Detect presence of OpenSSL library and build accordingly

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:28:19 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.3.0
in repository yara.

commit aaee659fb064ab7911901ff7c16cb0b10d26a5c3
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Tue Oct 28 13:10:00 2014 +0100

    Detect presence of OpenSSL library and build accordingly
---
 configure.ac         | 57 ++++++++++++++++++++++++++++++++++++----------------
 libyara/Makefile.am  |  1 +
 libyara/modules/pe.c | 17 +++++++++++++++-
 3 files changed, 57 insertions(+), 18 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2d6cff7..a4307f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,36 +20,59 @@ LT_INIT
 AC_PROG_LIBTOOL
 
 AC_ARG_ENABLE([dmalloc],
-  [AS_HELP_STRING([--enable-dmalloc], [enable dmalloc to debug heap-related issues])],
+  [AS_HELP_STRING([--enable-dmalloc],
+    [enable dmalloc to debug heap-related issues])],
   [if test x$enableval = xyes; then
-    AC_CHECK_LIB(dmalloc, dmalloc_malloc,, AC_MSG_ERROR(please install dmalloc library))
+    AC_CHECK_LIB(dmalloc, dmalloc_malloc,,
+      AC_MSG_ERROR([please install dmalloc library]))
     AC_DEFINE([DMALLOC], [1], [enable dmalloc])
   fi])
 
 AC_ARG_ENABLE([cuckoo],
   [AS_HELP_STRING([--enable-cuckoo], [enable cuckoo module])],
   [if test x$enableval = xyes; then
-    cuckoo=true
-    AC_CHECK_LIB(jansson, json_loadb,, AC_MSG_ERROR(please install Jansson library))
+    build_cuckoo_module=true
+    AC_CHECK_LIB(jansson, json_loadb,,
+      AC_MSG_ERROR([please install Jansson library]))
     AC_DEFINE([CUCKOO], [1], [enable cuckoo module])
   fi])
 
 AC_ARG_ENABLE([magic],
   [AS_HELP_STRING([--enable-magic], [enable magic module])],
   [if test x$enableval = xyes; then
-    magic=true
-    AC_CHECK_LIB(magic, magic_open,, AC_MSG_ERROR(please install libmagic library))
+    build_magic_module=true
+    AC_CHECK_LIB(magic, magic_open,,
+      AC_MSG_ERROR([please install libmagic library]))
     AC_DEFINE([MAGIC], [1], [enable magic module])
   fi])
 
-AC_ARG_ENABLE([hash],
-  [AS_HELP_STRING([--enable-hash], [enable hash module for files and memory blocks])],
-  [if test x$enableval = xyes; then
-    hash=true
-    AC_CHECK_HEADERS([openssl/md5.h])
-    AC_CHECK_LIB(crypto, MD5_Update,, AC_MSG_ERROR(please install openssl libcrypto library))
-    AC_DEFINE([HASH], [1], [enable hash module])
-  fi])
+AC_ARG_WITH([crypto],
+  AS_HELP_STRING([--without-crypto],
+    [ignore presence of OpenSSL and disable it]))
+
+  AS_IF([test "x$with_crypto" != "xno"],
+    [
+      AC_CHECK_LIB(crypto, MD5_Init,, [have_crypto=no])
+      AC_CHECK_LIB(crypto, MD5_Update,, [have_crypto=no])
+      AC_CHECK_LIB(crypto, MD5_Final,, [have_crypto=no])
+      AC_CHECK_LIB(crypto, SHA256_Init,, [have_crypto=no])
+      AC_CHECK_LIB(crypto, SHA256_Update,, [have_crypto=no])
+      AC_CHECK_LIB(crypto, SHA256_Final,, [have_crypto=no])
+    ],
+    [
+      have_crypto=no
+    ])
+
+  AS_IF([test "x$have_crypto" = "xno"],
+    [
+      AS_IF([test "x$with_crypto" = "xyes"],
+        [
+          AC_MSG_ERROR([OpenSSL requested but not found])
+        ])
+    ],
+    [
+      build_hash_module=true
+    ])
 
 ACX_PTHREAD(
     [LIBS="$PTHREAD_LIBS $LIBS"
@@ -59,9 +82,9 @@ ACX_PTHREAD(
 
 AC_CHECK_FUNCS_ONCE(strlcpy strlcat)
 
-AM_CONDITIONAL([CUCKOO], [test x$cuckoo = xtrue])
-AM_CONDITIONAL([MAGIC], [test x$magic = xtrue])
-AM_CONDITIONAL([HASH], [test x$hash = xtrue])
+AM_CONDITIONAL([CUCKOO], [test x$build_cuckoo_module = xtrue])
+AM_CONDITIONAL([MAGIC], [test x$build_magic_module = xtrue])
+AM_CONDITIONAL([HASH], [test x$build_hash_module = xtrue])
 
 AC_CONFIG_FILES([Makefile])
 AC_CONFIG_FILES([libyara/Makefile])
diff --git a/libyara/Makefile.am b/libyara/Makefile.am
index a9c00f6..db7299e 100644
--- a/libyara/Makefile.am
+++ b/libyara/Makefile.am
@@ -14,6 +14,7 @@ endif
 if HASH
 MODULES += modules/hash.c
 endif
+
 #
 # Add your modules here:
 #
diff --git a/libyara/modules/pe.c b/libyara/modules/pe.c
index 2f6c208..3d7cccc 100644
--- a/libyara/modules/pe.c
+++ b/libyara/modules/pe.c
@@ -18,8 +18,13 @@ limitations under the License.
 
 #include <stdio.h>
 #include <ctype.h>
+
+#include <config.h>
+
+#if defined(HAVE_LIBCRYPTO)
 #include <openssl/md5.h>
 #include <openssl/sha.h>
+#endif
 
 #include <yara/pe.h>
 #include <yara/modules.h>
@@ -2543,6 +2548,8 @@ define_function(exports)
 }
 
 
+#if defined(HAVE_LIBCRYPTO)
+
 //
 // Generate an import hash:
 // https://www.mandiant.com/blog/tracking-malware-import-hashing/
@@ -2676,6 +2683,8 @@ define_function(richhash)
   return_string(digest_ascii);
 }
 
+#endif  // defined(HAVE_LIBCRYPTO)
+
 
 define_function(imports)
 {
@@ -2868,20 +2877,26 @@ begin_declarations;
     declare_integer("raw_data_size");
   end_struct_array("sections");
 
+
   begin_struct("rich_signature");
     declare_integer("start");
     declare_integer("key");
     declare_string("raw_data");
     declare_string("clear_data");
+    #if defined(HAVE_LIBCRYPTO)
     declare_function("hash", "", "s", richhash);
+    #endif
   end_struct("rich_signature");
 
+  #if defined(HAVE_LIBCRYPTO)
+  declare_function("imphash", "", "s", imphash);
+  #endif
+
   declare_function("section_index", "s", "i", section_index);
   declare_function("exports", "s", "i", exports);
   declare_function("imports", "ss", "i", imports);
   declare_function("locale", "i", "i", locale);
   declare_function("language", "i", "i", language);
-  declare_function("imphash", "", "s", imphash);
 
 end_declarations;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list