Browse code

add ScanELF and --no-elf

git-svn: trunk@2449

Tomasz Kojm authored on 2006/10/29 07:01:51
Showing 12 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sun Oct 29 00:00:10 CEST 2006 (tk)
2
+----------------------------------
3
+  * clamd: new directive ScanELF
4
+  * clamscan: new command line option --no-elf
5
+
1 6
 Sat Oct 28 22:44:46 CEST 2006 (tk)
2 7
 ----------------------------------
3 8
   * libclamav/elf.c: parse program headers and properly calculate file offset
... ...
@@ -372,14 +372,22 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in
372 372
     if(cfgopt(copt, "ScanPE")->enabled) {
373 373
 	logg("Portable Executable support enabled.\n");
374 374
 	options |= CL_SCAN_PE;
375
+    } else {
376
+	logg("Portable Executable support disabled.\n");
377
+    }
375 378
 
379
+    if(cfgopt(copt, "ScanELF")->enabled) {
380
+	logg("ELF support enabled.\n");
381
+	options |= CL_SCAN_ELF;
382
+    } else {
383
+	logg("ELF support disabled.\n");
384
+    }
385
+
386
+    if(cfgopt(copt, "ScanPE")->enabled || cfgopt(copt, "ScanELF")->enabled) {
376 387
 	if(cfgopt(copt, "DetectBrokenExecutables")->enabled) {
377 388
 	    logg("Detection of broken executables enabled.\n");
378 389
 	    options |= CL_SCAN_BLOCKBROKEN;
379 390
 	}
380
-
381
-    } else {
382
-	logg("Portable Executable support disabled.\n");
383 391
     }
384 392
 
