diff options
Diffstat (limited to 'vcpkg/ports/yara')
| -rw-r--r-- | vcpkg/ports/yara/CMakeLists.txt | 183 | ||||
| -rw-r--r-- | vcpkg/ports/yara/Disable-module-elf.patch | 13 | ||||
| -rw-r--r-- | vcpkg/ports/yara/portfile.cmake | 35 | ||||
| -rw-r--r-- | vcpkg/ports/yara/vcpkg.json | 30 |
4 files changed, 261 insertions, 0 deletions
diff --git a/vcpkg/ports/yara/CMakeLists.txt b/vcpkg/ports/yara/CMakeLists.txt new file mode 100644 index 0000000..3f3ed1e --- /dev/null +++ b/vcpkg/ports/yara/CMakeLists.txt @@ -0,0 +1,183 @@ +cmake_minimum_required(VERSION 3.8) +project(yara C) + +if(MSVC) + add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS) +else() + find_library(HAVE_LIBM NAMES m) +endif() + + +find_package(OpenSSL REQUIRED) + +include_directories( + . + libyara + libyara/include +) + +set(PROC_PLATFORM_SOURCE "libyara/proc/none.c") +set(PROC_PLATFORM_INTERFACE "USE_NO_PROC") + +if(APPLE AND CMAKE_SYSTEM_NAME MATCHES "Darwin") + set(PROC_PLATFORM_SOURCE "libyara/proc/mach.c") + set(PROC_PLATFORM_INTERFACE "USE_MACH_PROC") +elseif(WIN32 OR MINGW OR CYGWIN) + set(PROC_PLATFORM_SOURCE "libyara/proc/windows.c") + set(PROC_PLATFORM_INTERFACE "USE_WINDOWS_PROC") +elseif(UNIX AND CMAKE_SYSTEM_NAME MATCHES "Linux") + set(THREADS_PREFER_PTHREAD_FLAG TRUE) + set(PROC_PLATFORM_SOURCE "libyara/proc/linux.c") + set(PROC_PLATFORM_INTERFACE "USE_LINUX_PROC") +endif() + +set( + libyara_sources + libyara/ahocorasick.c + libyara/arena.c + libyara/atoms.c + libyara/base64.c + libyara/bitmask.c + libyara/compiler.c + libyara/endian.c + libyara/exec.c + libyara/exefiles.c + libyara/filemap.c + libyara/grammar.c + libyara/hash.c + libyara/hex_grammar.c + libyara/hex_lexer.c + libyara/lexer.c + libyara/libyara.c + libyara/mem.c + libyara/modules.c + libyara/modules/console/console.c + libyara/modules/hash/hash.c + libyara/modules/math/math.c + libyara/modules/macho/macho.c + libyara/modules/pe/pe.c + libyara/modules/pe/pe_utils.c + libyara/modules/pe/authenticode-parser/authenticode.c + libyara/modules/pe/authenticode-parser/certificate.c + libyara/modules/pe/authenticode-parser/helper.c + libyara/modules/pe/authenticode-parser/countersignature.c + libyara/modules/pe/authenticode-parser/structs.c + libyara/modules/tests/tests.c + libyara/modules/time/time.c + libyara/modules/string/string.c + libyara/notebook.c + libyara/object.c + libyara/parser.c + libyara/proc.c + ${PROC_PLATFORM_SOURCE} + libyara/re.c + libyara/re_grammar.c + libyara/re_lexer.c + libyara/rules.c + libyara/scan.c + libyara/scanner.c + libyara/sizedstr.c + libyara/stack.c + libyara/stopwatch.c + libyara/stream.c + libyara/strutils.c + libyara/threading.c + + # Module elf request new library tlshc(https://github.com/avast/tlshc), the related upstream PR: https://github.com/VirusTotal/yara/pull/1624. + # libyara/modules/elf/elf.c + # libyara/tlshc/tlsh.c + # libyara/tlshc/tlsh_impl.c + # libyara/tlshc/tlsh_util.c +) + +set( + yara_sources + cli/args.c + cli/common.c + cli/threading.c + cli/yara.c +) +set( yarac_sources + cli/args.c + cli/common.c + cli/yarac.c +) + +find_package(Threads REQUIRED) + +set( + libyara_dependencies + OpenSSL::SSL + OpenSSL::Crypto + Threads::Threads +) + +if(CMAKE_SYSTEM_NAME MATCHES "Windows") +list(APPEND libyara_dependencies Crypt32.lib Ws2_32.lib) +endif() +if(HAVE_LIBM) + list(APPEND libyara_dependencies m) +endif() + +set( + libyara_definitions + -DHAVE_LIBCRYPTO + -D${PROC_PLATFORM_INTERFACE} + -DHASH_MODULE +) + +if(CUCKOO_MODULE) + list(APPEND libyara_definitions -DCUCKOO_MODULE) + list(APPEND libyara_sources libyara/modules/cuckoo/cuckoo.c) + find_package(jansson CONFIG REQUIRED) + list(APPEND libyara_dependencies jansson::jansson) +endif() + +if(DOTNET_MODULE) + list(APPEND libyara_definitions -DDOTNET_MODULE) + list(APPEND libyara_sources libyara/modules/dotnet/dotnet.c libyara/simple_str.c) +endif() + +add_library(libyara ${libyara_sources}) +target_link_libraries(libyara PRIVATE ${libyara_dependencies}) +target_compile_definitions(libyara PRIVATE ${libyara_definitions}) +target_include_directories(libyara INTERFACE $<INSTALL_INTERFACE:include>) + +add_executable(yara ${yara_sources}) +add_executable(yarac ${yarac_sources}) + +target_link_libraries(yarac PRIVATE libyara ${libyara_dependencies}) +target_link_libraries(yara PRIVATE libyara ${libyara_dependencies}) + +install( + TARGETS libyara EXPORT unofficial-libyaraTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) + +install(EXPORT unofficial-libyaraTargets + NAMESPACE unofficial::libyara:: + DESTINATION share/unofficial-libyara +) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-libyara-config.cmake.in" +[[include(CMakeFindDependencyMacro) +find_dependency(OpenSSL) +find_dependency(Threads) +if(@CUCKOO_MODULE@) + find_dependency(jansson CONFIG) +endif() +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-libyaraTargets.cmake") +]]) +configure_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-libyara-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-libyara-config.cmake" @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-libyara-config.cmake DESTINATION share/unofficial-libyara) + +if(NOT DISABLE_INSTALL_TOOLS) + install ( + TARGETS yarac yara + RUNTIME DESTINATION tools/yara + ) +endif() + +if(NOT DISABLE_INSTALL_HEADERS) + install(DIRECTORY libyara/include/ DESTINATION include) +endif() diff --git a/vcpkg/ports/yara/Disable-module-elf.patch b/vcpkg/ports/yara/Disable-module-elf.patch new file mode 100644 index 0000000..8cdc98a --- /dev/null +++ b/vcpkg/ports/yara/Disable-module-elf.patch @@ -0,0 +1,13 @@ +diff --git a/libyara/modules/module_list b/libyara/modules/module_list +index 35e848a..e11433e 100644 +--- a/libyara/modules/module_list ++++ b/libyara/modules/module_list +@@ -1,6 +1,8 @@ + MODULE(tests) + MODULE(pe) ++#ifdef DELF_MODULE + MODULE(elf) ++#endif + MODULE(math) + MODULE(time) + MODULE(console) diff --git a/vcpkg/ports/yara/portfile.cmake b/vcpkg/ports/yara/portfile.cmake new file mode 100644 index 0000000..f3933a6 --- /dev/null +++ b/vcpkg/ports/yara/portfile.cmake @@ -0,0 +1,35 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO VirusTotal/yara + REF "v${VERSION}" + SHA512 b1da40636f9e55bb07cc911479e6dfa8dc7a4fa3f6b9f10b9f669d741d7af51a1d31e044f9842ec3ab9c6ac9788fbdb89a1686c9e3f22f68d1f9e5fb3db22167 + HEAD_REF master + PATCHES + # Module elf request new library tlshc(https://github.com/avast/tlshc), the related upstream PR: https://github.com/VirusTotal/yara/pull/1624. + Disable-module-elf.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + cuckoo CUCKOO_MODULE + dotnet DOTNET_MODULE +) + +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + OPTIONS_DEBUG + -DDISABLE_INSTALL_HEADERS=ON + -DDISABLE_INSTALL_TOOLS=ON +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-libyara) + +# Handle copyright +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/vcpkg/ports/yara/vcpkg.json b/vcpkg/ports/yara/vcpkg.json new file mode 100644 index 0000000..3b59cac --- /dev/null +++ b/vcpkg/ports/yara/vcpkg.json @@ -0,0 +1,30 @@ +{ + "name": "yara", + "version": "4.5.4", + "description": "The pattern matching swiss knife", + "homepage": "https://github.com/VirusTotal/yara", + "license": "BSD-3-Clause", + "supports": "!uwp", + "dependencies": [ + "openssl", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "cuckoo": { + "description": "The Cuckoo module enables you to create YARA rules based on behavioral information generated by Cuckoo sandbox.", + "dependencies": [ + "jansson" + ] + }, + "dotnet": { + "description": "The dotnet module allows you to create more fine-grained rules for .NET files by using attributes and features of the .NET file format." + } + } +} |