]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/main/verify.tex
Merge branch 'Branch-5.2' of bsweb:docs into Branch-5.2
[bacula/docs] / docs / manuals / en / main / verify.tex
1 %%
2 %%
3
4 % TODO: this chapter name is confusing ...  maybe rename to
5 % TODO:  "File Integrity Checking with Bacula"?
6 \chapter{Using Bacula to Improve Computer Security}
7 \label{VerifyChapter}
8 \index[general]{Security!Using Bacula to Improve Computer }
9 \index[general]{Using Bacula to Improve Computer Security }
10
11 % TODO: only those two digest algorithms?
12 % TODO: can it use multiple at a time? (record and use both SHA1 and MD5?)
13 Since Bacula maintains a catalog of files, their attributes, and either SHA1
14 or MD5 signatures, it can be an ideal tool for improving computer security.
15 This is done by making a snapshot of your system files with a {\bf Verify} Job
16 and then checking the current state of your system against the snapshot, on a
17 regular basis (e.g. nightly). 
18
19 The first step is to set up a {\bf Verify} Job and to run it with: 
20
21 \footnotesize
22 \begin{verbatim}
23 Level = InitCatalog
24 \end{verbatim}
25 \normalsize
26
27 The {\bf InitCatalog} level tells {\bf Bacula} simply to get the information on
28 the specified files and to put it into the catalog. That is your database is
29 initialized and no comparison is done. The {\bf InitCatalog} is normally run
30 one time manually. 
31
32 Thereafter, you will run a Verify Job on a daily (or whatever) basis with: 
33
34 \footnotesize
35 \begin{verbatim}
36 Level = Catalog
37 \end{verbatim}
38 \normalsize
39
40 The {\bf Level = Catalog} level tells Bacula to compare the current state of
41 the files on the Client to the last {\bf InitCatalog} that is stored in the
42 catalog and to report any differences. See the example below for the format of
43 the output. 
44
45 You decide what files you want to form your "snapshot" by specifying them in
46 a {\bf FileSet} resource, and normally, they will be system files that do not
47 change, or that only certain features change. 
48
49 Then you decide what attributes of each file you want compared by specifying
50 comparison options on the {\bf Include} statements that you use in the {\bf
51 FileSet} resource of your {\bf Catalog} Jobs. 
52
53 \section{The Details}
54 \index[general]{Details }
55
56 In the discussion that follows, we will make reference to the Verify
57 Configuration Example that is included below in the {\bf A Verify
58 Configuration Example} section. You might want to look it over now to get an
59 idea of what it does. 
60
61 The main elements consist of adding a schedule, which will normally be run
62 daily, or perhaps more often. This is provided by the {\bf VerifyCycle}
63 Schedule, which runs at 5:05 in the morning every day. 
64
65 Then you must define a Job, much as is done below. We recommend that the Job
66 name contain the name of your machine as well as the word {\bf Verify} or {\bf
67 Check}. In our example, we named it {\bf MatouVerify}. This will permit you to
68 easily identify your job when running it from the Console. 
69
70 You will notice that most records of the Job are quite standard, but that the
71 {\bf FileSet} resource contains {\bf verify=pins1} option in addition to the
72 standard {\bf signature=SHA1} option. If you don't want SHA1 signature
73 comparison, and we cannot imagine why not, you can drop the {\bf
74 signature=SHA1} and none will be computed nor stored in the catalog. Or
75 alternatively, you can use {\bf verify=pins5} and {\bf signature=MD5}, which
76 will use the MD5 hash algorithm. The MD5 hash computes faster than SHA1, but
77 is cryptographically less secure. 
78
79 The {\bf verify=pins1} is ignored during the {\bf InitCatalog} Job, but is
80 used during the subsequent {\bf Catalog} Jobs to specify what attributes of
81 the files should be compared to those found in the catalog. {\bf pins1} is a
82 reasonable set to begin with, but you may want to look at the details of these
83 and other options. They can be found in the 
84 \ilink{FileSet Resource}{FileSetResource} section of this manual.
85 Briefly, however, the {\bf p} of the {\bf pins1} tells Verify to compare the
86 permissions bits, the {\bf i} is to compare inodes, the {\bf n} causes
87 comparison of the number of links, the {\bf s} compares the file size, and the
88 {\bf 1} compares the SHA1 checksums (this requires the {\bf signature=SHA1}
89 option to have been set also). 
90
91 You must also specify the {\bf Client} and the {\bf Catalog} resources for
92 your Verify job, but you probably already have them created for your client
93 and do not need to recreate them, they are included in the example below for
94 completeness. 
95
96 As mentioned above, you will need to have a {\bf FileSet} resource for the
97 Verify job, which will have the additional {\bf verify=pins1} option. You will
98 want to take some care in defining the list of files to be included in your
99 {\bf FileSet}. Basically, you will want to include all system (or other) files
100 that should not change on your system. If you select files, such as log files
101 or mail files, which are constantly changing, your automatic Verify job will
102 be constantly finding differences. The objective in forming the FileSet is to
103 choose all unchanging important system files. Then if any of those files has
104 changed, you will be notified, and you can determine if it changed because you
105 loaded a new package, or because someone has broken into your computer and
106 modified your files. The example below shows a list of files that I use on my
107 Red Hat 7.3 system. Since I didn't spend a lot of time working on it, it
108 probably is missing a few important files (if you find one, please send it to
109 me). On the other hand, as long as I don't load any new packages, none of
110 these files change during normal operation of the system. 
111
112 \section{Running the Verify}
113 \index[general]{Running the Verify }
114 \index[general]{Verify!Running the }
115
116 The first thing you will want to do is to run an {\bf InitCatalog} level
117 Verify Job. This will initialize the catalog to contain the file information
118 that will later be used as a basis for comparisons with the actual file
119 system, thus allowing you to detect any changes (and possible intrusions into
120 your system). 
121
122 The easiest way to run the {\bf InitCatalog} is manually with the console
123 program by simply entering {\bf run}. You will be presented with a list of
124 Jobs that can be run, and you will choose the one that corresponds to your
125 Verify Job, {\bf MatouVerify} in this example. 
126
127 \footnotesize
128 \begin{verbatim}
129 The defined Job resources are:
130      1: MatouVerify
131      2: kernsrestore
132      3: Filetest
133      4: kernsave
134 Select Job resource (1-4): 1
135 \end{verbatim}
136 \normalsize
137
138 Next, the console program will show you the basic parameters of the Job and
139 ask you: 
140
141 \footnotesize
142 \begin{verbatim}
143 Run Verify job
144 JobName:  MatouVerify
145 FileSet:  Verify Set
146 Level:    Catalog
147 Client:   MatouVerify
148 Storage:  DLTDrive
149 Verify Job:  
150 Verify List: /tmp/regress/working/MatouVerify.bsr
151 OK to run? (yes/mod/no): mod
152 \end{verbatim}
153 \normalsize
154
155 Here, you want to respond {\bf mod} to modify the parameters because the Level
156 is by default set to {\bf Catalog} and we want to run an {\bf InitCatalog}
157 Job. After responding {\bf mod}, the console will ask: 
158
159 \footnotesize
160 \begin{verbatim}
161 Parameters to modify:
162      1: Level
163      2: Storage
164      3: Job
165      4: FileSet
166      5: Client
167      6: When
168      7: Priority
169      8: Pool
170      9: Verify Job
171 Select parameter to modify (1-5): 1
172 \end{verbatim}
173 \normalsize
174
175 you should select number 2 to modify the {\bf Level}, and it will display: 
176
177 \footnotesize
178 \begin{verbatim}
179 Levels:
180      1: Initialize Catalog
181      2: Verify Catalog
182      3: Verify Volume to Catalog
183      4: Verify Disk to Catalog
184      5: Verify Volume Data (not yet implemented)
185 Select level (1-4): 1
186 \end{verbatim}
187 \normalsize
188
189 Choose item 1, and you will see the final display: 
190
191 \footnotesize
192 \begin{verbatim}
193 Run Verify job
194 JobName:  MatouVerify
195 FileSet:  Verify Set
196 Level:    Initcatalog
197 Client:   MatouVerify
198 Storage:  DLTDrive
199 Verify Job:  
200 Verify List: /tmp/regress/working/MatouVerify.bsr
201 OK to run? (yes/mod/no): yes
202 \end{verbatim}
203 \normalsize
204
205 at which point you respond {\bf yes}, and the Job will begin. 
206
207 Thereafter the Job will automatically start according to the schedule you
208 have defined. If you wish to immediately verify it, you can simply run a
209 Verify {\bf Catalog} which will be the default. No differences should be
210 found. 
211
212 To use a previous job, you can add \texttt{jobid=xxx} option in run command
213 line. It will run the Verify job against the specified job.
214
215 \begin{verbatim}
216 *run jobid=1 job=MatouVerify
217 Run Verify job
218 JobName:     MatouVerify
219 Level:       Catalog
220 Client:      127.0.0.1-fd
221 FileSet:     Full Set
222 Pool:        Default (From Job resource)
223 Storage:     File (From Job resource)
224 Verify Job:  MatouVerify.2010-09-08_15.33.33_03
225 Verify List: /tmp/regress/working/MatouVerify.bsr
226 When:        2010-09-08 15:35:32
227 Priority:    10
228 OK to run? (yes/mod/no): 
229 \end{verbatim}
230
231 \section{What To Do When Differences Are Found}
232 \index[general]{What To Do When Differences Are Found }
233 \index[general]{Found!What To Do When Differences Are }
234
235 If you have setup your messages correctly, you should be notified if there are
236 any differences and exactly what they are. For example, below is the email
237 received after doing an update of OpenSSH: 
238
239 \footnotesize
240 \begin{verbatim}
241 HeadMan: Start Verify JobId 83 Job=RufusVerify.2002-06-25.21:41:05
242 HeadMan: Verifying against Init JobId 70 run 2002-06-21 18:58:51
243 HeadMan: File: /etc/pam.d/sshd
244 HeadMan:       st_ino   differ. Cat: 4674b File: 46765
245 HeadMan: File: /etc/rc.d/init.d/sshd
246 HeadMan:       st_ino   differ. Cat: 56230 File: 56231
247 HeadMan: File: /etc/ssh/ssh_config
248 HeadMan:       st_ino   differ. Cat: 81317 File: 8131b
249 HeadMan:       st_size  differ. Cat: 1202 File: 1297
250 HeadMan:       SHA1 differs.
251 HeadMan: File: /etc/ssh/sshd_config
252 HeadMan:       st_ino   differ. Cat: 81398 File: 81325
253 HeadMan:       st_size  differ. Cat: 1182 File: 1579
254 HeadMan:       SHA1 differs.
255 HeadMan: File: /etc/ssh/ssh_config.rpmnew
256 HeadMan:       st_ino   differ. Cat: 812dd File: 812b3
257 HeadMan:       st_size  differ. Cat: 1167 File: 1114
258 HeadMan:       SHA1 differs.
259 HeadMan: File: /etc/ssh/sshd_config.rpmnew
260 HeadMan:       st_ino   differ. Cat: 81397 File: 812dd
261 HeadMan:       st_size  differ. Cat: 2528 File: 2407
262 HeadMan:       SHA1 differs.
263 HeadMan: File: /etc/ssh/moduli
264 HeadMan:       st_ino   differ. Cat: 812b3 File: 812ab
265 HeadMan: File: /usr/bin/scp
266 HeadMan:       st_ino   differ. Cat: 5e07e File: 5e343
267 HeadMan:       st_size  differ. Cat: 26728 File: 26952
268 HeadMan:       SHA1 differs.
269 HeadMan: File: /usr/bin/ssh-keygen
270 HeadMan:       st_ino   differ. Cat: 5df1d File: 5e07e
271 HeadMan:       st_size  differ. Cat: 80488 File: 84648
272 HeadMan:       SHA1 differs.
273 HeadMan: File: /usr/bin/sftp
274 HeadMan:       st_ino   differ. Cat: 5e2e8 File: 5df1d
275 HeadMan:       st_size  differ. Cat: 46952 File: 46984
276 HeadMan:       SHA1 differs.
277 HeadMan: File: /usr/bin/slogin
278 HeadMan:       st_ino   differ. Cat: 5e359 File: 5e2e8
279 HeadMan: File: /usr/bin/ssh
280 HeadMan:       st_mode  differ. Cat: 89ed File: 81ed
281 HeadMan:       st_ino   differ. Cat: 5e35a File: 5e359
282 HeadMan:       st_size  differ. Cat: 219932 File: 234440
283 HeadMan:       SHA1 differs.
284 HeadMan: File: /usr/bin/ssh-add
285 HeadMan:       st_ino   differ. Cat: 5e35b File: 5e35a
286 HeadMan:       st_size  differ. Cat: 76328 File: 81448
287 HeadMan:       SHA1 differs.
288 HeadMan: File: /usr/bin/ssh-agent
289 HeadMan:       st_ino   differ. Cat: 5e35c File: 5e35b
290 HeadMan:       st_size  differ. Cat: 43208 File: 47368
291 HeadMan:       SHA1 differs.
292 HeadMan: File: /usr/bin/ssh-keyscan
293 HeadMan:       st_ino   differ. Cat: 5e35d File: 5e96a
294 HeadMan:       st_size  differ. Cat: 139272 File: 151560
295 HeadMan:       SHA1 differs.
296 HeadMan: 25-Jun-2002 21:41
297 JobId:                  83
298 Job:                    RufusVerify.2002-06-25.21:41:05
299 FileSet:                Verify Set
300 Verify Level:           Catalog
301 Client:                 RufusVerify
302 Start time:             25-Jun-2002 21:41
303 End time:               25-Jun-2002 21:41
304 Files Examined:         4,258
305 Termination:            Verify Differences
306 \end{verbatim}
307 \normalsize
308
309 At this point, it was obvious that these files were modified during
310 installation of the RPMs. If you want to be super safe, you should run a {\bf
311 Verify Level=Catalog} immediately before installing new software to verify
312 that there are no differences, then run a {\bf Verify Level=InitCatalog}
313 immediately after the installation. 
314
315 To keep the above email from being sent every night when the Verify Job runs,
316 we simply re-run the Verify Job setting the level to {\bf InitCatalog} (as we
317 did above in the very beginning). This will re-establish the current state of
318 the system as your new basis for future comparisons. Take care that you don't
319 do an {\bf InitCatalog} after someone has placed a Trojan horse on your
320 system! 
321
322 If you have included in your {\bf FileSet} a file that is changed by the
323 normal operation of your system, you will get false matches, and you will need
324 to modify the {\bf FileSet} to exclude that file (or not to Include it), and
325 then re-run the {\bf InitCatalog}. 
326
327 The FileSet that is shown below is what I use on my Red Hat 7.3 system. With a
328 bit more thought, you can probably add quite a number of additional files that
329 should be monitored. 
330
331 \section{A Verify Configuration Example}
332 \index[general]{Verify Configuration Example }
333 \index[general]{Example!Verify Configuration }
334
335 \footnotesize
336 \begin{verbatim}
337 Schedule {
338   Name = "VerifyCycle"
339   Run = Level=Catalog sun-sat at 5:05
340 }
341 Job {
342   Name = "MatouVerify"
343   Type = Verify
344   Level = Catalog                     # default level
345   Client = MatouVerify
346   FileSet = "Verify Set"
347   Messages = Standard
348   Storage = DLTDrive
349   Pool = Default
350   Schedule = "VerifyCycle"
351 }
352 #
353 # The list of files in this FileSet should be carefully
354 # chosen. This is a good starting point.
355 #
356 FileSet {
357   Name = "Verify Set"
358   Include {
359     Options {
360       verify=pins1
361       signature=SHA1
362     }
363     File = /boot
364     File = /bin
365     File = /sbin
366     File = /usr/bin
367     File = /lib
368     File = /root/.ssh
369     File = /home/kern/.ssh
370     File = /var/named
371     File = /etc/sysconfig
372     File = /etc/ssh
373     File = /etc/security
374     File = /etc/exports
375     File = /etc/rc.d/init.d
376     File = /etc/sendmail.cf
377     File = /etc/sysctl.conf
378     File = /etc/services
379     File = /etc/xinetd.d
380     File = /etc/hosts.allow
381     File = /etc/hosts.deny
382     File = /etc/hosts
383     File = /etc/modules.conf
384     File = /etc/named.conf
385     File = /etc/pam.d
386     File = /etc/resolv.conf
387   }
388   Exclude = { }
389 P
390 Client {
391   Name = MatouVerify
392   Address = lmatou
393   Catalog = Bacula
394   Password = ""
395   File Retention = 80d                # 80 days
396   Job Retention = 1y                  # one year
397   AutoPrune = yes                     # Prune expired Jobs/Files
398 }
399 Catalog {
400   Name = Bacula
401   dbname = verify; user = bacula; password = ""
402 }
403 \end{verbatim}
404 \normalsize