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