Browse code

docs: update signatures.pdf - more to come

Tomasz Kojm authored on 2010/02/26 01:20:50
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Feb 25 17:20:27 CET 2010 (tk)
2
+---------------------------------
3
+ * docs: update signatures.pdf
4
+
1 5
 Tue Feb 16 16:41:30 CET 2010 (tk)
2 6
 ---------------------------------
3 7
  * libclamav/cvd.c: enable new dsig check for main db
4 8
Binary files a/docs/signatures.pdf and b/docs/signatures.pdf differ
... ...
@@ -38,8 +38,8 @@ JVh4vYmW8mZ62ZHYMlM903TMZFg5hZIxcjQB3SX0TapdF1SFNzoWjsyH53eXvMDY
38 38
 eaPVNe2ccXLfEegoda4xU2TezbGfbSEGoU1qolyQYLX674sNA2Ni6l6/CEKYYh
39 39
 Verification OK.
40 40
     \end{verbatim}
41
-    The ClamAV project distributes two CVD files: \emph{main.cvd} and
42
-    \emph{daily.cvd}.
41
+    The ClamAV project distributes a number of CVD files, including
42
+    \emph{main.cvd} and \emph{daily.cvd}.
43 43
 
44 44
     \section{Signature formats}
45 45
 
... ...
@@ -52,7 +52,7 @@ zolw@localhost:/tmp/test$ sigtool --md5 test.exe > test.hdb
52 52
 zolw@localhost:/tmp/test$ cat test.hdb 
53 53
 48c4533230e1ae1c118c741c0db19dfb:17387:test.exe
54 54
     \end{verbatim}
55
-    That's it! The signature is ready to use:
55
+    That's it! The signature is ready for use:
56 56
     \begin{verbatim}
57 57
 zolw@localhost:/tmp/test$ clamscan -d test.hdb test.exe 
58 58
 test.exe: test.exe FOUND
... ...
@@ -83,10 +83,11 @@ PESectionSize:MD5:MalwareName
83 83
     target PE sections into separate files and then run sigtool with the
84 84
     option \verb+--mdb+
85 85
 
86
-    \subsection{Hexadecimal signatures}
87
-    ClamAV stores all signatures in a hexadecimal format. By a hex-signature
88
-    here we mean a fragment of a malware's body converted into a hexadecimal
89
-    string which can be additionally extended with various wildcards.
86
+    \subsection{Body-based signatures}
87
+    ClamAV stores all body-based signatures in a hexadecimal format. In this
88
+    section by a hex-signature we mean a fragment of malware's body converted
89
+    into a hexadecimal string which can be additionally extended using various
90
+    wildcards.
90 91
 
91 92
     \subsubsection{Hexadecimal format}
92 93
     You can use \verb+sigtool --hex-dump+ to convert any data into a hex-string:
... ...
@@ -97,7 +98,7 @@ How do I look in hex?
97 97
     \end{verbatim}
98 98
 
99 99
     \subsubsection{Wildcards}
100
-    ClamAV supports the following extensions inside hex signatures:
100
+    ClamAV supports the following extensions for hex-signatures:
101 101
     \begin{itemize}
102 102
 	\item \verb+??+\\
103 103
 	Match any byte.
... ...
@@ -122,11 +123,15 @@ How do I look in hex?
122 122
 	\item \verb+(aa|bb|cc|..)+\\
123 123
 	Match aa or bb or cc..
124 124
 	\item \verb+!(aa|bb|cc|..)+\\
125
-	Match any byte except aa and bb and cc..
125
+	Match any byte except aa and bb and cc.. (ClamAV$\ge$0.96)
126 126
 	\item \verb+HEXSIG[x-y]aa+ or \verb+aa[x-y]HEXSIG+\\
127 127
 	Match aa anchored to a hex-signature, see
