Skip to content

Commit

Permalink
Update libyara & rizin dev support (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio authored Apr 12, 2024
1 parent 660a446 commit 06c7b9b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/yara_generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ static inline void add_metadata_file_hash(YaraCbData *cd, const char *key) {
algo = YARA_KEYWORD_HASH_SHA256;
}

RzList *hashes = rz_bin_file_compute_hashes(cd->core->bin, bf, limit);
RzPVector *hashes = rz_bin_file_compute_hashes(cd->core->bin, bf, limit);
RzBinFileHash *h = NULL;
RzListIter *it = NULL;
rz_list_foreach (hashes, it, h) {
void **it = NULL;
rz_pvector_foreach (hashes, it) {
h = (RzBinFileHash *)*it;
if (yara_stricmp(algo, h->type)) {
continue;
}
Expand All @@ -74,7 +75,7 @@ static inline void add_metadata_file_hash(YaraCbData *cd, const char *key) {
}
break;
}
rz_list_free(hashes);
rz_pvector_free(hashes);
}

static inline void add_metadata_timestamp(YaraCbData *cd, const char *key) {
Expand Down
38 changes: 34 additions & 4 deletions subprojects/packagefiles/yara/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ yara_deps = [
]

yara_c_args = [
'-DMACHO_MODULE=1',
'-DDEX_MODULE=1',
'-DDOTNET_MODULE=1',
'-DDEX_MODULE=1',
# required flags
'-DBUCKETS_128=1',
'-DCHECKSUM_1B=1',
# enabled
'-DMACHO_MODULE=1',
'-DDEX_MODULE=1',
'-DDOTNET_MODULE=1',
'-DDEX_MODULE=1',
]

yara_src = [
Expand All @@ -33,15 +37,25 @@ yara_src = [
'libyara/libyara.c',
'libyara/mem.c',
'libyara/modules.c',
'libyara/modules/console/console.c',
#'libyara/modules/cuckoo/cuckoo.c',
#'libyara/modules/demo/demo.c',
'libyara/modules/dex/dex.c',
'libyara/modules/dotnet/dotnet.c',
'libyara/modules/elf/elf.c',
'libyara/modules/macho/macho.c',
#'libyara/modules/magic/magic.c',
'libyara/modules/math/math.c',
#'libyara/modules/pb_tests/pb_tests.c',
#'libyara/modules/pb_tests/pb_tests.pb-c.c',
'libyara/modules/pe/authenticode-parser/authenticode.c',
'libyara/modules/pe/authenticode-parser/certificate.c',
'libyara/modules/pe/authenticode-parser/countersignature.c',
'libyara/modules/pe/authenticode-parser/helper.c',
'libyara/modules/pe/authenticode-parser/structs.c',
'libyara/modules/pe/pe.c',
'libyara/modules/pe/pe_utils.c',
'libyara/modules/string/string.c',
'libyara/modules/tests/tests.c',
'libyara/modules/time/time.c',
'libyara/notebook.c',
Expand All @@ -54,12 +68,16 @@ yara_src = [
'libyara/rules.c',
'libyara/scan.c',
'libyara/scanner.c',
'libyara/simple_str.c',
'libyara/sizedstr.c',
'libyara/stack.c',
'libyara/stopwatch.c',
'libyara/stream.c',
'libyara/strutils.c',
'libyara/threading.c',
'libyara/tlshc/tlsh.c',
'libyara/tlshc/tlsh_impl.c',
'libyara/tlshc/tlsh_util.c',
]

if host_machine.system() == 'openbsd'
Expand Down Expand Up @@ -108,6 +126,18 @@ if cc.has_argument('-fPIC')
add_project_arguments('-fPIC', language: ['c'])
endif

if cc.has_argument('-Wno-unused-function')
add_project_arguments('-Wno-unused-function', language: ['c'])
endif

if cc.has_argument('-Wno-unused-variable')
add_project_arguments('-Wno-unused-variable', language: ['c'])
endif

if cc.has_argument('-Wno-nonnull-compare')
add_project_arguments('-Wno-nonnull-compare', language: ['c'])
endif

yara_lib = static_library('yara', yara_src,
c_args : yara_c_args,
dependencies: yara_deps,
Expand Down
3 changes: 2 additions & 1 deletion subprojects/yara.wrap
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[wrap-git]
url = https://github.com/VirusTotal/yara
revision = b99a808cf9955090b909c72d6a0da5295c3cbc7c
revision = 5317a2b3499f1e3a583377dcc1b8be84725034ac
patch_directory = yara
depth = 1

0 comments on commit 06c7b9b

Please sign in to comment.