~ubuntu-branches/ubuntu/saucy/clamav/saucy

« back to all changes in this revision

Viewing changes to docs/html/node43.html

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2007-12-18 15:18:53 UTC
  • mfrom: (0.25.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218151853-ag6bdjbq6budh353
Tags: 0.92~dfsg-0build1
Fake sync to get the new clamav into the NEW queue

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
8
8
<HTML>
9
9
<HEAD>
10
 
<TITLE>Database reloading</TITLE>
11
 
<META NAME="description" CONTENT="Database reloading">
 
10
<TITLE>Data scan functions</TITLE>
 
11
<META NAME="description" CONTENT="Data scan functions">
12
12
<META NAME="keywords" CONTENT="clamdoc">
13
13
<META NAME="resource-type" CONTENT="document">
14
14
<META NAME="distribution" CONTENT="global">
19
19
 
20
20
<LINK REL="STYLESHEET" HREF="clamdoc.css">
21
21
 
22
 
<LINK REL="next" HREF="node48.html">
23
 
<LINK REL="previous" HREF="node38.html">
24
 
<LINK REL="up" HREF="node29.html">
 
22
<LINK REL="next" HREF="node44.html">
 
23
<LINK REL="previous" HREF="node42.html">
 
24
<LINK REL="up" HREF="node42.html">
25
25
<LINK REL="next" HREF="node44.html">
26
26
</HEAD>
27
27
 
31
31
  HREF="node44.html">
32
32
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
33
33
<A NAME="tex2html747"
34
 
  HREF="node29.html">
 
34
  HREF="node42.html">
35
35
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
36
36
<A NAME="tex2html741"
37
37
  HREF="node42.html">
41
41
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
42
42
<BR>
43
43
<B> Next:</B> <A NAME="tex2html752"
44
 
  HREF="node44.html">Data scan functions</A>
 
44
  HREF="node44.html">Memory</A>
45
45
<B> Up:</B> <A NAME="tex2html748"
46
 
  HREF="node29.html">LibClamAV</A>
 
46
  HREF="node42.html">Database reloading</A>
47
47
<B> Previous:</B> <A NAME="tex2html742"
48
 
  HREF="node42.html">Engine structure</A>
 
48
  HREF="node42.html">Database reloading</A>
49
49
 &nbsp <B>  <A NAME="tex2html750"
50
50
  HREF="node1.html">Contents</A></B> 
51
51
<BR>
52
52
<BR>
53
53
<!--End of Navigation Panel-->
54
54
 
55
 
<H2><A NAME="SECTION00075000000000000000">
56
 
Database reloading</A>
57
 
</H2>
58
 
    The most important thing is to keep the internal instance of the database
59
 
    up to date. You can watch database changes with the <code>cl_stat</code>
60
 
    family of functions.
61
 
    <PRE>
62
 
        int cl_statinidir(const char *dirname, struct cl_stat *dbstat);
63
 
        int cl_statchkdir(const struct cl_stat *dbstat);
64
 
        int cl_statfree(struct cl_stat *dbstat);
65
 
</PRE>
66
 
    Initialization:
 
55
<H3><A NAME="SECTION00074100000000000000">
 
56
Data scan functions</A>
 
57
</H3>
 
58
    It's possible to scan a file or descriptor using:
 
59
    <PRE>
 
60
        int cl_scanfile(const char *filename, const char **virname,
 
61
        unsigned long int *scanned, const struct cl_engine *engine,
 
62
        const struct cl_limits *limits, unsigned int options);
 
63
 
 
64
        int cl_scandesc(int desc, const char **virname, unsigned
 
65
        long int *scanned, const struct cl_engine *engine, const
 
66
        struct cl_limits *limits, unsigned int options);
 
67
</PRE>
 
68
    Both functions will save a virus name under the pointer <code>virname</code>,
 
69
    the virus name is part of the engine structure and must not be released
 
70
    directly. If the third argument (<code>scanned</code>) is not NULL, the
 
71
    functions will increase its value with the size of scanned data (in
 
72
    <code>CL_COUNT_PRECISION</code> units). Both functions have support for archive
 
73
    limits in order to protect against Denial of Service attacks.
 
74
    <PRE>
 
75
struct cl_limits {
 
76
    unsigned int maxreclevel;     /* maximum recursion level for archives */
 
77
    unsigned int maxfiles;        /* maximum number of files to be scanned
 
78
                                   * within a single archive
 
79
                                   */
 
80
    unsigned int maxmailrec;      /* maximum recursion level for mail files */
 
81
    unsigned int maxratio;        /* maximum compression ratio */
 
82
    unsigned long int maxfilesize;/* compressed files larger than this limit
 
83
                                   * will not be scanned
 
84
                                   */
 
85
    unsigned short archivememlim;  /* limit memory usage for some unpackers */
 
86
};
 
87
</PRE>
 
88
    The last argument (<code>options</code>) configures the scan engine and supports
 
89
    the following flags (that can be combined using bit operators):
 
90
    
 
91
<UL>
 
92
<LI><B>CL_SCAN_STDOPT</B>
 
93
<BR>
 
94
This is an alias for a recommended set of scan options. You
 
95
              should use it to make your software ready for new features
 
96
              in the future versions of libclamav.
 
97
</LI>
 
98
<LI><B>CL_SCAN_RAW</B>
 
99
<BR>
 
100
Use it alone if you want to disable support for special files.
 
101
</LI>
 
102
<LI><B>CL_SCAN_ARCHIVE</B>
 
103
<BR>
 
104
This flag enables transparent scanning of various archive formats.
 
105
</LI>
 
106
<LI><B>CL_SCAN_BLOCKENCRYPTED</B>
 
107
<BR>
 
108
With this flag the library will mark encrypted archives as viruses
 
109
              (Encrypted.Zip, Encrypted.RAR).
 
110
</LI>
 
111
<LI><B>CL_SCAN_BLOCKMAX</B>
 
112
<BR>
 
113
Mark archives as viruses if <code>maxfiles</code>, <code>maxfilesize</code>,
 
114
              or <code>maxreclevel</code> limit is reached.
 
115
</LI>
 
116
<LI><B>CL_SCAN_MAIL</B>
 
117
<BR>
 
118
Enable support for mail files.
 
119
</LI>
 
120
<LI><B>CL_SCAN_MAILURL</B>
 
121
<BR>
 
122
The mail scanner will download and scan URLs listed in a mail
 
123
              body. This flag should not be used on loaded servers. Due to
 
124
              potential problems please do not enable it by default but make
 
125
              it optional.
 
126
</LI>
 
127
<LI><B>CL_SCAN_OLE2</B>
 
128
<BR>
 
129
Enables support for OLE2 containers (used by MS Office and .msi
 
130
              files).
 
131
</LI>
 
132
<LI><B>CL_SCAN_PDF</B>
 
133
<BR>
 
134
Enables scanning within PDF files.
 
135
</LI>
 
136
<LI><B>CL_SCAN_PE</B>
 
137
<BR>
 
138
This flag enables deep scanning of Portable Executable files and
 
139
              allows libclamav to unpack executables compressed with run-time
 
140
              unpackers.
 
141
</LI>
 
142
<LI><B>CL_SCAN_ELF</B>
 
143
<BR>
 
144
Enable support for ELF files.
 
145
</LI>
 
146
<LI><B>CL_SCAN_BLOCKBROKEN</B>
 
147
<BR>
 
148
libclamav will try to detect broken executables and mark them as
 
149
              Broken.Executable.
 
150
</LI>
 
151
<LI><B>CL_SCAN_HTML</B>
 
152
<BR>
 
153
This flag enables HTML normalisation (including ScrEnc
 
154
              decryption).
 
155
</LI>
 
156
<LI><B>CL_SCAN_ALGORITHMIC</B>
 
157
<BR>
 
158
Enable algorithmic detection of viruses.
 
159
</LI>
 
160
<LI><B>CL_SCAN_PHISHING_DOMAINLIST</B>
 
161
<BR>
 
162
Phishing module: restrict URL scanning to domains from .pdf
 
163
              (RECOMMENDED).
 
164
</LI>
 
165
<LI><B>CL_SCAN_PHISHING_BLOCKSSL</B>
 
166
<BR>
 
167
Phishing module: always block SSL mismatches in URLs.
 
168
</LI>
 
169
<LI><B>CL_SCAN_PHISHING_BLOCKCLOAK</B>
 
170
<BR>
 
171
Phishing module: always block cloaked URLs.
 
172
    
 
173
</LI>
 
174
</UL>
 
175
    All functions return 0 (<code>CL_CLEAN</code>) when the file seems clean,
 
176
    <code>CL_VIRUS</code> when a virus is detected and another value on failure.
67
177
    <PRE>
68
178
            ...
69
 
            struct cl_stat dbstat;
70
 
 
71
 
        memset(&amp;dbstat, 0, sizeof(struct cl_stat));
72
 
        cl_statinidir(dbdir, &amp;dbstat);
73
 
</PRE>
74
 
    To check for a change you just need to call <code>cl_statchkdir</code> and check
75
 
    its return value:
76
 
    <PRE>
77
 
        if(cl_statchkdir(&amp;dbstat) == 1) {
78
 
            reload_database...;
79
 
            cl_statfree(&amp;dbstat);
80
 
            cl_statinidir(cl_retdbdir(), &amp;dbstat);
 
179
            struct cl_limits limits;
 
180
            const char *virname;
 
181
 
 
182
        memset(&amp;limits, 0, sizeof(struct cl_limits));
 
183
        limits.maxfiles = 1000; /* max files */
 
184
        limits.maxfilesize = 10 * 1048576; /* maximum size of archived or
 
185
                                    * compressed file (files exceeding
 
186
                                    * this limit will be ignored)
 
187
                                    */
 
188
        limits.maxreclevel = 5; /* maximum recursion level for archives */
 
189
        limits.maxmailrec = 64; /* maximum recursion level for mail files */
 
190
        limits.maxratio = 200; /* maximum compression ratio */
 
191
 
 
192
        if((ret = cl_scanfile("/tmp/test.exe", &amp;virname, NULL, engine,
 
193
        &amp;limits, CL_STDOPT)) == CL_VIRUS) {
 
194
            printf("Virus detected: %s\n", virname);
 
195
        } else {
 
196
            printf("No virus detected.\n");
 
197
            if(ret != CL_CLEAN)
 
198
                printf("Error: %s\n", cl_strerror(ret));
81
199
        }
82
200
</PRE>
83
 
    Remember to reset the <code>cl_stat</code> structure after reload.
84
201
 
85
202
<P>
86
 
<BR><HR>
87
 
<!--Table of Child-Links-->
88
 
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
89
 
 
90
 
<UL>
91
 
<LI><A NAME="tex2html753"
92
 
  HREF="node44.html">Data scan functions</A>
93
 
<LI><A NAME="tex2html754"
94
 
  HREF="node45.html">Memory</A>
95
 
<LI><A NAME="tex2html755"
96
 
  HREF="node46.html">clamav-config</A>
97
 
<LI><A NAME="tex2html756"
98
 
  HREF="node47.html">Example</A>
99
 
</UL>
100
 
<!--End of Table of Child-Links-->
101
 
<BR><HR>
 
203
<HR>
 
204
<!--Navigation Panel-->
 
205
<A NAME="tex2html751"
 
206
  HREF="node44.html">
 
207
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
 
208
<A NAME="tex2html747"
 
209
  HREF="node42.html">
 
210
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
 
211
<A NAME="tex2html741"
 
212
  HREF="node42.html">
 
213
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
 
214
<A NAME="tex2html749"
 
215
  HREF="node1.html">
 
216
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
 
217
<BR>
 
218
<B> Next:</B> <A NAME="tex2html752"
 
219
  HREF="node44.html">Memory</A>
 
220
<B> Up:</B> <A NAME="tex2html748"
 
221
  HREF="node42.html">Database reloading</A>
 
222
<B> Previous:</B> <A NAME="tex2html742"
 
223
  HREF="node42.html">Database reloading</A>
 
224
 &nbsp <B>  <A NAME="tex2html750"
 
225
  HREF="node1.html">Contents</A></B> 
 
226
<!--End of Navigation Panel-->
102
227
<ADDRESS>
103
228
Tomasz Kojm
104
 
2007-07-11
 
229
2007-12-12
105
230
</ADDRESS>
106
231
</BODY>
107
232
</HTML>