128 128
 	\url{https://wwws.clamav.net/bugzilla/show_bug.cgi?id=776} for
129
-	a discussion and examples.
129
+	discussion and examples.
130
+	\item \verb+(B)+\\
131
+	Match word boundary (including file boundaries).
132
+	\item \verb+(L)+\\
133
+	Match CR, CRLF or file boundaries.
130 134
     \end{itemize}
131 135
     The range signatures \verb+*+ and \verb+{}+ virtually separate
132 136
     a hex-signature into two parts, eg. \verb+aabbcc*bbaacc+ is treated
... ...
@@ -168,7 +173,7 @@ MalwareName:TargetType:Offset:HexSignature[:MinEngineFunctionalityLevel:[Max]]
168 168
 	\item 5 = Graphics
169 169
 	\item 6 = ELF
170 170
 	\item 7 = ASCII text file (normalized)
171
-	\item 8 = Disassembler data
171
+	\item 8 = Unused
172 172
 	\item 9 = Mach-O files
173 173
     \end{itemize}
174 174
     And	\verb+Offset+ is an asterisk or a decimal number \verb+n+ possibly
... ...
@@ -226,6 +231,15 @@ Subsig1;Subsig2;...
226 226
 	\item \verb+SubsigN+ is n-th subsignature in extended format possibly
227 227
 	preceded with an offset. There can be specified up to 64 subsigs.
228 228
     \end{itemize}
229
+    Keywords used in \verb+TargetDescriptionBlock+:
230
+    \begin{itemize}
231
+	\item \verb+Target:X+: Target file type
232
+	\item \verb+Engine:X-Y+: Required engine functionality (range; 0.96)
233
+	\item \verb+FileSize:X-Y+: Required file size (range in bytes; 0.96)
234
+	\item \verb+EntryPoint+: Entry point offset (range in bytes; 0.96)
235
+	\item \verb+NumberOfSections+: Required number of sections in executable (range; 0.96)
236
+	\item \verb+Container:CL_TYPE_*+: File type of the container which stores the scanned file
237
+    \end{itemize}
229 238
     Modifiers for subexpressions:
230 239
     \begin{itemize}
231 240
 	\item \verb+A=X+: If the SUB-EXPRESSION A refers to a single signature
... ...
@@ -265,11 +279,53 @@ f2aef7d14951684cf04100e8110a00;S2+78:22??232c2d252229{-15}6e6573
265 265
 (63|64)61706528;S+50:68efa311c3b9963cb1ee8e586d32aeb9043e;f9c58d
266 266
 cf43987e4f519d629b103375;SL+550:6300680065005c0046006900
267 267
     \end{verbatim}
268
+    ClamAV 0.96 introduced support for special macro subsignatures in
269
+    the following format: \verb+${min-max}MACROID$+, where \verb+MACROID+
270
+    points to a group of signatures and \verb+{min-max}+ specifies the
271
+    offset range at which one of the group signatures should match.
272
+    The range is calculated against the match offset of the previous
273
+    subsignature. The macro subsignature makes its preceding subsignature
274
+    considered a match only if both of them get matched. For more
275
+    information and examples please see
276
+    \url{https://wwws.clamav.net/bugzilla/show_bug.cgi?id=164}.
277
+
278
+    \subsection{Signatures based on container metadata}
279
+    ClamAV 0.96 allows creating generic signatures matching files stored
280
+    inside different container types which meet specific conditions.
281
+    The signature format is
282
+\begin{verbatim}
283
+VirusName:ContainerType:ContainerSize:FileNameREGEX:FileSizeInContainer:
284
+FileSizeReal:IsEncrypted:FilePos:Res1:Res2[:MinFL[:MaxFL]]
285
+\end{verbatim}
286
+    where the corresponding fields are:
287
+    \begin{itemize}
288
+	\item \verb+VirusName:+ Virus name to be displayed when signature matches
289
+	\item \verb+ContainerType:+ one of \verb+CL_TYPE_ZIP+, \verb+CL_TYPE_RAR+,
290
+	\verb+CL_TYPE_ARJ+, \verb+CL_TYPE_CAB+, \verb+CL_TYPE_7Z+,
291
+	\verb+CL_TYPE_MAIL+, \verb+CL_TYPE_(POSIX|OLD)_TAR+,
292
+	\verb+CL_TYPE_CPIO_(OLD|ODC|NEWC|CRC)+ or \verb+*+ to match
293
+	any of the container types listed here
294
+	\item \verb+ContainerSize:+ size of the container file itself (eg. size of
295
+	the zip archive) specified in bytes as absolute value or range \verb+x-y+
296
+	\item \verb+FileNameREGEX:+ regular expression describing name of the target file
297
+	\item \verb+FileSizeInContainer:+ usually compressed size; for MAIL, TAR and CPIO ==
298
+	\verb+FileSizeReal+; specified in bytes as absolute value or range
299
+	\item \verb+FileSizeReal:+ usually uncompressed size; for MAIL, TAR and CPIO ==
300
+	\verb+FileSizeInContainer+; absolute value or range
301
+	\item \verb+IsEncrypted+: 1 if the target file is encrypted, 0 if it's not and
302
+	\verb+*+ to ignore
303
+	\item \verb+FilePos+: file position in container (counting from 1); absolute value
304
+	or range
305
+	\item \verb+Res1+: when \verb+ContainerType+ is \verb+CL_TYPE_ZIP+ or
306
+	\verb+CL_TYPE_RAR+ this field is treated as a CRC sum of the target file
307
+	specified in hexadecimal format; for other container types it's ignored
308
+	\item \verb+Res2+: not used as of ClamAV 0.96
309
+    \end{itemize}
310
+    The signatures for container files are stored inside \verb+.cdb+ files.
268 311
 
269
-    \subsection{Signatures based on archive metadata}
270
-    Signatures based on metadata inside archive files can provide an effective
271
-    protection against malware that spreads via encrypted zip or rar
272
-    archives. The format of a metadata signature is:
312
+    \subsection{Signatures based on ZIP/RAR metadata (obsolete)}
313
+    The (now obsolete) archive metadata signatures can be only applied
314
+    to ZIP and RAR files and have the following format:
273 315
 \begin{verbatim}
274 316
 virname:encrypted:filename:normal size:csize:crc32:cmethod:fileno:max depth
275 317
 \end{verbatim}
... ...
@@ -293,11 +349,16 @@ virname:encrypted:filename:normal size:csize:crc32:cmethod:fileno:max depth
293 293
     it inside a database file with the extension of \verb+.fp+.\\
294 294
 
295 295
     \noindent
296
-    To whitelist a specific signature inside main.cvd add the following
297
-    entry into daily.ign or a local file local.ign:
296
+    To whitelist a specific signature from the database you just add
297
+    its name into a local file called local.ign2 stored inside the
298
+    database directory. You can additionally follow the signature name
299
+    with the MD5 of the entire database entry for this signature, eg:
298 300
 \begin{verbatim}
299
-db_name:line_number:signature_name
301
+Eicar-Test-Signature:bc356bae4c42f19a3de16e333ba3569c
300 302
 \end{verbatim}
303
+    In such a case, the signature will no longer be whitelisted when
304
+    its entry in the database gets modified (eg. the signature gets
305
+    updated to avoid false alerts).
301 306
 
302 307
     \subsection{Signature names}
303 308
     ClamAV uses the following prefixes for signature names:
... ...
@@ -326,7 +387,8 @@ db_name:line_number:signature_name
326 326
     \end{itemize}
327 327
     Important rules of the naming convention:
328 328
     \begin{itemize}
329
-	\item always use a -zippwd suffix in the malware name for signatures of	      type zmd,
329
+	\item always use a -zippwd suffix in the malware name for signatures
330
+	      of type zmd,
330 331
 	\item always use a -rarpwd suffix in the malware name for signatures
331 332
 	      of type rmd,
332 333
 	\item only use alphanumeric characters, dash (-), dot (.), underscores