Browse code

add mew and upack into dconf

git-svn: trunk@2652

Tomasz Kojm authored on 2007/01/31 04:18:36
Showing 8 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Jan 30 20:16:39 CET 2007 (tk)
2
+---------------------------------
3
+  * libclamav: add mew and upack into dconf
4
+
1 5
 Tue Jan 30 16:31:37 CET 2007 (tk)
2 6
 ---------------------------------
3 7
   * libclamav/unrar/unrar.c: properly handle metadata for large files
... ...
@@ -61,8 +61,12 @@ static struct dconf_module modules[] = {
61 61
 #ifdef CL_EXPERIMENTAL
62 62
     /* enable by default in experimental mode */
63 63
     { "PE",	    "NSPACK",	    PE_CONF_NSPACK,	    1 },
64
+    { "PE",	    "MEW",	    PE_CONF_MEW,	    1 },
65
+    { "PE",	    "UPACK",	    PE_CONF_UPACK,	    1 },
64 66
 #else
65 67
     { "PE",	    "NSPACK",	    PE_CONF_NSPACK,	    0 },
68
+    { "PE",	    "MEW",	    PE_CONF_MEW,	    0 },
69
+    { "PE",	    "UPACK",	    PE_CONF_UPACK,	    0 },
66 70
 #endif
67 71
 
68 72
     { "ELF",	    NULL,	    0x1,		    1 },
... ...
@@ -47,6 +47,8 @@ struct cli_dconf {
47 47
 #define PE_CONF_YC	    0x400
48 48
 #define PE_CONF_WWPACK	    0x800
49 49
 #define PE_CONF_NSPACK	    0x1000
50
+#define PE_CONF_MEW	    0x2000
51
+#define PE_CONF_UPACK	    0x4000
50 52
 
51 53
 /* Archive flags */
52 54
 #define ARCH_CONF_RAR	    0x1
... ...
@@ -30,7 +30,6 @@
30 30
 #include "clamav-config.h"
31 31
 #endif
32 32
 
33
-#ifdef CL_EXPERIMENTAL
34 33
 #include <stdio.h>
35 34
 #include <stdlib.h>
36 35
 #include <sys/types.h>
... ...
@@ -874,5 +873,3 @@ int unmew11(int sectnum, char *src, int off, int ssize, int dsize, uint32_t base
874 874
 
875 875
 	return 1;
876 876
 }
877
-
878
-#endif /* CL_EXPERIMENTAL */
... ...
@@ -24,20 +24,18 @@
24 24
 #include "clamav-config.h"
25 25
 #endif
26 26
 
27
-#ifdef CL_EXPERIMENTAL
27
+#include "cltypes.h"
28
+
28 29
 struct lzmastate {
29 30
 	char *p0;
30 31
 	uint32_t p1, p2;
31 32
 };
32 33
 
33
-//int mew_lzma(struct pe_image_section_hdr *, char *, char *, uint32_t, uint32_t, uint32_t);
34 34
 int mew_lzma(char *, char *, uint32_t, uint32_t, uint32_t);
35 35
 
36 36
 uint32_t lzma_upack_esi_00(struct lzmastate *, char *, char *, uint32_t);
37 37
 uint32_t lzma_upack_esi_50(struct lzmastate *, uint32_t, uint32_t, char **, char *, uint32_t *, char *, uint32_t);
38 38
 uint32_t lzma_upack_esi_54(struct lzmastate *, uint32_t, uint32_t *, char **, uint32_t *, char *, uint32_t);
39
-//int unmew11(struct pe_image_section_hdr *, int, char *, int, int, int, uint32_t, uint32_t, int, char **, char **, int);
40 39
 int unmew11(int, char *, int, int, int, uint32_t, uint32_t, int, char **, char **, int);
41
-#endif
42 40
 
43 41
 #endif
... ...
@@ -49,10 +49,8 @@
49 49
 #include "str.h"
50 50
 #include "execs.h"
51 51
 #include "md5.h"
52
-#ifdef CL_EXPERIMENTAL
53 52
 #include "mew.h"
54 53
 #include "upack.h"
55
-#endif
56 54
 
57 55
 #ifndef	O_BINARY
58 56
 #define	O_BINARY	0
... ...
@@ -484,7 +482,9 @@ int cli_scanpe(int desc, cli_ctx *ctx)
484 484
 	    lseek(desc, (EC16(file_hdr.SizeOfOptionalHeader)-sizeof(struct pe_image_optional_hdr32)), SEEK_CUR);
485 485
 	}
486 486
 
487
-	upack = (EC16(file_hdr.SizeOfOptionalHeader)==0x148);
487
+	if(DCONF & PE_CONF_UPACK)
488
+	    upack = (EC16(file_hdr.SizeOfOptionalHeader)==0x148);
489
+
488 490
 	vep = EC32(optional_hdr32.AddressOfEntryPoint);
489 491
 	cli_dbgmsg("File format: PE\n");
490 492
 
... ...
@@ -1080,7 +1080,7 @@ int cli_scanpe(int desc, cli_ctx *ctx)
1080 1080
 
1081 1081
     /* try to find the first section with physical size == 0 */
1082 1082
     found = 0;
1083
-    if(DCONF & (PE_CONF_UPX | PE_CONF_FSG)) {
1083
+    if(DCONF & (PE_CONF_UPX | PE_CONF_FSG | PE_CONF_MEW)) {
1084 1084
 	for(i = 0; i < (unsigned int) nsections - 1; i++) {
1085 1085
 	    if(!section_hdr[i].SizeOfRawData && section_hdr[i].VirtualSize && section_hdr[i + 1].SizeOfRawData && section_hdr[i + 1].VirtualSize) {
1086 1086
 		found = 1;
... ...
@@ -1090,10 +1090,8 @@ int cli_scanpe(int desc, cli_ctx *ctx)
1090 1090
 	}
1091 1091
     }
1092 1092
 
1093
-
1094 1093
     /* MEW support */
1095
-#ifdef CL_EXPERIMENTAL
1096
-    if (found) {
1094
+    if (found && (DCONF & PE_CONF_MEW)) {
1097 1095
 	uint32_t fileoffset;
1098 1096
 	/* Check EP for MEW */
1099 1097
 	if(lseek(desc, ep, SEEK_SET) == -1) {
... ...
@@ -1253,11 +1251,7 @@ int cli_scanpe(int desc, cli_ctx *ctx)
1253 1253
 	} while (0);
1254 1254
     }
1255 1255
 
1256
-
1257 1256
     if(found || upack) {
1258
-#else
1259
-    if(found) {
1260
-#endif
1261 1257
 	/* Check EP for UPX vs. FSG vs. Upack */
1262 1258
 	if(lseek(desc, ep, SEEK_SET) == -1) {
1263 1259
 	    cli_dbgmsg("UPX/FSG: lseek() failed\n");
... ...
@@ -1274,7 +1268,6 @@ int cli_scanpe(int desc, cli_ctx *ctx)
1274 1274
 	    return CL_CLEAN;
1275 1275
 	}
1276 1276
 
1277
-#ifdef CL_EXPERIMENTAL
1278 1277
 	/* Upack 0.39 produces 2 types of executables
1279 1278
 	 * 3 sections:           | 2 sections (one empty, I don't chech found if !upack, since it's in OR above):
1280 1279
 	 *   mov esi, value      |   pusha
... ...
@@ -1424,7 +1417,6 @@ int cli_scanpe(int desc, cli_ctx *ctx)
1424 1424
 		}
1425 1425
 	}
1426 1426
 skip_upack_and_go_to_next_unpacker:
1427
-#endif
1428 1427
 
1429 1428
 	if((DCONF & PE_CONF_FSG) && buff[0] == '\x87' && buff[1] == '\x25') {
1430 1429
 
... ...
@@ -27,7 +27,6 @@
27 27
 #include "clamav-config.h"
28 28
 #endif
29 29
 
30
-#ifdef CL_EXPERIMENTAL
31 30
 #include <stdio.h>
32 31
 #include <stdlib.h>
33 32
 #include <sys/types.h>
... ...
@@ -39,6 +38,7 @@
39 39
 #include "pe.h"
40 40
 #include "rebuildpe.h"
41 41
 #include "others.h"
42
+#include "upack.h"
42 43
 #include "mew.h"
43 44
 
44 45
 #define EC32(x) le32_to_host(x) /* Convert little endian to host */
... ...
@@ -672,5 +672,3 @@ int unupack399(char *bs, uint32_t bl, uint32_t init_eax, char *init_ebx, uint32_
672 672
 
673 673
 	return 1;
674 674
 }
675
-
676
-#endif
... ...
@@ -24,8 +24,8 @@
24 24
 #include "clamav-config.h"
25 25
 #endif
26 26
 
27
-#ifdef CL_EXPERIMENTAL
27
+#include "cltypes.h"
28
+
28 29
 int unupack(int, char *, uint32_t, char *, uint32_t, uint32_t, uint32_t, uint32_t, int);
29 30
 
30 31
 #endif
31
-#endif