Commit graph

45 commits

Author SHA1 Message Date
Micah Snyder
005cbf5a37 Record names of extracted files
A way is needed to record scanned file names for two purposes:

1. File names (and extensions) must be stored in the json metadata
properties recorded when using the --gen-json clamscan option. Future
work may use this to compare file extensions with detected file types.

2. File names are useful when interpretting tmp directory output when
using the --leave-temps option.

This commit enables file name retention for later use by storing file
names in the fmap header structure, if a file name exists.

To store the names in fmaps, an optional name argument has been added to
any internal scan API's that create fmaps and every call to these APIs
has been modified to pass a file name or NULL if a file name is not
required.  The zip and gpt parsers required some modification to record
file names.  The NSIS and XAR parsers fail to collect file names at all
and will require future work to support file name extraction.

Also:

- Added recursive extraction to the tmp directory when the
  --leave-temps option is enabled.  When not enabled, the tmp directory
  structure remains flat so as to prevent the likelihood of exceeding
  MAX_PATH.  The current tmp directory is stored in the scan context.

- Made the cli_scanfile() internal API non-static and added it to
  scanners.h so it would be accessible outside of scanners.c in order to
  remove code duplication within libmspack.c.

- Added function comments to scanners.h and matcher.h

- Converted a TDB-type macros and LSIG-type macros to enums for improved
  type safey.

- Converted more return status variables from `int` to `cl_error_t` for
  improved type safety, and corrected ooxml file typing functions so
  they use `cli_file_t` exclusively rather than mixing types with
  `cl_error_t`.

- Restructured the magic_scandesc() function to use goto's for error
  handling and removed the early_ret_from_magicscan() macro and
  magic_scandesc_cleanup() function.  This makes the code easier to
  read and made it easier to add the recursive tmp directory cleanup to
  magic_scandesc().

- Corrected zip, egg, rar filename extraction issues.

- Removed use of extra sub-directory layer for zip, egg, and rar file
  extraction.  For Zip, this also involved changing the extracted
  filenames to be randomly generated rather than using the "zip.###"
  file name scheme.
2020-06-03 10:39:18 -04:00
Jonas Zaddach (jzaddach)
d5a733ef90 XLM (Excel 4.0) macro detection and extraction
XLM is a macro language in Excel that was used before VBA (before
1996). It is still parsed and executed by modern Excel and is gaining
popularity with malware authors.

This patch adds rudimentary support for detecting and extracting
Excel 4.0 (XLM) macros.

