Skip to content

Commit 06cdd46

Browse files
committed
Add vba macro support for oxml files to sigtool
1 parent 66fd30c commit 06cdd46

7 files changed

Lines changed: 439 additions & 3 deletions

File tree

common/optparser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const struct clam_option __clam_options[] = {
118118
{NULL, "verbose", 'v', CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_CLAMONACC, "", ""},
119119
{NULL, "dumpcerts", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "Dump authenticode certificate chain.", ""},
120120
{NULL, "quiet", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_CLAMONACC, "", ""},
121-
{NULL, "leave-temps", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", ""},
121+
{NULL, "leave-temps", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_SIGTOOL, "", ""},
122122
{NULL, "no-warnings", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "", ""},
123123
{NULL, "show-progress", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "", ""},
124124
{NULL, "stdout", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_CLAMONACC, "", ""},

libclamav/clamav.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,28 @@ typedef int (*clcb_file_props)(const char *j_propstr, int rc, void *cbdata);
814814
*/
815815
extern void cl_engine_set_clcb_file_props(struct cl_engine *engine, clcb_file_props callback);
816816

817+
/**
818+
* @brief VBA macro callback function.
819+
*
820+
* Invoked after vba is extracted from the module, but before it is normalized.
821+
* This is only invoked if libclamav was built with json support.
822+
*
823+
* @param vba The vba macro information.
824+
* @param vba_len The length of vba.
825+
* @param cbdata Opaque application provided data.
826+
*/
827+
typedef int (*clcb_vba)(const unsigned char *const vba, const size_t vba_len, void *cbdata);
828+
829+
/**
830+
* @brief Set a custom VBA macro callback function.
831+
*
832+
* Caution: changing options for an engine that is in-use is not thread-safe!
833+
*
834+
* @param engine The initialized scanning engine.
835+
* @param callback The callback function pointer.
836+
*/
837+
extern void cl_engine_set_clcb_vba(struct cl_engine *engine, clcb_vba callback);
838+
817839
/* ----------------------------------------------------------------------------
818840
* Statistics/telemetry gathering callbacks.
819841
*

libclamav/libclamav.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CLAMAV_PUBLIC {
1414
cl_engine_set_clcb_hash;
1515
cl_engine_set_clcb_meta;
1616
cl_engine_set_clcb_file_props;
17+
cl_engine_set_vba_callback;
1718
cl_set_clcb_msg;
1819
cl_engine_set_clcb_file_inspection;
1920
cl_engine_set_clcb_pre_scan;

libclamav/others.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,11 @@ void cl_engine_set_clcb_file_props(struct cl_engine *engine, clcb_file_props cal
19271927
engine->cb_file_props = callback;
19281928
}
19291929

1930+
void cl_engine_set_clcb_vba(struct cl_engine *engine, clcb_vba callback)
1931+
{
1932+
engine->cb_vba = callback;
1933+
}
1934+
19301935
uint8_t cli_get_debug_flag()
19311936
{
19321937
return cli_debug_flag;

libclamav/others.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ struct cl_engine {
416416
void *cb_sigload_ctx;
417417
clcb_hash cb_hash;
418418
clcb_meta cb_meta;
419+
clcb_vba cb_vba;
419420
clcb_file_props cb_file_props;
420421
clcb_progress cb_sigload_progress;
421422
void *cb_sigload_progress_ctx;

libclamav/vba_extract.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,10 @@ cl_error_t cli_vba_readdir_new(cli_ctx *ctx, const char *dir, struct uniq *U, co
12551255

12561256
close(module_fd);
12571257

1258+
if (NULL != ctx->engine->cb_vba) {
1259+
ctx->engine->cb_vba(module_data, module_data_size, ctx->cb_ctx);
1260+
}
1261+
12581262
if (CL_SUCCESS == cli_codepage_to_utf8((char *)module_data, module_data_size, codepage, (char **)&module_data_utf8, &module_data_utf8_size)) {
12591263
module_data_utf8_size = vba_normalize(module_data_utf8, module_data_utf8_size);
12601264

0 commit comments

Comments
 (0)