... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
# |
2 | 2 |
# Copyright (C) 2002 - 2007 Tomasz Kojm <tkojm@clamav.net> |
3 |
+# Copyright (C) 2008 - 2013 Sourcefire, Inc. |
|
3 | 4 |
# |
4 | 5 |
# This program is free software; you can redistribute it and/or modify |
5 | 6 |
# it under the terms of the GNU General Public License as published by |
... | ... |
@@ -370,6 +371,10 @@ libclamav_la_SOURCES = \ |
370 | 370 |
builtin_bytecodes.h\ |
371 | 371 |
events.c\ |
372 | 372 |
events.h \ |
373 |
+ dmg.c \ |
|
374 |
+ dmg.h \ |
|
375 |
+ xar.c \ |
|
376 |
+ xar.h \ |
|
373 | 377 |
swf.c \ |
374 | 378 |
swf.h \ |
375 | 379 |
jpeg.c \ |
... | ... |
@@ -17,6 +17,7 @@ |
17 | 17 |
|
18 | 18 |
# |
19 | 19 |
# Copyright (C) 2002 - 2007 Tomasz Kojm <tkojm@clamav.net> |
20 |
+# Copyright (C) 2008 - 2013 Sourcefire, Inc. |
|
20 | 21 |
# |
21 | 22 |
# This program is free software; you can redistribute it and/or modify |
22 | 23 |
# it under the terms of the GNU General Public License as published by |
... | ... |
@@ -184,7 +185,8 @@ am_libclamav_la_OBJECTS = libclamav_la-matcher-ac.lo \ |
184 | 184 |
libclamav_la-ishield.lo libclamav_la-bytecode_api.lo \ |
185 | 185 |
libclamav_la-bytecode_api_decl.lo libclamav_la-cache.lo \ |
186 | 186 |
libclamav_la-bytecode_detect.lo libclamav_la-events.lo \ |
187 |
- libclamav_la-swf.lo libclamav_la-jpeg.lo libclamav_la-png.lo \ |
|
187 |
+ libclamav_la-dmg.lo libclamav_la-xar.lo libclamav_la-swf.lo \ |
|
188 |
+ libclamav_la-jpeg.lo libclamav_la-png.lo \ |
|
188 | 189 |
libclamav_la-iso9660.lo libclamav_la-arc4.lo \ |
189 | 190 |
libclamav_la-rijndael.lo libclamav_la-crtmgr.lo \ |
190 | 191 |
libclamav_la-asn1.lo libclamav_la-fp_add.lo \ |
... | ... |
@@ -706,12 +708,12 @@ libclamav_la_SOURCES = clamav.h matcher-ac.c matcher-ac.h matcher-bm.c \ |
706 | 706 |
bcfeatures.h bytecode_api.c bytecode_api_decl.c bytecode_api.h \ |
707 | 707 |
bytecode_api_impl.h bytecode_hooks.h cache.c cache.h \ |
708 | 708 |
bytecode_detect.c bytecode_detect.h builtin_bytecodes.h \ |
709 |
- events.c events.h swf.c swf.h jpeg.c jpeg.h png.c png.h \ |
|
710 |
- iso9660.c iso9660.h arc4.c arc4.h rijndael.c rijndael.h \ |
|
711 |
- crtmgr.c crtmgr.h asn1.c asn1.h bignum.h bignum_fast.h \ |
|
712 |
- tomsfastmath/addsub/fp_add.c tomsfastmath/addsub/fp_add_d.c \ |
|
713 |
- tomsfastmath/addsub/fp_addmod.c tomsfastmath/addsub/fp_cmp.c \ |
|
714 |
- tomsfastmath/addsub/fp_cmp_d.c \ |
|
709 |
+ events.c events.h dmg.c dmg.h xar.c xar.h swf.c swf.h jpeg.c \ |
|
710 |
+ jpeg.h png.c png.h iso9660.c iso9660.h arc4.c arc4.h \ |
|
711 |
+ rijndael.c rijndael.h crtmgr.c crtmgr.h asn1.c asn1.h bignum.h \ |
|
712 |
+ bignum_fast.h tomsfastmath/addsub/fp_add.c \ |
|
713 |
+ tomsfastmath/addsub/fp_add_d.c tomsfastmath/addsub/fp_addmod.c \ |
|
714 |
+ tomsfastmath/addsub/fp_cmp.c tomsfastmath/addsub/fp_cmp_d.c \ |
|
715 | 715 |
tomsfastmath/addsub/fp_cmp_mag.c tomsfastmath/addsub/fp_sub.c \ |
716 | 716 |
tomsfastmath/addsub/fp_sub_d.c tomsfastmath/addsub/fp_submod.c \ |
717 | 717 |
tomsfastmath/addsub/s_fp_add.c tomsfastmath/addsub/s_fp_sub.c \ |
... | ... |
@@ -931,6 +933,7 @@ distclean-compile: |
931 | 931 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-dconf.Plo@am__quote@ |
932 | 932 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-disasm.Plo@am__quote@ |
933 | 933 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-dlp.Plo@am__quote@ |
934 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-dmg.Plo@am__quote@ |
|
934 | 935 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-dsig.Plo@am__quote@ |
935 | 936 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-elf.Plo@am__quote@ |
936 | 937 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-entconv.Plo@am__quote@ |
... | ... |
@@ -1085,6 +1088,7 @@ distclean-compile: |
1085 | 1085 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-vba_extract.Plo@am__quote@ |
1086 | 1086 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-version.Plo@am__quote@ |
1087 | 1087 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-wwunpack.Plo@am__quote@ |
1088 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-xar.Plo@am__quote@ |
|
1088 | 1089 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-yc.Plo@am__quote@ |
1089 | 1090 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unrar.Plo@am__quote@ |
1090 | 1091 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unrar15.Plo@am__quote@ |
... | ... |
@@ -1838,6 +1842,20 @@ libclamav_la-events.lo: events.c |
1838 | 1838 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
1839 | 1839 |
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-events.lo `test -f 'events.c' || echo '$(srcdir)/'`events.c |
1840 | 1840 |
|
1841 |
+libclamav_la-dmg.lo: dmg.c |
|
1842 |
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-dmg.lo -MD -MP -MF $(DEPDIR)/libclamav_la-dmg.Tpo -c -o libclamav_la-dmg.lo `test -f 'dmg.c' || echo '$(srcdir)/'`dmg.c |
|
1843 |
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-dmg.Tpo $(DEPDIR)/libclamav_la-dmg.Plo |
|
1844 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dmg.c' object='libclamav_la-dmg.lo' libtool=yes @AMDEPBACKSLASH@ |
|
1845 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
1846 |
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-dmg.lo `test -f 'dmg.c' || echo '$(srcdir)/'`dmg.c |
|
1847 |
+ |
|
1848 |
+libclamav_la-xar.lo: xar.c |
|
1849 |
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-xar.lo -MD -MP -MF $(DEPDIR)/libclamav_la-xar.Tpo -c -o libclamav_la-xar.lo `test -f 'xar.c' || echo '$(srcdir)/'`xar.c |
|
1850 |
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-xar.Tpo $(DEPDIR)/libclamav_la-xar.Plo |
|
1851 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xar.c' object='libclamav_la-xar.lo' libtool=yes @AMDEPBACKSLASH@ |
|
1852 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
1853 |
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-xar.lo `test -f 'xar.c' || echo '$(srcdir)/'`xar.c |
|
1854 |
+ |
|
1841 | 1855 |
libclamav_la-swf.lo: swf.c |
1842 | 1856 |
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-swf.lo -MD -MP -MF $(DEPDIR)/libclamav_la-swf.Tpo -c -o libclamav_la-swf.lo `test -f 'swf.c' || echo '$(srcdir)/'`swf.c |
1843 | 1857 |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-swf.Tpo $(DEPDIR)/libclamav_la-swf.Plo |
... | ... |
@@ -96,6 +96,8 @@ static struct dconf_module modules[] = { |
96 | 96 |
{ "ARCHIVE", "ISHIELD", ARCH_CONF_ISHIELD, 1 }, |
97 | 97 |
{ "ARCHIVE", "7zip", ARCH_CONF_7Z, 1 }, |
98 | 98 |
{ "ARCHIVE", "ISO9660", ARCH_CONF_ISO9660, 1 }, |
99 |
+ { "ARCHIVE", "DMG", ARCH_CONF_DMG, 1 }, |
|
100 |
+ { "ARCHIVE", "XAR", ARCH_CONF_XAR, 1 }, |
|
99 | 101 |
|
100 | 102 |
{ "DOCUMENT", "HTML", DOC_CONF_HTML, 1 }, |
101 | 103 |
{ "DOCUMENT", "RTF", DOC_CONF_RTF, 1 }, |
88 | 90 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,76 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2013 Sourcefire, Inc. |
|
2 |
+ * |
|
3 |
+ * Authors: David Raynor <draynor@sourcefire.com> |
|
4 |
+ * |
|
5 |
+ * This program is free software; you can redistribute it and/or modify |
|
6 |
+ * it under the terms of the GNU General Public License version 2 as |
|
7 |
+ * published by the Free Software Foundation. |
|
8 |
+ * |
|
9 |
+ * This program is distributed in the hope that it will be useful, |
|
10 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
+ * GNU General Public License for more details. |
|
13 |
+ * |
|
14 |
+ * You should have received a copy of the GNU General Public License |
|
15 |
+ * along with this program; if not, write to the Free Software |
|
16 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
+ * MA 02110-1301, USA. |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#if HAVE_CONFIG_H |
|
21 |
+#include "clamav-config.h" |
|
22 |
+#endif |
|
23 |
+ |
|
24 |
+#include <stdio.h> |
|
25 |
+#include <ctype.h> |
|
26 |
+ |
|
27 |
+#include "cltypes.h" |
|
28 |
+#include "others.h" |
|
29 |
+#include "dmg.h" |
|
30 |
+#include "scanners.h" |
|
31 |
+ |
|
32 |
+int cli_scandmg(cli_ctx *ctx) |
|
33 |
+{ |
|
34 |
+ struct dmg_koly_block hdr; |
|
35 |
+ int ret, conv; |
|
36 |
+ size_t maplen; |
|
37 |
+ |
|
38 |
+ char name[513]; |
|
39 |
+ unsigned int file = 0, trailer = 0; |
|
40 |
+ uint32_t filesize, namesize, hdr_namesize; |
|
41 |
+ off_t pos = 0; |
|
42 |
+ |
|
43 |
+ if (!ctx || !ctx->fmap) { |
|
44 |
+ cli_errmsg("cli_scandmg: Invalid context\n"); |
|
45 |
+ return CL_ENULLARG; |
|
46 |
+ } |
|
47 |
+ |
|
48 |
+ maplen = (*ctx->fmap)->real_len; |
|
49 |
+ pos = maplen - 512; |
|
50 |
+ if (pos <= 0) { |
|
51 |
+ cli_dbgmsg("cli_scandmg: Sizing problem for DMG archive.\n"); |
|
52 |
+ return CL_CLEAN; |
|
53 |
+ } |
|
54 |
+ |
|
55 |
+ /* Grab koly block */ |
|
56 |
+ if (fmap_readn(*ctx->fmap, &hdr, pos, sizeof(hdr)) != sizeof(hdr)) { |
|
57 |
+ cli_dbgmsg("cli_scandmg: Invalid DMG trailer block\n"); |
|
58 |
+ return CL_EFORMAT; |
|
59 |
+ } |
|
60 |
+ |
|
61 |
+ /* Check magic */ |
|
62 |
+ hdr.magic = be32_to_host(hdr.magic); |
|
63 |
+ if (hdr.magic == 0x6b6f6c79) { |
|
64 |
+ cli_dbgmsg("cli_scandmg: Found koly block @ %ld\n", (long) pos); |
|
65 |
+ } |
|
66 |
+ else { |
|
67 |
+ cli_dbgmsg("cli_scandmg: No koly magic, %8x\n", hdr.magic); |
|
68 |
+ return CL_EFORMAT; |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ /* TODO: the rest of the unpacking */ |
|
72 |
+ |
|
73 |
+ return CL_CLEAN; |
|
74 |
+} |
|
75 |
+ |
0 | 76 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,100 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2013 Sourcefire, Inc. |
|
2 |
+ * |
|
3 |
+ * Authors: David Raynor <draynor@sourcefire.com> |
|
4 |
+ * |
|
5 |
+ * This program is free software; you can redistribute it and/or modify |
|
6 |
+ * it under the terms of the GNU General Public License version 2 as |
|
7 |
+ * published by the Free Software Foundation. |
|
8 |
+ * |
|
9 |
+ * This program is distributed in the hope that it will be useful, |
|
10 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
+ * GNU General Public License for more details. |
|
13 |
+ * |
|
14 |
+ * You should have received a copy of the GNU General Public License |
|
15 |
+ * along with this program; if not, write to the Free Software |
|
16 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
+ * MA 02110-1301, USA. |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#ifndef __DMG_H |
|
21 |
+#define __DMG_H |
|
22 |
+ |
|
23 |
+#if HAVE_CONFIG_H |
|
24 |
+#include "clamav-config.h" |
|
25 |
+#endif |
|
26 |
+ |
|
27 |
+#include "cltypes.h" |
|
28 |
+#include "others.h" |
|
29 |
+ |
|
30 |
+#ifndef HAVE_ATTRIB_PACKED |
|
31 |
+#define __attribute__(x) |
|
32 |
+#endif |
|
33 |
+ |
|
34 |
+#ifdef HAVE_PRAGMA_PACK |
|
35 |
+#pragma pack(1) |
|
36 |
+#endif |
|
37 |
+ |
|
38 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
39 |
+#pragma pack 1 |
|
40 |
+#endif |
|
41 |
+ |
|
42 |
+/* 512-byte block, remember these are big-endian! */ |
|
43 |
+struct dmg_koly_block { |
|
44 |
+ uint32_t magic __attribute__ ((packed)); |
|
45 |
+ uint32_t version __attribute__ ((packed)); |
|
46 |
+ uint32_t headerLength __attribute__ ((packed)); |
|
47 |
+ uint32_t flags __attribute__ ((packed)); |
|
48 |
+ uint64_t runningOffset __attribute__ ((packed)); |
|
49 |
+ uint64_t dataForkOffset __attribute__ ((packed)); |
|
50 |
+ uint64_t dataForkLength __attribute__ ((packed)); |
|
51 |
+ uint64_t resourceForkOffset __attribute__ ((packed)); |
|
52 |
+ uint64_t resourceForkLength __attribute__ ((packed)); |
|
53 |
+ uint32_t segment __attribute__ ((packed)); |
|
54 |
+ uint32_t segmentCount __attribute__ ((packed)); |
|
55 |
+ /* technically uuid */ |
|
56 |
+ uint8_t segmentID[16]; |
|
57 |
+ |
|
58 |
+ uint32_t dataChecksumFields[34] __attribute__ ((packed)); |
|
59 |
+ |
|
60 |
+ uint64_t xmlOffset __attribute__ ((packed)); |
|
61 |
+ uint64_t xmlLength __attribute__ ((packed)); |
|
62 |
+ uint8_t padding[120]; |
|
63 |
+ |
|
64 |
+ uint32_t masterChecksumFields[34] __attribute__ ((packed)); |
|
65 |
+ |
|
66 |
+ uint32_t imageVariant __attribute__ ((packed)); |
|
67 |
+ uint64_t sectorCount __attribute__ ((packed)); |
|
68 |
+ |
|
69 |
+ uint32_t reserved[3] __attribute__ ((packed)); |
|
70 |
+}; |
|
71 |
+ |
|
72 |
+/* 204-byte block, still big-endian */ |
|
73 |
+struct dmg_mish_block { |
|
74 |
+ uint32_t magic; |
|
75 |
+ uint32_t version; |
|
76 |
+ |
|
77 |
+ uint64_t startSector; |
|
78 |
+ uint64_t sectorCount; |
|
79 |
+ uint64_t dataOffset; |
|
80 |
+ uint32_t bufferCount; |
|
81 |
+ uint32_t descriptorBlocks; |
|
82 |
+ |
|
83 |
+ uint8_t reserved[24]; |
|
84 |
+ |
|
85 |
+ uint32_t checksum[34]; |
|
86 |
+ uint64_t blockDescriptorCount; |
|
87 |
+}; |
|
88 |
+ |
|
89 |
+#ifdef HAVE_PRAGMA_PACK |
|
90 |
+#pragma pack() |
|
91 |
+#endif |
|
92 |
+ |
|
93 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
94 |
+#pragma pack |
|
95 |
+#endif |
|
96 |
+ |
|
97 |
+int cli_scandmg(cli_ctx *ctx); |
|
98 |
+ |
|
99 |
+#endif |
... | ... |
@@ -101,6 +101,8 @@ static const struct ftmap_s { |
101 | 101 |
{ "CL_TYPE_SWF", CL_TYPE_SWF }, |
102 | 102 |
{ "CL_TYPE_ISO9660", CL_TYPE_ISO9660 }, |
103 | 103 |
{ "CL_TYPE_JAVA", CL_TYPE_JAVA }, |
104 |
+ { "CL_TYPE_DMG", CL_TYPE_DMG }, |
|
105 |
+ { "CL_TYPE_XAR", CL_TYPE_XAR }, |
|
104 | 106 |
{ NULL, CL_TYPE_IGNORED } |
105 | 107 |
}; |
106 | 108 |
|
... | ... |
@@ -74,6 +74,7 @@ typedef enum { |
74 | 74 |
CL_TYPE_7Z, |
75 | 75 |
CL_TYPE_SWF, |
76 | 76 |
CL_TYPE_JAVA, |
77 |
+ CL_TYPE_XAR, |
|
77 | 78 |
|
78 | 79 |
/* bigger numbers have higher priority (in o-t-f detection) */ |
79 | 80 |
CL_TYPE_HTML, /* on the fly */ |
... | ... |
@@ -88,6 +89,7 @@ typedef enum { |
88 | 88 |
CL_TYPE_AUTOIT, |
89 | 89 |
CL_TYPE_ISHIELD_MSI, |
90 | 90 |
CL_TYPE_ISO9660, |
91 |
+ CL_TYPE_DMG, |
|
91 | 92 |
CL_TYPE_IGNORED /* please don't add anything below */ |
92 | 93 |
} cli_file_t; |
93 | 94 |
|
... | ... |
@@ -172,6 +172,8 @@ static const char *ftypes_int[] = { |
172 | 172 |
"1:0:cafebabe0000001?:Universal Binary:CL_TYPE_ANY:CL_TYPE_MACHO_UNIBIN:73", |
173 | 173 |
"1:0:cafebabe0000002?:Java class file:CL_TYPE_ANY:CL_TYPE_JAVA:73", |
174 | 174 |
"1:0:cafebabe0000003?:Java class file:CL_TYPE_ANY:CL_TYPE_JAVA:73", |
175 |
+ "1:EOF-512:6b6f6c79:DMG container file:CL_TYPE_ANY:CL_TYPE_DMG:73", |
|
176 |
+ "0:0:78617221:XAR container file:CL_TYPE_ANY:CL_TYPE_XAR:73", |
|
175 | 177 |
NULL |
176 | 178 |
}; |
177 | 179 |
|
... | ... |
@@ -94,6 +94,8 @@ |
94 | 94 |
#include "jpeg.h" |
95 | 95 |
#include "png.h" |
96 | 96 |
#include "iso9660.h" |
97 |
+#include "dmg.h" |
|
98 |
+#include "xar.h" |
|
97 | 99 |
|
98 | 100 |
#ifdef HAVE_BZLIB_H |
99 | 101 |
#include <bzlib.h> |
... | ... |
@@ -595,7 +597,6 @@ static int cli_scangzip(cli_ctx *ctx) |
595 | 595 |
return ret; |
596 | 596 |
} |
597 | 597 |
|
598 |
- |
|
599 | 598 |
#ifndef HAVE_BZLIB_H |
600 | 599 |
static int cli_scanbzip(cli_ctx *ctx) { |
601 | 600 |
cli_warnmsg("cli_scanbzip: bzip2 support not compiled in\n"); |
... | ... |
@@ -2114,6 +2115,14 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_ |
2114 | 2114 |
} |
2115 | 2115 |
break; |
2116 | 2116 |
|
2117 |
+ case CL_TYPE_DMG: |
|
2118 |
+ if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_DMG)) { |
|
2119 |
+ ctx->container_type = CL_TYPE_DMG; |
|
2120 |
+ nret = cli_scandmg(ctx); |
|
2121 |
+ cli_dbgmsg("DMG signature found at %u\n", (unsigned int) fpt->offset); |
|
2122 |
+ } |
|
2123 |
+ break; |
|
2124 |
+ |
|
2117 | 2125 |
case CL_TYPE_PDF: |
2118 | 2126 |
if(type != CL_TYPE_PDF && SCAN_PDF && (DCONF_DOC & DOC_CONF_PDF)) { |
2119 | 2127 |
ctx->container_type = CL_TYPE_PDF; |
... | ... |
@@ -2650,6 +2659,12 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type) |
2650 | 2650 |
ret = cli_scan_structured(ctx); |
2651 | 2651 |
break; |
2652 | 2652 |
|
2653 |
+ case CL_TYPE_XAR: |
|
2654 |
+ ctx->container_type = CL_TYPE_XAR; |
|
2655 |
+ if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_XAR)) |
|
2656 |
+ ret = cli_scanxar(ctx); |
|
2657 |
+ break; |
|
2658 |
+ |
|
2653 | 2659 |
default: |
2654 | 2660 |
break; |
2655 | 2661 |
} |
2656 | 2662 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,57 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2013 Sourcefire, Inc. |
|
2 |
+ * |
|
3 |
+ * Authors: David Raynor <draynor@sourcefire.com> |
|
4 |
+ * |
|
5 |
+ * This program is free software; you can redistribute it and/or modify |
|
6 |
+ * it under the terms of the GNU General Public License version 2 as |
|
7 |
+ * published by the Free Software Foundation. |
|
8 |
+ * |
|
9 |
+ * This program is distributed in the hope that it will be useful, |
|
10 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
+ * GNU General Public License for more details. |
|
13 |
+ * |
|
14 |
+ * You should have received a copy of the GNU General Public License |
|
15 |
+ * along with this program; if not, write to the Free Software |
|
16 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
+ * MA 02110-1301, USA. |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#if HAVE_CONFIG_H |
|
21 |
+#include "clamav-config.h" |
|
22 |
+#endif |
|
23 |
+ |
|
24 |
+#include "cltypes.h" |
|
25 |
+#include "others.h" |
|
26 |
+#include "xar.h" |
|
27 |
+#include "fmap.h" |
|
28 |
+#include "scanners.h" |
|
29 |
+ |
|
30 |
+int cli_scanxar(cli_ctx *ctx) |
|
31 |
+{ |
|
32 |
+ struct xar_header hdr; |
|
33 |
+ char name[513]; |
|
34 |
+ unsigned int file = 0, trailer = 0; |
|
35 |
+ uint32_t filesize, namesize, hdr_namesize; |
|
36 |
+ int ret, conv; |
|
37 |
+ off_t pos = 0; |
|
38 |
+ |
|
39 |
+ if (fmap_readn(*ctx->fmap, &hdr, pos, sizeof(hdr)) != sizeof(hdr)) { |
|
40 |
+ cli_dbgmsg("cli_scanxar: Invalid header, too short.\n"); |
|
41 |
+ return CL_EFORMAT; |
|
42 |
+ } |
|
43 |
+ hdr.magic = be32_to_host(hdr.magic); |
|
44 |
+ if (hdr.magic == 0x78617221) { |
|
45 |
+ cli_dbgmsg("cli_scanxar: Matched magic\n"); |
|
46 |
+ } |
|
47 |
+ else { |
|
48 |
+ cli_dbgmsg("cli_scanxar: Invalid magic\n"); |
|
49 |
+ return CL_EFORMAT; |
|
50 |
+ } |
|
51 |
+ |
|
52 |
+ /* TODO: First grab the TOC, parse that, and then unpack the rest. */ |
|
53 |
+ |
|
54 |
+ return CL_CLEAN; |
|
55 |
+} |
|
56 |
+ |
0 | 57 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,62 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2013 Sourcefire, Inc. |
|
2 |
+ * |
|
3 |
+ * Authors: David Raynor <draynor@sourcefire.com> |
|
4 |
+ * |
|
5 |
+ * This program is free software; you can redistribute it and/or modify |
|
6 |
+ * it under the terms of the GNU General Public License version 2 as |
|
7 |
+ * published by the Free Software Foundation. |
|
8 |
+ * |
|
9 |
+ * This program is distributed in the hope that it will be useful, |
|
10 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
+ * GNU General Public License for more details. |
|
13 |
+ * |
|
14 |
+ * You should have received a copy of the GNU General Public License |
|
15 |
+ * along with this program; if not, write to the Free Software |
|
16 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
+ * MA 02110-1301, USA. |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#ifndef __XAR_H |
|
21 |
+#define __XAR_H |
|
22 |
+ |
|
23 |
+#if HAVE_CONFIG_H |
|
24 |
+#include "clamav-config.h" |
|
25 |
+#endif |
|
26 |
+ |
|
27 |
+#include "cltypes.h" |
|
28 |
+#include "others.h" |
|
29 |
+ |
|
30 |
+#ifndef HAVE_ATTRIB_PACKED |
|
31 |
+#define __attribute__(x) |
|
32 |
+#endif |
|
33 |
+ |
|
34 |
+#ifdef HAVE_PRAGMA_PACK |
|
35 |
+#pragma pack(1) |
|
36 |
+#endif |
|
37 |
+ |
|
38 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
39 |
+#pragma pack 1 |
|
40 |
+#endif |
|
41 |
+ |
|
42 |
+struct xar_header { |
|
43 |
+ uint32_t magic; |
|
44 |
+ uint16_t size; |
|
45 |
+ uint16_t version; |
|
46 |
+ uint64_t toc_length_compressed; |
|
47 |
+ uint64_t toc_length_decompressed; |
|
48 |
+ uint32_t chksum_alg; /* 0 = none */ |
|
49 |
+}; |
|
50 |
+ |
|
51 |
+#ifdef HAVE_PRAGMA_PACK |
|
52 |
+#pragma pack() |
|
53 |
+#endif |
|
54 |
+ |
|
55 |
+#ifdef HAVE_PRAGMA_PACK_HPPA |
|
56 |
+#pragma pack |
|
57 |
+#endif |
|
58 |
+ |
|
59 |
+int cli_scanxar(cli_ctx *ctx); |
|
60 |
+ |
|
61 |
+#endif |
... | ... |
@@ -298,6 +298,7 @@ |
298 | 298 |
<ClCompile Include="..\libclamav\dconf.c"/> |
299 | 299 |
<ClCompile Include="..\libclamav\disasm.c"/> |
300 | 300 |
<ClCompile Include="..\libclamav\dlp.c"/> |
301 |
+ <ClCompile Include="..\libclamav\dmg.c"/> |
|
301 | 302 |
<ClCompile Include="..\libclamav\dsig.c"/> |
302 | 303 |
<ClCompile Include="..\libclamav\elf.c"/> |
303 | 304 |
<ClCompile Include="..\libclamav\entconv.c"/> |
... | ... |
@@ -372,6 +373,7 @@ |
372 | 372 |
<ClCompile Include="..\libclamav\vba_extract.c"/> |
373 | 373 |
<ClCompile Include="..\libclamav\version.c"/> |
374 | 374 |
<ClCompile Include="..\libclamav\wwunpack.c"/> |
375 |
+ <ClCompile Include="..\libclamav\xar.c"/> |
|
375 | 376 |
<ClCompile Include="..\libclamav\yc.c"/> |
376 | 377 |
<ClCompile Include="..\shared\getopt.c"/> |
377 | 378 |
<ClCompile Include="..\shared\misc.c"/> |
... | ... |
@@ -102,6 +102,9 @@ |
102 | 102 |
<ClCompile Include="..\libclamav\dlp.c"> |
103 | 103 |
<Filter>Source Files</Filter> |
104 | 104 |
</ClCompile> |
105 |
+ <ClCompile Include="..\libclamav\dmg.c"> |
|
106 |
+ <Filter>Source Files</Filter> |
|
107 |
+ </ClCompile> |
|
105 | 108 |
<ClCompile Include="..\libclamav\dsig.c"> |
106 | 109 |
<Filter>Source Files</Filter> |
107 | 110 |
</ClCompile> |
... | ... |
@@ -282,6 +285,9 @@ |
282 | 282 |
<ClCompile Include="..\libclamav\wwunpack.c"> |
283 | 283 |
<Filter>Source Files</Filter> |
284 | 284 |
</ClCompile> |
285 |
+ <ClCompile Include="..\libclamav\xar.c"> |
|
286 |
+ <Filter>Source Files</Filter> |
|
287 |
+ </ClCompile> |
|
285 | 288 |
<ClCompile Include="..\libclamav\sha256.c"> |
286 | 289 |
<Filter>Source Files</Filter> |
287 | 290 |
</ClCompile> |