~ubuntu-branches/ubuntu/jaunty/clamav/jaunty-security

« back to all changes in this revision

Viewing changes to docs/signatures.tex

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-04-06 14:21:16 UTC
  • mfrom: (0.35.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100406142116-9jwi9mqh3mdvi8mq
Tags: 0.95.3+dfsg-1ubuntu0.09.04.1
* SECURITY UPDATE: (LP: #553266)
* References clamav bugs #1771 and #1826
* libclamav/mspack.c: fix Quantum decompressor (bb#1771)
  - clamav git 224fee54dd6cd8933d7007331ec2bfca0398d4b4
* libclamav/mspack.c: improve unpacking of malformed cabinets (bb#1826)
  - clamav git 31b77b3fb589ab07e7b4d84f8b3825178864ee51
* based on work by Scott Kitterman

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
        \item \verb+??+\\
103
103
        Match any byte.
104
104
        \item \verb+a?+\\
105
 
        Match a high nibble (the four high bits). \textbf{IMPORTANT NOTE:}
 
105
        Match a high nibble (the four high bits).\\ \textbf{IMPORTANT NOTE:}
106
106
        The nibble matching is only available in libclamav with the
107
107
        functionality level 17 and higher therefore please only use it with
108
108
        .ndb signatures followed by ":17" (MinEngineFunctionalityLevel,
112
112
        \item \verb+*+\\
113
113
        Match any number of bytes.
114
114
        \item \verb+{n}+\\
115
 
        Match n bytes.
 
115
        Match $n$ bytes.
116
116
        \item \verb+{-n}+\\
117
 
        Match n or less bytes.
 
117
        Match $n$ or less bytes.
118
118
        \item \verb+{n-}+\\
119
 
        Match n or more bytes.
 
119
        Match $n$ or more bytes.
 
120
        \item \verb+{n-m}+\\
 
121
        Match between $n$ and $m$ bytes ($m > n$).
120
122
        \item \verb+(aa|bb|cc|..)+\\
121
123
        Match aa or bb or cc..
122
124
        \item \verb+HEXSIG[x-y]aa+ or \verb+aa[x-y]HEXSIG+\\
149
151
    the type of the target file:
150
152
    \begin{itemize}
151
153
        \item 0 = any file
152
 
        \item 1 = Portable Executable
153
 
        \item 2 = OLE2 component (e.g. a VBA script)
154
 
        \item 3 = HTML (normalised)
 
154
        \item 1 = Portable Executable, both 32- and 64-bit.
 
155
        \item 2 = file inside OLE2 container (e.g. image, embedded executable,
 
156
        VBA script). The OLE2 format is primarily used by MS Office and MSI
 
157
        installation files.
 
158
        \item 3 = HTML (normalized: whitespace transformed to spaces, tags/tag
 
159
        attributes normalized, all lowercase), Javascript is normalized too:
 
160
        all strings are normalized (hex encoding is decoded), numbers are
 
161
        parsed and normalized, local variables/function names are normalized
 
162
        to 'n001' format, argument to eval() is parsed as JS again,
 
163
        unescape() is handled, some simple JS packers are handled,
 
164
        output is whitespace normalized.
155
165
        \item 4 = Mail file
156
166
        \item 5 = Graphics
157
167
        \item 6 = ELF
158
 
        \item 7 = ASCII text file (normalised)
 
168
        \item 7 = ASCII text file (normalized)
159
169
    \end{itemize}
160
170
    And \verb+Offset+ is an asterisk or a decimal number \verb+n+ possibly
161
171
    combined with a special modifier:
186
196
    \noindent
187
197
    All signatures in the extended format must be placed inside \verb+*.ndb+ files.
188
198
 
 
199
    \subsubsection{Logical signatures}\label{ndb}
 
200
    Logical signatures allow combining of multiple signatures in extended
 
201
    format using logical operators. They can provide both more detailed and
 
202
    flexible pattern matching. The logical sigs are stored inside \verb+*.ldb+
 
203
    files in the following format:
 
204
    \begin{verbatim}
 
205
SignatureName;TargetDescriptionBlock;LogicalExpression;Subsig0;
 
206
Subsig1;Subsig2;...
 
207
    \end{verbatim}
 
208
    where:
 
209
    \begin{itemize}
 
210
        \item \verb+TargetDescriptionBlock+ provides information about the
 
211
        engine and target file with comma separated \verb+Arg:Val+ pairs,
 
212
        currently (as of 0.95.1) only \verb+Target:X+ and \verb+Engine:X-Y+
 
213
        are supported.
 
214
        \item \verb+LogicalExpression+ specifies the logical expression
 
215
        describing the relationship between \verb+Subsig0...SubsigN+.\\
 
216
        \textbf{Basis clause:} 0,1,...,N decimal indexes are SUB-EXPRESSIONS
 
217
        representing \verb+Subsig0, Subsig1,...,SubsigN+ respectively.\\
 
218
        \textbf{Inductive clause:} if \verb+A+ and \verb+B+ are
 
219
        SUB-EXPRESSIONS and \verb+X, Y+ are decimal numbers then
 
220
        \verb+(A&B)+, \verb+(A|B)+, \verb+A=X+, \verb+A=X,Y+, \verb+A>X+,
 
221
        \verb+A>X,Y+, \verb+A<X+ and \verb+A<X,Y+ are SUB-EXPRESSIONS
 
222
        \item \verb+SubsigN+ is n-th subsignature in extended format possibly
 
223
        preceded with an offset. There can be specified up to 64 subsigs.
 
224
    \end{itemize}
 
225
    Modifiers for subexpressions:
 
226
    \begin{itemize}
 
227
        \item \verb+A=X+: If the SUB-EXPRESSION A refers to a single signature
 
228
        then this signature must get matched exactly X times; if it refers to
 
229
        a (logical) block of signatures then this block must generate exactly
 
230
        X matches (with any of its sigs).
 
231
        \item \verb+A=0+ specifies negation (signature or block of signatures
 
232
        cannot be matched)
 
233
        \item \verb+A=X,Y+: If the SUB-EXPRESSION A refers to a single signature
 
234
        then this signature must be matched exactly X times; if it refers to
 
235
        a (logical) block of signatures then this block must generate X matches
 
236
        and at least Y different signatures must get matched.
 
237
        \item \verb+A>X+: If the SUB-EXPRESSION A refers to a single signature
 
238
        then this signature must get matched more than X times; if it refers to
 
239
        a (logical) block of signatures then this block must generate more
 
240
        than X matches (with any of its sigs).
 
241
        \item \verb+A>X,Y+: If the SUB-EXPRESSION A refers to a single signature
 
242
        then this signature must get matched more than X times; if it refers to
 
243
        a (logical) block of signatures then this block must generate more than
 
244
        X matches and at least Y different signatures must be matched.
 
245
        \item \verb+A<X+ and \verb+A<X,Y+ as above with the change of "more"
 
246
        to "less".
 
247
    \end{itemize}
 
248
    Examples:
 
249
    \begin{verbatim}
 
250
Sig1;Target:0;(0&1&2&3)&(4|1);6b6f74656b;616c61;7a6f6c77;7374656
 
251
6616e;deadbeef
 
252
 
 
253
Sig2;Target:0;((0|1|2)>5,2)&(3|1);6b6f74656b;616c61;7a6f6c77;737
 
254
46566616e  
 
255
 
 
256
Sig3;Target:0;((0|1|2|3)=2)&(4|1);6b6f74656b;616c61;7a6f6c77;737
 
257
46566616e;deadbeef
 
258
 
 
259
Sig4;Target:1,Engine:18-20;((0|1)&(2|3))&4;EP+123:33c06834f04100
 
260
f2aef7d14951684cf04100e8110a00;S2+78:22??232c2d252229{-15}6e6573
 
261
(63|64)61706528;S+50:68efa311c3b9963cb1ee8e586d32aeb9043e;f9c58d
 
262
cf43987e4f519d629b103375;SL+550:6300680065005c0046006900
 
263
    \end{verbatim}
 
264
 
189
265
    \subsection{Signatures based on archive metadata}
190
266
    Signatures based on metadata inside archive files can provide an effective
191
267
    protection against malware that spreads via encrypted zip or rar
260
336
    HTML exploits. Running \verb+sigtool --html-normalise+ on a HTML file
261
337
    should generate the following files:
262
338
    \begin{itemize}
263
 
        \item nocomment.html - the file is normalised, lower-case, with all
 
339
        \item nocomment.html - the file is normalized, lower-case, with all
264
340
        comments and superflous white space removed
265
341
        \item notags.html - as above but with all HTML tags removed
266
342
    \end{itemize}
270
346
    be set to 3.
271
347
 
272
348
    \subsection{Text files}
273
 
    Similarly to HTML all ASCII text files get normalised (converted
 
349
    Similarly to HTML all ASCII text files get normalized (converted
274
350
    to lower-case, all superflous white space and control characters removed,
275
351
    etc.) before scanning. Use \verb+clamscan --leave-temps+ to obtain
276
 
    a normalised file then create a signature with the target type 7.
 
352
    a normalized file then create a signature with the target type 7.
277
353
 
278
354
    \subsection{Compressed Portable Executable files}
279
355
    If the file is compressed with UPX, FSG, Petite or other PE packer