The code is based on Didier Steven's plugin_biff for oletools.py.
2020-04-29 14:19:41 -07:00
Micah Snyder
28d0940ff3 Correction to vba ctx cleanup logic to prevent possible null dereference. 2019-10-02 16:08:25 -04:00
Micah Snyder
97a0647e88 Additional variable type changes for correctness and to silence warnings. A handful of other minor changes to silence warnings. Corrected a number of function definitions so they return cl_error_t rather than int. 2019-10-02 16:08:25 -04:00
Micah Snyder (micasnyd)
0f128f20b8 bb12250 & bb12277: Fixes for sigtools vba scanner. Scanner engine, scan options, and context creation routines were incomplete. 2019-10-02 16:08:20 -04:00
Micah Snyder
50f178dc63 fuzz - 12166 - Fix for 4-byte out of bounds write wherein the an invalid struct pointer member variable is set to zero. The fix adds bounds checking to the Uniq storage 'add' function as well as error code checks. Included a lot of new inline documentation. 2019-10-02 16:08:19 -04:00
Micah Snyder
b3e82e5e61 Replacing libclamav/cltypes.h with clamav-types.h.in, which generates a header clamav-types.h that we install alongside clamav.h. 2019-10-02 16:08:17 -04:00
Micah Snyder
72fd33c8b2 clang-format'd using new .clang-format rules. 2019-10-02 16:08:16 -04:00
Kevin Lin
2283657ce4 bb#11364 - convenience_ctx containing uninitialized memory 2015-07-28 14:11:13 -04:00
Shawn Webb
859b6fb843 Fix a few more compiler warnings 2014-07-11 09:42:42 -04:00
Shawn Webb
60d8d2c352 Move all the crypto API to clamav.h 2014-07-01 19:38:01 -04:00
Shawn Webb
0735b6856d Include vba.h in vba.c 2014-06-02 13:51:48 -04:00
Shawn Webb
e0f667e7f1 bb11023 - Wrong declaration of function destroy_ctx to cause undefined behavior 2014-06-02 08:54:43 -04:00
Shawn Webb
b2e7c931d0 Use OpenSSL for hashing. 2014-02-08 00:31:12 -05:00
David Raynor
9f33ce782e sigtool: Use closedir() to close directory pointer 2013-02-14 12:07:03 -05:00
David Raynor
981b77c1ff Fix const-related warnings on convenience_ctx() 2013-02-14 11:20:50 -05:00
cwu
81fa389041 fix CID# 11393 2013-02-14 07:11:26 -08:00
cwu
a252900c46 fix CID# 10539 2013-02-13 13:12:48 -08:00
cwu
8028d34f59 fix CID# 10541 2013-02-13 12:46:28 -08:00
cwu
0fdaab06f8 fix CID# 10542 2013-02-13 12:03:21 -08:00
Shawn webb
a2a004df25 BB#3737 - Value too large for specified data type
Create compile-time preprocessor defines for switching from calling
stat() to stat64(). Add --enable-stat64 switch in configure script.
2012-07-16 15:36:49 -04:00
Török Edvin
b4d884d920 provide fmap_fd() accessor to fd.
Accessing fd directly is deprecated, and most unpackers can unpack directly the
map, with the rest being fixed shortly.
Only the pre/post callbacks need the fd (they will get -1 if we not scanning a
fd), and the zlib_from_the_80s.
2011-06-14 18:48:50 +03:00
aCaB
8f5bb092f8 win32: add sigtool 2010-03-16 04:17:10 +01:00
aCaB
9be6a33415 fix distcheck 2010-02-10 19:38:04 +01:00
aCaB
3e527c3487 one & too much 2010-02-10 19:19:54 +01:00
aCaB
3ef137af1b fix fmap stuff in sigtool 2010-02-10 17:53:27 +01:00
Tomasz Kojm
799a761fe6 another error path leak 2009-10-27 21:05:13 +01:00
Tomasz Kojm
9b3e1e8580 clamdscan, libclamav, clamdtop, freshclam, sigtool: fix some error path leaks (bb#1730) 2009-10-27 21:02:00 +01:00
aCaB
63979bf21e Merge remote branch 'origin/fmap4all' 2009-10-09 22:07:33 +02:00
aCaB
49cc1e3c35 s/struct F_MAP/fmap_t/ 2009-10-02 18:09:31 +02:00
aCaB
b705e8d712 merge win32 patches from sherpya 2009-09-25 15:29:09 +02:00
aCaB
58481352d5 win32 paths handling 2009-09-24 19:07:39 +02:00
aCaB
081f64735d win32#2 2009-09-24 16:24:07 +02:00
aCaB
be4bf7f4ab win32 2009-09-24 16:08:52 +02:00
aCaB
034c02fd9e ole2 to fmap 2009-08-31 07:07:32 +02:00
Tomasz Kojm
33068e0973 libclamav: drop cl_settempdir(); use cl_engine_set() with CL_ENGINE_TMPDIR and CL_ENGINE_KEEPTMP instead
git-svn: trunk@4416
2008-11-14 22:23:39 +00:00
Tomasz Kojm
6dbc66020e sigtool/vba.c: fix possible use of uninitialized value (bb#1201)
git-svn: trunk@4210
2008-09-29 13:07:35 +00:00
Török Edvin
7959343dc7 allow make distcheck to succeed (bb #1142)
fix some more warnings
  filter -Werror in clamav-milter.c

git-svn: trunk@4141
2008-08-25 14:18:48 +00:00
aCaB
53ed2cb75c uniq update
git-svn: trunk@4069
2008-08-03 21:39:29 +00:00
Tomasz Kojm
f8a82180da sigtool/vba.c: fix crash on error in vba code (bb#1106)
git-svn: trunk@3977
2008-07-21 10:37:19 +00:00
Tomasz Kojm
b0c7e984a8 libclamav/ole2_extract.c, sigtool: make sigtool compatible with the new OLE2 scan scheme (bb#1086)
git-svn: trunk@3915
2008-07-07 14:10:15 +00:00
Tomasz Kojm
72ce4b70eb improve handling of PDF, CAB, RTF, OLE2 and HTML files (sync with branch/0.93)
git-svn: trunk@3862
2008-05-27 16:30:47 +00:00
Nigel Horne
11d24f8a8f Code cleanup
git-svn: trunk@3432
2007-12-18 14:32:47 +00:00
Tomasz Kojm
797c5b1e04 fix gcc -W* warnings
git-svn: trunk@2911
2007-03-05 22:01:14 +00:00
Sven Strickroth
a99111f050 remove old CVS-stuff and make the repository look more like SVN
git-svn: trunk@2755
2007-02-17 19:02:20 +00:00
Renamed from clamav-devel/sigtool/vba.c (Browse further)