Browse code

docs - overhauling Usage documentation

Mickey Sola authored on 2018/11/15 05:39:30
Showing 5 changed files
1 1
deleted file mode 100644
... ...
@@ -1,105 +0,0 @@
1
-# Configuration
2
-
3
-Before proceeding with the steps below, you should run the ’clamconf’ command, which gives important information about your ClamAV configuration. See section [5.8](#sec:clamconf) for more details.
4
-
5
-## clamd
6
-
7
-Before you start using the daemon you have to edit the configuration file (in other case `clamd` won’t run):
8
-
9
-```bash
10
-    $ clamd
11
-    ERROR: Please edit the example config file /etc/clamd.conf.
12
-```
13
-
14
-This shows the location of the default configuration file. The format and options of this file are fully described in the *clamd.conf(5)* manual. The config file is well commented and configuration should be straightforward.
15
-
16
-### On-access scanning
17
-
18
-One of the interesting features of `clamd` is on-access scanning based on fanotify, included in Linux since kernel 2.6.36. **This is not required to run clamd**. At the moment the fanotify header is only available for Linux.
19
-
20
-Configure on-access scanning in `clamd.conf` and read the [on-access](Usage.md#On-access-Scanning) section for on-access scanning usage.
21
-
22
-## clamav-milter
23
-
24
-ClamAV (v0.95) includes a new, redesigned clamav-milter. The most notable difference is that the internal mode has been dropped and now a working clamd companion is required. The second important difference is that now the milter has got its own configuration and log files.
25
-
26
-To compile ClamAV with the clamav-milter just run `./configure --enable-milter` and make as usual. In order to use the `–enable-milter` option with `configure`, your system MUST have the milter library installed. If you use the `–enable-milter` option without the library being installed, you will most likely see output like this during ’configure’:
27
-
28
-```bash
29
-        checking for libiconv_open in -liconv... no
30
-        checking for iconv... yes
31
-        checking whether in_port_t is defined... yes
32
-        checking for in_addr_t definition... yes
33
-        checking for mi_stop in -lmilter... no
34
-        checking for library containing strlcpy... no
35
-        checking for mi_stop in -lmilter... no
36
-        configure: error: Cannot find libmilter
37
-```
38
-
39
-At which point the ’configure’ script will stop processing.
40
-
41
-Please consult your MTA’s manual on how to connect ClamAV with the milter.
42
-
43
-## Testing
44
-
45
-Try to scan recursively the source directory:
46
-
47
-```bash
48
-    $ clamscan -r -l scan.txt clamav-x.yz
49
-```
50
-
51
-It should find some test files in the clamav-x.yz/test directory. The scan result will be saved in the `scan.txt` log file \[7\]. To test `clamd`, start it and use `clamdscan` (or instead connect directly to its socket and run the SCAN command):
52
-
53
-```bash
54
-    $ clamdscan -l scan.txt clamav-x.yz
55
-```
56
-
57
-Please note that the scanned files must be accessible by the user running `clamd` or you will get an error.
58
-
59
-## Setting up auto-updating
60
-
61
-`freshclam` is the automatic database update tool for Clam AntiVirus. It can work in two modes:
62
-
63
-- interactive - on demand from command line
64
-- daemon - silently in the background
65
-
66
-`freshclam` is advanced tool: it supports scripted updates (instead of transferring the whole CVD file at each update it only transfers the differences between the latest and the current database via a special script), database version checks through DNS, proxy servers (with authentication), digital signatures and various error scenarios. **Quick test: run freshclam (as superuser) with no parameters and check the output.** If everything is OK you may create the log file in /var/log (owned by *clamav* or another user `freshclam` will be running as):
67
-
68
-```bash
69
-    # touch /var/log/freshclam.log
70
-    # chmod 600 /var/log/freshclam.log
71
-    # chown clamav /var/log/freshclam.log
72
-```
73
-
74
-Now you *should* edit the configuration file `freshclam.conf` and point the *UpdateLogFile* directive to the log file. Finally, to run `freshclam` in the daemon mode, execute:
75
-
76
-```bash
77
-    # freshclam -d
78
-```
79
-
80
-The other way is to use the *cron* daemon. You have to add the following line to the crontab of **root** or **clamav** user:
81
-
82
-```cron
83
-N * * * *   /usr/local/bin/freshclam --quiet
84
-```
85
-
86
-to check for a new database every hour. **N should be a number between 3 and 57 of your choice. Please don’t choose any multiple of 10, because there are already too many clients using those time slots.** Proxy settings are only configurable via the configuration file and `freshclam` will require strict permission settings for the config file when `HTTPProxyPassword` is turned on.
87
-
88
-```bash
89
-    HTTPProxyServer myproxyserver.com
90
-    HTTPProxyPort 1234
91
-    HTTPProxyUsername myusername
92
-    HTTPProxyPassword mypass
93
-```
94
-
95
-### Closest mirrors
96
-
97
-The `DatabaseMirror` directive in the config file specifies the database server `freshclam` will attempt (up to `MaxAttempts` times) to download the database from. The default database mirror is [database.clamav.net](database.clamav.net) but multiple directives are allowed. In order to download the database from the closest mirror you should configure `freshclam` to use [db.xx.clamav.net](db.xx.clamav.net) where xx represents your country code. For example, if your server is in "Ascension Island" you should have the following lines included in `freshclam.conf`:
98
-
99
-```bash
100
-    DNSDatabaseInfo current.cvd.clamav.net
101
-    DatabaseMirror db.ac.clamav.net
102
-    DatabaseMirror database.clamav.net
103
-```
104
-
105
-The second entry acts as a fallback in case the connection to the first mirror fails for some reason. The full list of two-letters country codes is available at <http://www.iana.org/cctld/cctld-whois.htm>
... ...
@@ -1,215 +1,33 @@
1 1
 # Usage
2 2
 
3
-## Clam daemon
3
+This User Guide presents an overview of the various ways that *libclamav* can be used through the tools provided by ClamAV. To learn more about how to better use each facet of ClamAV that interests you, please follow the links provided.
4 4
 
5
-`clamd` is a multi-threaded daemon that uses *libclamav* to scan files for viruses. It may work in one or both modes listening on:
5
+## Daemon
6 6
 
7
-- Unix (local) socket
8
-- TCP socket
7
+The ClamAV Daemon, or [`clamd`](Usage/Scanning.md#clamd), is a multi-threaded daemon that uses *libclamav* to [scan files for viruses](Usage/Scanning.md). ClamAV provides a number of tools which interface with this daemon. They are, as follows:
9 8
 
10
-The daemon is fully configurable via the `clamd.conf` file \[8\]. `clamd` recognizes the following commands:
9
+  - [`clamdscan`](Usage/Scanning.md#clamdscan) - a simple scanning client
10
+  - [`on-access scanning`](Usage/Scanning.md#On-access-scanning) - a special `clamd` thread for real-time protection
11
+  - [`clamdtop`](Usage/Scanning.md#clamdtop) - a resource monitoring interface for `clamd`
11 12
 
12
-- **PING**
13
-    Check the daemon’s state (should reply with "PONG").
14
-- **VERSION**
15
-    Print program and database versions.
16
-- **RELOAD**
17
-    Reload the databases.
18
-- **SHUTDOWN**
19
-    Perform a clean exit.
20
-- **SCAN file/directory**
21
-    Scan file or directory (recursively) with archive support enabled (a full path is required).
22
-- **RAWSCAN file/directory**
23
-    Scan file or directory (recursively) with archive and special file support disabled (a full path is required).
24
-- **CONTSCAN file/directory**
25
-    Scan file or directory (recursively) with archive support enabled and don’t stop the scanning when a virus is found.
26
-- **MULTISCAN file/directory**
27
-    Scan file in a standard way or scan directory (recursively) using multiple threads (to make the scanning faster on SMP machines).
28
-- **ALLMATCHSCAN file/directory**
29
-    ALLMATCHSCAN works just like SCAN except that it sets a mode where, after finding a virus within a file, continues scanning for additional viruses.
30
-- **INSTREAM**
31
-    *It is mandatory to prefix this command with **n** or **z**.* Scan a stream of data. The stream is sent to clamd in chunks, after INSTREAM, on the same socket on which the command was sent. This avoids the overhead of establishing new TCP connections and problems with NAT. The format of the chunk is: `<length><data>` where `<length>` is the size of the following data in bytes expressed as a 4 byte unsigned integer in network byte order and `<data>` is the actual chunk. Streaming is terminated by sending a zero-length chunk. Note: do not exceed StreamMaxLength as defined in clamd.conf, otherwise clamd will reply with *INSTREAM size limit exceeded* and close the connection.
32
-- **FILDES**
33
-    *It is mandatory to newline terminate this command, or prefix with **n** or **z**. This command only works on UNIX domain sockets.* Scan a file descriptor. After issuing a FILDES command a subsequent rfc2292/bsd4.4 style packet (with at least one dummy character) is sent to clamd carrying the file descriptor to be scanned inside the ancillary data. Alternatively the file descriptor may be sent in the same packet, including the extra character.
34
-- **STATS**
35
-    *It is mandatory to newline terminate this command, or prefix with **n** or **z**, it is recommended to only use the **z** prefix.* On this command clamd provides statistics about the scan queue, contents of scan queue, and memory usage. The exact reply format is subject to changes in future releases.
36
-- **IDSESSION, END**
37
-    *It is mandatory to prefix this command with **n** or **z**, also all commands inside **IDSESSION** must be prefixed.* Start/end a clamd session. Within a session multiple SCAN, INSTREAM, FILDES, VERSION, STATS commands can be sent on the same socket without opening new connections. Replies from clamd will be in the form `<id>: <response>` where `<id>` is the request number (in ASCII, starting from 1) and `<response>` is the usual clamd reply. The reply lines have the same delimiter as the corresponding command had. Clamd will process the commands asynchronously, and reply as soon as it has finished processing. Clamd requires clients to read all the replies it sent, before sending more commands to prevent send() deadlocks. The recommended way to implement a client that uses IDSESSION is with non-blocking sockets, and a select()/poll() loop: whenever send would block, sleep in select/poll until either you can write more data, or read more replies. *Note that using non-blocking sockets without the select/poll loop and alternating recv()/send() doesn’t comply with clamd’s requirements.* If clamd detects that a client has deadlocked, it will close the connection. Note that clamd may close an IDSESSION connection too if the client doesn’t follow the protocol’s requirements.
38
-- **STREAM** (deprecated, use **INSTREAM** instead)
39
-    Scan stream: clamd will return a new port number you should connect to and send data to scan.
13
+## Scanner
40 14
 
41
-It’s recommended to prefix clamd commands with the letter **z** (eg. zSCAN) to indicate that the command will be delimited by a NULL character and that clamd should continue reading command data until a NULL character is read. The null delimiter assures that the complete command and its entire argument will be processed as a single command. Alternatively commands may be prefixed with the letter **n** (e.g. nSCAN) to use a newline character as the delimiter. Clamd replies will honour the requested terminator in turn. If clamd doesn’t recognize the command, or the command doesn’t follow the requirements specified below, it will reply with an error message, and close the connection. Clamd can handle the following signals:
15
+ClamAV also provides a command-line tool for [simple scanning](Usage/Scanning.md) tasks with *libclamav* called [`clamscan`](Usage/Scanning,md#clamscan). Unlike the daemon, `clamscan` is not a persistent process and is best suited for use cases where one-time scanning with minimal setup is needed.
42 16
 
43
-- **SIGTERM** - perform a clean exit
44
-- **SIGHUP** - reopen the log file
45
-- **SIGUSR2** - reload the database
17
+## Signature Testing and Management
46 18
 
47
-Clamd should not be started in the background using the shell operator `&` or external tools. Instead, you should run and wait for clamd to load the database and daemonize itself. After that, clamd is instantly ready to accept connections and perform file scanning.
19
+A number of tools allow for [testing and management of signatures](Usage/SignatureManagement.md). Of note are the following:
48 20
 
49
-## Clam**d**scan
21
+  - [`clambc`](Usage/SignatureManagement.md#clambc) - specifically for testing bytecode
22
+  - [`sigtool`](Usage/SignatureManagement.md#sigtool) - for general signature testing and analysis
23
+  - [`freshclam`](Usage/SignatureManagement.md#freshclam) - used to update signature database sets to the latest version
50 24
 
51
-`clamdscan` is a simple `clamd` client. In many cases you can use it as a `clamscan` replacement however you must remember that:
52 25
 
53
-- it only depends on `clamd`
54
-- although it accepts the same command line options as `clamscan` most of them are ignored because they must be enabled directly in `clamd`, i.e. `clamd.conf`
55
-- in TCP mode scanned files must be accessible for `clamd`, if you enabled LocalSocket in clamd.conf then clamdscan will try to workaround this limitation by using FILDES
26
+## Configuration
56 27
 
57
-## On-access Scanning
28
+The more complex tools ClamAV provides each require some degree of [configuration](Usage/Configuration.md). ClamAV supplies two examples configuration files:
58 29
 
59
-There is a special thread in `clamd` that performs on-access scanning under Linux and shares internal virus database with the daemon. By default, this thread will only notify you when potential threats are discovered. If you turn on prevention via `clamd.conf` then **you must follow some important rules when using it:**
30
+  - [`clamd.conf`](Usage/Configuration.md#clamd-configuration) - for configuring the behaviour of the ClamAV Daemon `clamd` and associated tools
31
+  - [`freschclam.conf`](Usage/Configuration.md#freshclam-configuration) - for configuring the behaviour of the signature database update tool, `freshclam`
60 32
 
61
-- Always stop the daemon cleanly - using the SHUTDOWN command or the SIGTERM signal. In other case you can lose access to protected files until the system is restarted.
62
-- Never protect the directory your mail-scanner software uses for attachment unpacking. Access to all infected files will be automatically blocked and the scanner (including `clamd`\!) will not be able to detect any viruses. In the result **all infected mails may be delivered.**
63
-- Watch your entire filesystem only using the `clamd.conf` OnAccessMountPath option. While this will disable on-access prevention, it will avoid potential system lockups caused by fanotify’s blocking functionality.
64
-- Using the On-Access Scanner to watch a virtual filesystem will result in undefined behaviour.
65
-
66
-For more configuration options, type ’man clamd.conf’ or reference the example clamd.conf. And for additional details on how to use this feature, please reference the [OnAccess usage manual](OnAccess.md).
67
-
68
-## Clamdtop
69
-
70
-`clamdtop` is a tool to monitor one or multiple instances of clamd. It has a (color) ncurses interface, that shows the jobs in clamd’s queue, memory usage, and information about the loaded signature database. You can specify on the command-line to which clamd(s) it should connect to. By default it will attempt to connect to the local clamd as defined in clamd.conf.
71
-
72
-For more detailed help, type ’man clamdtop’ or ’clamdtop –help’.
73
-
74
-## Clamscan
75
-
76
-`clamscan` is ClamAV’s command line virus scanner. It can be used to scan files and/or directories for viruses. In order for clamscan to work proper, the ClamAV virus database files must be installed on the system you are using clamscan on.
77
-
78
-The general usage of clamscan is: clamscan \[options\]
79
-\[file/directory/-\]
80
-
81
-For more detailed help, type ’man clamscan’ or ’clamscan –help’.
82
-
83
-## ClamBC
84
-
85
-`clambc` is Clam Anti-Virus’ bytecode testing tool. It can be used to test files which contain bytecode. For more detailed help, type ’man clambc’ or ’clambc –help’.
86
-
87
-## Freshclam
88
-
89
-`freshclam` is ClamAV’s virus database update tool and reads it’s configuration from the file ’freshclam.conf’ (this may be overridden by command line options). Freshclam’s default behavior is to attempt to update databases that are paired with downloaded cdiffs. Potentially corrupted databases are not updated and are automatically fully replaced after several failed attempts unless otherwise specified.
90
-
91
-Here is a sample usage including cdiffs:
92
-
93
-```bash
94
-$ freshclam
95
-
96
-ClamAV update process started at Mon Oct  7 08:15:10 2013
97
-main.cld is up to date (version: 55, sigs: 2424225, f-level: 60, builder: neo)
98
-Downloading daily-17945.cdiff [100%]
99
-Downloading daily-17946.cdiff [100%]
100
-Downloading daily-17947.cdiff [100%]
101
-daily.cld updated (version: 17947, sigs: 406951, f-level: 63, builder: neo)
102
-Downloading bytecode-227.cdiff [100%]
103
-Downloading bytecode-228.cdiff [100%]
104
-bytecode.cld updated (version: 228, sigs: 43, f-level: 63, builder: neo)
105
-Database updated (2831219 signatures) from database.clamav.net (IP: 64.6.100.177)
106
-```
107
-
108
-For more detailed help, type ’man clamscan’ or ’clamscan –help’.
109
-
110
-## Clamconf
111
-
112
-`clamconf` is the Clam Anti-Virus configuration utility. It is used for displaying values of configurations options in ClamAV, which will show the contents of clamd.conf (or tell you if it is not properly configured), the contents of freshclam.conf, and display information about software settings, database, platform, and build information. Here is a sample clamconf output:
113
-
114
-```bash
115
-$ clamconf
116
-
117
-Checking configuration files in /etc/clamav
118
-
119
-Config file: clamd.conf
120
-ERROR: Please edit the example config file /etc/clamav/clamd.conf
121
-
122
-Config file: freshclam.conf
123
-ERROR: Please edit the example config file /etc/clamav/freshclam.conf
124
-
125
-clamav-milter.conf not found
126
-
127
-Software settings
128
-Version: 0.98.2
129
-Optional features supported: MEMPOOL IPv6 AUTOIT_EA06 BZIP2 RAR JIT
130
-
131
-Database information
132
-Database directory: /xclam/gcc/release/share/clamav
133
-WARNING: freshclam.conf and clamd.conf point to different database directories
134
-print_dbs: Can't open directory /xclam/gcc/release/share/clamav
135
-
136
-Platform information
137
-uname: Linux 3.5.0-44-generic #67~precise1-Ubuntu SMP Wed Nov 13 16:20:03 UTC 2013 i686
138
-OS: linux-gnu, ARCH: i386, CPU: i686
139
-Full OS version: Ubuntu 12.04.3 LTS
140
-zlib version: 1.2.3.4 (1.2.3.4), compile flags: 55
141
-Triple: i386-pc-linux-gnu
142
-CPU: i686, Little-endian
143
-platform id: 0x0a114d4d0404060401040604
144
-
145
-Build information
146
-GNU C: 4.6.4 (4.6.4)
147
-GNU C++: 4.6.4 (4.6.4)
148
-CPPFLAGS:
149
-CFLAGS: -g -O0 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
150
-CXXFLAGS:
151
-LDFLAGS:
152
-Configure: '--prefix=/xclam/gcc/release/' '--disable-clamav' '--enable-debug' 'CFLAGS=-g -O0'
153
-sizeof(void*) = 4
154
-Engine flevel: 77, dconf: 77
155
-
156
-```
157
-
158
-For more detailed help, type ’man clamconf’ or ’clamconf –help’.
159
-
160
-## Output format
161
-
162
-### clamscan
163
-
164
-`clamscan` writes all regular program messages to **stdout** and errors/warnings to **stderr**. You can use the option `--stdout` to redirect all program messages to **stdout**. Warnings and error messages from `libclamav` are always printed to **stderr**. A typical output from `clamscan` looks like this:
165
-
166
-```bash
167
-    /tmp/test/removal-tool.exe: Worm.Sober FOUND
168
-    /tmp/test/md5.o: OK
169
-    /tmp/test/blob.c: OK
170
-    /tmp/test/message.c: OK
171
-    /tmp/test/error.hta: VBS.Inor.D FOUND
172
-```
173
-
174
-When a virus is found its name is printed between the `filename:` and `FOUND` strings. In case of archives the scanner depends on libclamav and only prints the first virus found within an archive:
175
-
176
-```bash
177
-    $ clamscan malware.zip
178
-    malware.zip: Worm.Mydoom.U FOUND
179
-```
180
-
181
-When using the –allmatch(-z) flag, clamscan may print multiple virus `FOUND` lines for archives and files.
182
-
183
-### clamd
184
-
185
-The output format of `clamd` is very similar to `clamscan`.
186
-
187
-```bash
188
-    $ telnet localhost 3310
189
-    Trying 127.0.0.1...
190
-    Connected to localhost.
191
-    Escape character is '^]'.
192
-    SCAN /home/zolw/test
193
-    /home/zolw/test/clam.exe: ClamAV-Test-File FOUND
194
-    Connection closed by foreign host.
195
-```
196
-
197
-In the **SCAN** mode it closes the connection when the first virus is found.
198
-
199
-```bash
200
-    SCAN /home/zolw/test/clam.zip
201
-    /home/zolw/test/clam.zip: ClamAV-Test-File FOUND
202
-```
203
-
204
-**CONTSCAN** and **MULTISCAN** don’t stop scanning in case a virus is found. Error messages are printed in the following format:
205
-
206
-```bash
207
-    SCAN /no/such/file
208
-    /no/such/file: Can't stat() the file. ERROR
209
-```
33
+Additionally, a tool called [`clamconf`](Usage/Configuration.md#clamconf) allows users to check the configurations used by each other tool, pulling information from the configuration files listed above, alongside other relevant information.
210 34
new file mode 100644
... ...
@@ -0,0 +1,126 @@
0
+# Configuration
1
+
2
+<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
3
+
4
+- [clamconf](#clamconf)
5
+- [clamd.conf](#clamdconf)
6
+	- [On-Access Scanning](#on-access-scanning)
7
+- [freshclam.conf](#freshclamconf)
8
+- [clamav-milter](#clamav-milter)
9
+
10
+<!-- /TOC -->
11
+
12
+## clamconf
13
+
14
+`clamconf` is a tool ClamAV provides for checking your entire system configuration, as it relates to your ClamAV installation. When run, it displays values used when configuring ClamAV at compilation time, important OS details, the contents (and validity) of both `clamd.conf` and `freshclam.conf`, along with other important engine, database, platform, and build information.
15
+
16
+It can also generate example configuration files for `clamd.conf` and `freshclam.conf`.
17
+
18
+To use `clamconf`, and see all the information it provides, simply run the following command:
19
+
20
+> $ clamconf
21
+
22
+For more detailed information on `clamconf`, run:
23
+
24
+> $ man clamdconf
25
+
26
+or
27
+
28
+> $ clamconf --help
29
+
30
+## clamd.conf
31
+
32
+Currently, ClamAV requires users edit their `clamd.conf.example` file before they can run the daemon. At a bare minimum, users will nee to comment out the line that reads "Example", else `clamd` will consider the configuration invalid, ala:
33
+
34
+<pre>
35
+  7 # Comment or remove the line below.
36
+  8 #Example
37
+  9
38
+</pre>
39
+
40
+You will also need to rename `clamd.conf.example` to `clamd.conf` via:
41
+
42
+> $ mv ./clamd.conf.example ./clamd.conf
43
+
44
+If you are setting up a simple, local `clamd` instance then some other configuration options of interests to you will be as follows:
45
+
46
+<pre>
47
+91 # Path to a local socket file the daemon will listen on.
48
+92 # Default: disabled (must be specified by a user)
49
+93 LocalSocket /tmp/clamd.socket
50
+
51
+...
52
+
53
+99 # Sets the permissions on the unix socket to the specified mode.
54
+100 # Default: disabled (socket is world accessible)
55
+101 LocalSocketMode 660
56
+</pre>
57
+
58
+Beyond that, `clamd.conf` is well commented and configuration should be straightforward.
59
+
60
+If needed, you can find out even more about the formatting and options available in `clamd.conf` with the command:
61
+
62
+> man clamd.conf
63
+
64
+### On-Access Scanning
65
+
66
+You can configure On-Access Scanning through `clamd.conf` (starting at *line 613* in `clamd.conf.example`) and read the [on-access](Usage.md#On-access-Scanning) section for On-Access Scanning usage details.
67
+
68
+## freshclam.conf
69
+
70
+`freshclam` is the automatic database update tool for Clam AntiVirus. It can be configured to work in two modes:
71
+
72
+- interactive - on demand from command line
73
+- daemon - silently in the background
74
+
75
+`freshclam` is an advanced tool: it supports scripted updates (instead of transferring the whole CVD file at each update it only transfers the differences between the latest and the current database via a special script), database version checks through DNS, proxy servers (with authentication), digital signatures and various error scenarios.
76
+
77
+**Quick test: run freshclam (as superuser) with no parameters and check the output.**
78
+
79
+> $ freshclam
80
+
81
+If everything is OK you may create the log file in /var/log (ensure the directory is owned either by *clamav* or whichever user `freshclam` will be running as):
82
+
83
+<pre>bash
84
+    # touch /var/log/freshclam.log
85
+    # chmod 600 /var/log/freshclam.log
86
+    # chown clamav /var/log/freshclam.log
87
+</pre>
88
+
89
+Now you *should* edit the configuration file `freshclam.conf` and point the *UpdateLogFile* directive to the log file. Finally, to run `freshclam` in the daemon mode, execute:
90
+
91
+<pre>bash
92
+    # freshclam -d
93
+</pre>
94
+
95
+The other way is to use the *cron* daemon. You have to add the following line to the *crontab* of **root** or **clamav** user:
96
+
97
+<pre>cron
98
+N * * * *   /usr/local/bin/freshclam --quiet
99
+</pre>
100
+
101
+to check for a new database every hour. **N should be a number between 3 and 57 of your choice. Please don’t choose any multiple of 10, because there are already too many clients using those time slots.** Proxy settings are only configurable via the configuration file and `freshclam` will require strict permission settings for the config file when `HTTPProxyPassword` is turned on.
102
+
103
+<pre>bash
104
+    HTTPProxyServer myproxyserver.com
105
+    HTTPProxyPort 1234
106
+    HTTPProxyUsername myusername
107
+    HTTPProxyPassword mypass
108
+</pre>
109
+
110
+## clamav-milter
111
+
112
+ClamAV includes a mail filtering tool called `clamav-milter`. This tool interfaces directly with `clamd`, and thus requires and a working `clamd` instance to run. However, `clamav-milter`'s configuration and log files are separate from that of `clamd`.
113
+
114
+Ensuring ClamAV compiles with `clamav-milter` must be done at configure time with the command:
115
+
116
+> $ ./configure [options] --enable-milter
117
+
118
+This requires having the milter library installed on your system. If *libmilter* is not installed, `./configure` will exit with this error message:
119
+
120
+<pre>bash
121
+        checking for mi_stop in -lmilter... no
122
+        configure: error: Cannot find libmilter
123
+</pre>
124
+
125
+While not necessarily *complicated*, setting up the `clamav-milter` is an involved process. Thus, we recommend consulting your MTA’s manual on how to best connect ClamAV with the `clamav-milter`.
0 126
new file mode 100644
... ...
@@ -0,0 +1,125 @@
0
+# Scanning
1
+<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
2
+
3
+- [Daemon](#daemon)
4
+	- [clamd](#clamd)
5
+	- [clamdscan](#clamdscan)
6
+	- [clamdtop](#clamdtop)
7
+	- [On-Access Scanning](#on-access-scanning)
8
+- [One-Time Scanning](#one-time-scanning)
9
+	- [clamscan](#clamscan)
10
+
11
+<!-- /TOC -->
12
+
13
+## Daemon
14
+
15
+### clamd
16
+
17
+`clamd` is a multi-threaded daemon that uses *libclamav* to scan files for viruses. Scanning behaviour can be fully configured to fit most needs by modifying `clamd.conf`.
18
+
19
+As `clamd` requires a virus signature database to run, we recommend setting up ClamAV's official signatures before running `clamd` using `freshclam`.
20
+
21
+The daemon works by listening for commands on the sockets specified in `clamd.conf`. Listening is supported over both unix local sockets and TCP sockets.
22
+
23
+**IMPORTANT:** `clamd` does not currently protect or authenticate traffic coming over the TCP socket, meaning it will accept any and all of the following commands listed from *any* source. Thus, we strongly recommend following best networking practices when setting up your `clamd` instance. I.e. don't expose your TCP socket to the Internet.
24
+
25
+Here is a quick list of the commands accepted by `clamd` over the socket.
26
+
27
+- `PING`
28
+- `VERSION`
29
+- `RELOAD`
30
+- `SHUTDOWN`
31
+- `SCAN` *file/directory*
32
+- `RAWSCAN` *file/directory*
33
+- `CONTSCAN` *file/directory*
34
+- `MULTISCAN` *file/directory*
35
+- `ALLMATCHSCAN` *file/directory*
36
+- `INSTREAM`
37
+- `FILDES`
38
+- `STATS`
39
+- `IDSESSION, END`
40
+
41
+As with most ClamAV tools, you can find out more about these by invoking the command:
42
+
43
+> $ man clamd
44
+
45
+The daemon also handles the following signals as so:
46
+
47
+- `SIGTERM` - perform a clean exit
48
+- `SIGHUP` - reopen the log file
49
+- `SIGUSR2` - reload the database
50
+
51
+It should be noted that `clamd` should not be started using the shell operator `&` or other external tools which would start it as a background process. Instead, you should run `clamd` which will load the database and then daemonize itself (unless you have specified otherwise in `clamd.conf`). After that, clamd is ready to accept connections and perform file scanning.
52
+
53
+Once you have set up your configuration to your liking, and understand how you will be sending commands to the daemon, running `clamd` itself is simple. Simply execute the command:
54
+
55
+> $ clamd
56
+
57
+### clamdscan
58
+
59
+`clamdscan` is a `clamd` client, which greatly simplifies the task of scanning files with `clamd`. It sends commands to the `clamd` daemon across the socket specified in `clamd.conf` and generates a scan report after all requested scanning has been completed by the daemon.
60
+
61
+Thus, **to run `clamdscan`, you must have an instance of `clamd` already running** as well.
62
+
63
+Please keep in mind, that as a simple scanning client, `clamdscan` cannot change scanning and engine configurations. These are tied to the `clamd` instance and the configuration you set up in `clamd.conf`. Therefore, while `clamdscan` will accept many of the same commands as its sister tool `clamscan`, it will simply ignore most of them as (by design) no mechanism exists to make ClamAV engine configuration changes over the `clamd` socket.
64
+
65
+Again, running `clamdscan`, once you have a working `clamd` instance, is simple:
66
+
67
+> $ clamdscan [*options*] [*file/directory/-*]
68
+
69
+### clamdtop
70
+
71
+`clamdtop` is a tool to monitor one or multiple instances of `clamd`. It has a colorized *ncurses* interface, which shows each job queued, memory usage, and information about the loaded signature database for the connected `clamd` instance(s). By default it will attempt to connect to the local `clamd` as defined in `clamd.conf`. However, you can specify other `clamd` instances at the command line.
72
+
73
+To learn more, use the commands
74
+
75
+> $ man clamdtop
76
+
77
+or
78
+
79
+> $ clamdtop --help
80
+
81
+### On-Access Scanning
82
+
83
+To be updated.
84
+
85
+## One-Time Scanning
86
+
87
+### clamscan
88
+
89
+`clamscan` is a command line tool which uses *libclamav* to scan files and/or directories for viruses. Unlike `clamdscan`, `clamscan` does *not* require a running `clamd` instance to function. Instead, `clamscan` will create a new engine and load in the virus database each time it is run. It will then scan the files and/or directories specified at the command line, create a scan report, and exit.
90
+
91
+By default, when loading databases, `clamscan` will check the location to which `freshclam` installed the virus database signatures. This behaviour, along with a myriad of other scanning and engine controls, can be modified by providing flags and other options at the command line.
92
+
93
+There are too many options to list all of them here. So we'll only cover a few common and more interesting ones:
94
+
95
+- `--log=FILE` - save scan report to FILE
96
+- `--database=FILE/DIR` - load virus database from FILE or load all supported db files from DIR
97
+- `--official-db-only[=yes/no(*)]` - only load official signatures
98
+- `-max-filesize=#n` - files larger than this will be skipped and assumed clean
99
+- `--max-scansize=#n` - the maximum amount of data to scan for each container file
100
+- `--leave-temps[=yes/no(*)]`- do not remove temporary files
101
+- `--file-list=FILE` - scan files from FILE
102
+- `--quiet` - only output error messages
103
+- `--bell` - sound bell on virus detection
104
+- `--cross-fs[=yes(*)/no]` - scan files and directories on other filesystems
105
+- `--move=DIRECTORY` - move infected files into DIRECTORY
106
+- `--copy=DIRECTORY` - copy infected files into DIRECTORY
107
+- `--bytecode-timeout=N` - set bytecode timeout (in milliseconds)
108
+- `--heuristic-alerts[=yes(*)/no]` - toggles heuristic alerts
109
+- `--alert-encrypted[=yes/no(*)]` - alert on encrypted archives and documents
110
+- `--nocerts` - disable authenticode certificate chain verification in PE files
111
+- `--disable-cache` - disable caching and cache checks for hash sums of scanned files
112
+
113
+To learn more about the options available when using `clamscan` please reference:
114
+
115
+> $ man clamscan
116
+
117
+and
118
+
119
+> $ clamscan --help
120
+
121
+
122
+Otherwise, the general usage of clamscan is:
123
+
124
+> clamscan [options] [file/directory/-]
0 125
new file mode 100644
... ...
@@ -0,0 +1,70 @@
0
+# Signature Testing and Management
1
+
2
+<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
3
+
4
+- [freshclam](#freshclam)
5
+- [sigtool](#sigtool)
6
+- [clambc](#clambc)
7
+
8
+<!-- /TOC -->
9
+
10
+## freshclam
11
+
12
+The tool `freshclam` is used to download and update ClamAV’s official virus signature databases. While easy to use in its base configuration, `freshclam` does require a working `freshclam.conf` configuration file to run (the location of which can be passed in via command line if the default search location does not fit your needs).
13
+
14
+Once you have a valid configuration file, you can invoke freshclam with the following command:
15
+
16
+> $ freshclam
17
+
18
+By default, `freshclam` will then attempt to connect to ClamAV's virus signature database distribution network. If no databases exist in the directory specified, `freshclam` will do a fresh download of the requested databases. Otherwise, `freshclam` will attempt to update existing databases, pairing them against downloaded cdiffs. If a database is found to be corrupted, it is not updated and instead replaced with a fresh download.
19
+
20
+Of course, all this behaviour--and more--can be changed to suit your needs by modifying `freshclam.conf` and/or using various command line options.
21
+
22
+You can find more information about freshclam with the commands:
23
+
24
+> $ man freshclam
25
+
26
+and
27
+
28
+> $ freshclam --help
29
+
30
+## sigtool
31
+
32
+ClamAV provides `sigtool` as a command-line testing tool for assisting users in their efforts creating and working with virus signatures. While sigtool has many uses--including crafting signatures--of particular note, is sigtool's ability to help users and analysts in determining if a file detected by *libclamav*'s virus signatures is a false positive.
33
+
34
+This can be accomplished by using the command:
35
+
36
+> $ sigtool --unpack=FILE
37
+
38
+Where FILE points to your virus signature databases. Then, once `sigtool` has finished unpacking the database into the directory from which you ran the command, you can search for the offending signature name (provided either by [`clamscan`](./Scanning.md#clamscan) scan reports or [`clamd`](./Scanning.md#clamd) logs). As an example:
39
+
40
+> $ grep "Win.Test.EICAR" ./*
41
+
42
+Or, do all that in one step with:
43
+
44
+> $ sigtool --find="Win.Test.EICAR"
45
+
46
+This should give you the offending signature(s) in question, which can then be included as part of your [false positive report](https://www.clamav.net/reports/fp).
47
+
48
+To learn more in depth information on how `sigtool` can be used to help create virus signatures and work with malicious (and non-malicious) files please reference the many online tutorials on the topic.
49
+
50
+Otherwise, information on available sigtool functions can be easily referenced with:
51
+
52
+> $ sigtool --help
53
+
54
+and
55
+
56
+> $ man sigtool
57
+
58
+
59
+## clambc
60
+
61
+`clambc` is Clam Anti-Virus’ bytecode signature testing tool. It can be used to test newly crafted bytecode signatures or to help verify existing bytecode is executing against a sample as expected.
62
+
63
+For more detailed help, please use:
64
+
65
+> $ man clambc
66
+
67
+or
68
+
69
+> $ clambc --help