385 393
     if(cfgopt(copt, "ScanMail")->enabled) {
... ...
@@ -258,6 +258,7 @@ void help(void)
258 258
 #endif
259 259
     mprintf("    --no-algorithmic                     Disable algorithmic detection\n");
260 260
     mprintf("    --no-pe                              Disable PE analysis\n");
261
+    mprintf("    --no-elf                             Disable ELF support\n");
261 262
     mprintf("    --no-ole2                            Disable OLE2 support\n");
262 263
     mprintf("    --no-html                            Disable HTML support\n");
263 264
     mprintf("    --no-archive                         Disable libclamav archive support\n");
... ...
@@ -70,6 +70,7 @@ static struct option clamscan_longopt[] = {
70 70
     {"block-encrypted", 0, 0, 0},
71 71
     {"block-max", 0, 0, 0},
72 72
     {"no-pe", 0, 0, 0},
73
+    {"no-elf", 0, 0, 0},
73 74
     {"no-ole2", 0, 0, 0},
74 75
     {"no-html", 0, 0, 0},
75 76
     {"mbox", 0, 0, 'm'},	    /* not used */
... ...
@@ -186,6 +186,11 @@ int scanmanager(const struct optstruct *opt)
186 186
     else
187 187
 	options |= CL_SCAN_PE;
188 188
 
189
+    if(opt_check(opt, "no-elf"))
190
+	options &= ~CL_SCAN_ELF;
191
+    else
192
+	options |= CL_SCAN_ELF;
193
+
189 194
     if(opt_check(opt, "no-ole2"))
190 195
 	options &= ~CL_SCAN_OLE2;
191 196
     else
... ...
@@ -199,8 +199,13 @@ PE stands for Portable Executable \- it's an executable file format used in all
199 199
 .br 
200 200
 Default: enabled
201 201
 .TP 
202
+\fBScanELF\fR
203
+Executable and Linking Format is a standard format for UN*X executables. This option allows you to control the scanning of ELF files.
204
+.br 
205
+Default: enabled
206
+.TP 
202 207
 \fBDetectBrokenExecutables\fR
203
-With this option clamd will try to detect broken executables and mark them as Broken.Executable.
208
+With this option clamd will try to detect broken executables (both PE and ELF) and mark them as Broken.Executable.
204 209
 .br 
205 210
 Default: disabled
206 211
 .TP 
... ...
@@ -85,6 +85,9 @@ In some cases (eg. complex malware, exploits in graphic files, and others), Clam
85 85
 \fB\-\-no\-pe\fR
86 86
 PE stands for Portable Executable \- it's an executable file format used in all 32\-bit versions of Windows operating systems. By default ClamAV performs deeper analysis of executable files and attempts to decompress popular executable packers such as UPX, Petite, and FSG. This option \fBdisables\fR PE support and should be used with care!
87 87
 .TP 
88
+\fB\-\-no\-elf\fR
89
+Executable and Linking Format is a standard format for UN*X executables. This option \fBdisables\fR ELF support.
90
+.TP 
88 91
 \fB\-\-no\-ole2\fR
89 92
 Disable support for Microsoft Office document files.
90 93
 .TP 
... ...
@@ -180,8 +180,13 @@ LocalSocket /tmp/clamd
180 180
 # Default: yes
181 181
 #ScanPE yes
182 182
 
183
-# With this option clamav will try to detect broken executables and mark
184
-# them as Broken.Executable
183
+# Executable and Linking Format is a standard format for UN*X executables.
184
+# This option allows you to control the scanning of ELF files.
185
+# Default: yes
186
+#ScanELF yes
187
+
188
+# With this option clamav will try to detect broken executables (both PE and
189
+# ELF) and mark them as Broken.Executable.
185 190
 # Default: no
186 191
 #DetectBrokenExecutables yes
187 192
 
... ...
@@ -90,7 +90,8 @@ extern "C"
90 90
 #define CL_SCAN_BLOCKMAX	256
91 91
 #define CL_SCAN_ALGO		512
92 92
 #define CL_SCAN_NOPHISHING      1024
93
-#define CL_PHISH_NO_DOMAINLIST    4096
93
+#define CL_PHISH_NO_DOMAINLIST  4096
94
+#define CL_SCAN_ELF		8192
94 95
 
95 96
 /* recommended options */
96 97
 #define CL_SCAN_STDOPT		(CL_SCAN_ARCHIVE | CL_SCAN_MAIL | CL_SCAN_OLE2 | CL_SCAN_HTML | CL_SCAN_PE | CL_SCAN_ALGO) 
... ...
@@ -62,6 +62,7 @@ typedef struct {
62 62
 #define SCAN_OLE2	    (ctx->options & CL_SCAN_OLE2)
63 63
 #define SCAN_HTML	    (ctx->options & CL_SCAN_HTML)
64 64
 #define SCAN_PE		    (ctx->options & CL_SCAN_PE)
65
+#define SCAN_ELF	    (ctx->options & CL_SCAN_ELF)
65 66
 #define SCAN_ALGO 	    (ctx->options & CL_SCAN_ALGO)
66 67
 #define DETECT_ENCRYPTED    (ctx->options & CL_SCAN_BLOCKENCRYPTED)
67 68
 #define BLOCKMAX	    (ctx->options & CL_SCAN_BLOCKMAX)
... ...
@@ -1838,7 +1838,8 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
1838 1838
 	    ret = cli_scancryptff(desc, ctx);
1839 1839
 	    break;
1840 1840
 
1841
-	case CL_TYPE_ELF: /* TODO: Add ScanELF option */
1841
+	case CL_TYPE_ELF:
1842
+	    if(SCAN_ELF)
1842 1843
 		ret = cli_scanelf(desc, ctx);
1843 1844
 	    break;
1844 1845
 
... ...
@@ -44,6 +44,7 @@ struct cfgoption cfg_options[] = {
44 44
     {"PidFile", OPT_QUOTESTR, -1, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM},
45 45
     {"TemporaryDirectory", OPT_QUOTESTR, -1, NULL, 0, OPT_CLAMD},
46 46
     {"ScanPE", OPT_BOOL, 1, NULL, 0, OPT_CLAMD},
47
+    {"ScanELF", OPT_BOOL, 1, NULL, 0, OPT_CLAMD},
47 48
     {"DetectBrokenExecutables", OPT_BOOL, 0, NULL, 0, OPT_CLAMD},
48 49
     {"ScanMail", OPT_BOOL, 1, NULL, 0, OPT_CLAMD},
49 50
     {"MailFollowURLs", OPT_BOOL, 0, NULL, 0, OPT_CLAMD},