source: trunk/man/samhain.8@ 1

Last change on this file since 1 was 1, checked in by katerina, 19 years ago

Initial import

File size: 19.4 KB
Line 
1.TH SAMHAIN 8 "07 August 2004" "" "Samhain manual"
2.SH NAME
3samhain \- check file integrity
4.SH SYNOPSIS
5.SS "INITIALIZING, UPDATING, AND CHECKING"
6.PP
7
8.B samhain
9{
10.I \-t init|\-\-set\-checksum\-test=init
11} [\-\-init2stdout] [\-r DEPTH|\-\-recursion=DEPTH] [log-options]
12
13.B samhain
14{
15.I \-t update|\-\-set\-checksum\-test=update
16} [\-r DEPTH|\-\-recursion=DEPTH] [log-options]
17
18.B samhain
19{
20.I \-t check|\-\-set\-checksum\-test=check
21} [\-D | \-\-daemon | \-\-foreground] [\-\-forever] [\-r DEPTH,\-\-recursion=DEPTH] [log-options]
22
23.SS "LISTING THE DATABASE"
24.PP
25
26.B samhain
27[\-a | \-\-full\-detail]
28[\-\-delimited]
29\-d
30.IR file |
31.RI \-\-list\-database= file
32
33.SS "VERIFYING AN AUDIT TRAIL"
34.PP
35
36.B samhain
37[\-j | \-\-just\-list]
38\-L
39.IR logfile |
40.RI \-\-verify\-log= logfile
41
42.B samhain
43\-M
44.IR mailbox |
45.RI \-\-verify\-mail= mailbox
46
47
48.SS "MISCELLANEOUS"
49.PP
50
51.B samhain
52\-H
53.I string
54|
55.RI \-\-hash\-string= string
56
57.B samhain
58\-c | \-\-copyright
59
60.B samhain
61\-h | \-\-help
62
63.B samhain
64\-V key@/path/to/executable | \-\-add\-key=key@/path/to/executable
65
66.SS "SERVER STARTUP"
67.PP
68
69.B yule
70[\-q | \-\-qualified]
71[
72.RI \-\-chroot= chrootdir ]
73[\-D | \-\-daemon | \-\-foreground]
74[log-options]
75
76.SS "SERVER MISCELLANEOUS"
77.PP
78
79.B yule
80[\-P
81.I password
82|
83.RI \-\-password= password ]
84
85.B yule
86[\-G | \-\-gen-password]
87
88.SS "LOG OPTIONS"
89.PP
90
91[\-s
92.I threshold
93|
94.RI \-\-set\-syslog\-severity= threshold ]
95[\-l
96.I threshold
97|
98.RI \-\-set\-log\-severity= threshold ]
99[\-m
100.I threshold
101|
102.RI \-\-set\-mail\-severity= threshold ]
103[\-e
104.I threshold
105|
106.RI \-\-set\-export\-severity= threshold ]
107[\-p
108.I threshold
109|
110.RI \-\-set\-print\-severity= threshold ]
111[\-x
112.I threshold
113|
114.RI \-\-set\-external\-severity= threshold ]
115[
116.RI \-\-set\-prelude\-severity= threshold ]
117[
118.RI \-\-set\-database\-severity= threshold ]
119[
120.RI \-\-enable\-trace ]
121[
122.RI \-\-trace\-logfile= tracefile ]
123
124
125
126.SH WARNING
127.PP
128The information in this man page is not always up to date.
129The authoritative documentation is the user manual.
130
131.SH DESCRIPTION
132.PP
133.B samhain
134is a file integrity / intrusion detection system both for single hosts
135and networks.
136It consists of a monitoring application
137.RB ( samhain )
138running on
139individual hosts, and (optionally) a central log server
140.RB ( yule ).
141Currently, samhain can monitor the
142integrity of files/directories, and (optionally) also
143check for kernel rootkits
144(Linux and FreeBSD only), search the disk for SUID/SGID,
145and watch for login/logout events.
146.PP
147.B samhain/yule
148can log by email, to a tamper-resistant, signed log file,
149to syslog, to the Prelude IDS, to a MySQL/PostgreSQL/Oracle database,
150and/or to stdout
151.RI ( /dev/console
152if run as daemon).
153.B samhain/yule
154can run as a daemon, and can use a time server instead of the host's
155system clock. Most of the functionality is defined by a
156configuration file that is read at startup.
157.PP
158Most options of these usually would be set in the configuration file.
159Options given on the command line will override
160those in the configuration file.
161
162.SS "OPTIONS FOR INITIALIZING, UPDATING, AND CHECKING"
163.PP
164
165.B samhain
166.I "\-t init, \-\-set\-checksum-test=init"
167.RI [ options ]
168
169Initialize the database of file signatures. The path to the
170database is compiled in, and initializing will
171.B append
172to the respective file (or create it, if it does not exist).
173.B "It is ok to append to e.g. a JPEG image, but it is an error"
174.B "to append to an already existing file signature database."
175.PP
176.TP
177[\-\-init2stdout]
178Write the database to stdout.
179.TP
180[\-r DEPTH|\-\-recursion=DEPTH]
181Set the (global) recursion depth.
182
183.PP
184.B samhain
185.I "\-t update, \-\-set\-checksum-test=update"
186.RI [ options ]
187
188Update the database of file signatures. The path to the
189database is compiled in, and updating will
190.B overwrite
191the database, starting from the start of the database (which may not be
192identical to the start of the file \- see above).
193.PP
194.TP
195[\-r DEPTH|\-\-recursion=DEPTH]
196Set the (global) recursion depth.
197
198.PP
199.B samhain
200.I "\-t check, \-\-set\-checksum-test=check"
201.RI [ options ]
202
203Check the filesystem against the database of file signatures.
204The path to the database is compiled in.
205.PP
206.TP
207[\-r DEPTH|\-\-recursion=DEPTH]
208Set the (global) recursion depth.
209.TP
210[\-D|\-\-daemon]
211Run as daemon. File checks are performed as specified by the timing
212options in the configuration file.
213.TP
214[\-\-foreground]
215Run in the foreground. This will cause samhain to exit after the file check,
216unless the option
217.I "\-\-forever"
218is used.
219.TP
220[\-\-forever]
221If not running as daemon, do not exit after finishing the check, but
222loop forever, and perform checks according to the timing options in the
223configuration file.
224
225.SS "OPTIONS FOR LISTING THE DATABASE"
226.PP
227
228.B samhain
229[\-a | \-\-full\-detail]
230[\-\-delimited]
231\-d
232.IR file |
233.RI \-\-list\-database= file
234
235List the entries in the file signature database in a
236.B ls \-l
237like format.
238.PP
239.TP
240[\-a | \-\-full\-detail]
241List all informations for each file, not only those you would get
242with ls \-l.
243.TP
244[\-\-delimited]
245List all informations for each file, in a comma-separated format.
246
247.SS "OPTIONS TO VERIFY AN AUDIT TRAIL"
248.PP
249
250These options will only work, if the executable used for verifying the
251audit trail is compiled with the same \-\-enable\-base=... option as the
252executable of the reporting process.
253
254.B samhain
255[\-j | \-\-just\-list]
256\-L
257.IR logfile |
258.RI \-\-verify\-log= logfile
259
260Verify the integrity of a signed logfile. The signing key is
261auto\-generated on startup, and sent by email.
262.B samhain
263will ask for the key. Instead of entering the key, you can also enter
264the path to the mailbox holding the respective email message.
265.PP
266.TP
267[\-j | \-\-just\-list]
268Just list the logfile, do not verify it. This option must come
269.BR first .
270It is mainly intended for listing the content of an obfuscated logfile, if
271.B samhain
272is compiled with the
273.B stealth
274option.
275
276.B samhain
277\-M
278.IR mailbox |
279.RI \-\-verify\-mail= mailbox
280
281Verify the integrity of the email reports from samhain. All reports must be
282in the same file.
283
284.SS "MISCELLANEOUS OPTIONS"
285.PP
286
287.B samhain
288\-H
289.I string
290|
291.RI \-\-hash\-string= string
292
293Compute the TIGER192 checksum of a string. If the string starts with
294a '/', it is considered as a pathname, and the checksum of the corresponding
295file will be computed.
296
297.B samhain
298\-c | \-\-copyright
299
300Print the copyright statement.
301
302.B samhain
303\-h | \-\-help
304
305Print supported options (depending on compilation options).
306
307.B samhain
308\-V key@/path/to/executable | \-\-add\-key=key@/path/to/executable
309
310See the section "SECURITY" below.
311
312.SS "SERVER STARTUP OPTIONS"
313.PP
314
315.B yule
316[\-q | \-\-qualified]
317[
318.RI \-\-chroot= chrootdir ]
319[\-D | \-\-daemon | \-\-foreground]
320[log-options]
321
322Start the server, which is named
323.B yule
324by default. If the server is started with superuser privileges,
325it will drop them after startup.
326.PP
327.TP
328[\-q | \-\-qualified]
329Log client hostnames with fully qualified path. The default is to
330log only the leftmost domain label (i.e. the hostname).
331.TP
332[
333.RI \-\-chroot= chrootdir ]
334Chroot to the listed directory after startup.
335.TP
336[\-D | \-\-daemon]
337Run as daemon.
338.TP
339[\-\-foreground]
340Run in the foreground.
341
342
343.SS "MISCELLANEOUS SERVER OPTIONS"
344.PP
345
346.B yule
347[\-G | \-\-gen-password]
348
349Generate a random 8\-byte password and print it out in hexadecimal notation.
350
351
352.B yule
353[\-P
354.I password
355|
356.RI \-\-password= password ]
357
358Use the given
359.I password
360and generate an entry suitable for the [Clients] section of the
361configuration file.
362
363.SS "LOGGING OPTIONS"
364.PP
365
366Depending on the compilation options, some logging facilities may not
367be available in your executable.
368.PP
369.TP
370.I "\-s threshold, \-\-set\-syslog\-severity=threshold"
371Set the threshold for logging events via syslogd(8).
372Possible values are
373.IR debug ,
374.IR info ,
375.IR notice ,
376.IR warn ,
377.IR mark ,
378.IR err ,
379.IR crit ,
380.IR alert ,
381and
382.IR none .
383By default, everything equal to and above the threshold will be logged.
384Time stamps have the priority
385.IR warn ,
386system\-level errors have the priority
387.IR err ,
388and important start\-up messages the priority
389.IR alert .
390The signature key for the log file will never be logged to syslog or the
391log file itself.
392.TP
393.I "\-l threshold, \-\-set\-log\-severity=threshold"
394Set the threshold for logging events to the log file.
395.TP
396.I "\-m threshold, \-\-set\-mail\-severity=threshold"
397Set the threshold for logging events via e\-mail.
398.TP
399.I "\-e threshold, \-\-set\-export\-severity=threshold"
400Set the threshold for forwarding events via TCP to a log server.
401.TP
402.I "\-x threshold, \-\-set\-extern\-severity=threshold"
403Set the threshold for calling external logging programs/scripts (if any are
404defined in the configuration file).
405.TP
406.I "\-p threshold, \-\-set\-print\-severity=threshold"
407Set the threshold for logging events to stdout.
408If
409.B samhain
410runs as a daemon, this is redirected to /dev/console.
411.TP
412.I "\-\-set\-prelude\-severity=threshold"
413Set the threshold for logging events to the Prelude IDS.
414.TP
415.I "\-\-set\-database\-severity=threshold"
416Set the threshold for logging events to the MySQL/PostgreSQL/Oracle
417database.
418
419
420
421.SH SIGNALS
422.TP
423.I SIGUSR1
424Switch on/off maximum verbosity for console output.
425.TP
426.I SIGUSR2
427Suspend/continue the process, and
428(on suspend) send a message
429to the server. This message has the same priority as timestamps.
430This signal
431allows to run
432.I samhain -t init -e none
433on the client
434to regenerate the database, with download of the configuration file
435from the server, while the daemon is suspended (normally you would get
436errors because of concurrent access to the server by two processes from
437the
438.IR "same host" ")."
439.TP
440.I SIGHUP
441Reread the configuration file.
442.TP
443.I SIGTERM
444Terminate.
445.TP
446.I SIGQUIT
447Terminate after processing all pending requests from clients.
448.TP
449.I SIGABRT
450Unlock the log file, pause for three seconds, then proceed,
451eventually re-locking the log file and starting a fresh audit trail
452on next access.
453.TP
454.I SIGTTOU
455Force a file check (only client/standalone, and only in daemon mode).
456
457
458.SH DATABASE
459The database (default name
460.IR samhain_file )
461is a binary file, which can be created or updated using the
462.B \-t
463.I init
464or the
465.B \-t
466.I update
467option.
468If you use
469.B \-t
470.IR init ,
471you need to
472.I remove
473the old database first,
474otherwise the new version will be
475.I appended
476to the old one.
477The file may be (clear text) signed by PGP/GnuPG.
478.br
479It is recommended to use GnuPG with the options
480.B gpg
481.I -a --clearsign --not-dash-escaped
482.br
483.B samhain
484will check the signature, if compiled with support for that.
485.PP
486At startup
487.B samhain
488will compute the checksum of the database, and verify it for
489each further access. This checksum is not stored on disk (i.e. is lost
490after program termination), as there is no secure way to store it.
491
492.SH LOG FILE
493.PP
494Each entry in the log file has the format
495.BR "Severity : [Timestamp] Message" ,
496where the timestamp may be obtained from a time server rather than from
497the system clock, if
498.B samhain
499has been compiled with support for this.
500Each entry is followed by a
501.IR signature ,
502which is computed as
503.BR "Hash(Entry Key_N)" ,
504and
505.B Key_N
506is computed as
507.BR "Hash(Key_N\-1)" ,
508i.e. only knowledge of the first signature key in this chain allows to
509verify the integrity of the log file. This first key is autogenerated
510and e\-mailed to the designated recipient.
511.PP
512The default name of the log file is
513.IR samhain_log .
514To prevent multiple instances of
515.B samhain
516from writing to the same log file, the log file is locked by creating a
517.IR "lock file" ,
518which is normally deleted at program termination.
519The default name of the
520.I "lock file"
521is
522.IR samhain.lock .
523If
524.B samhain
525is terminated abnormally, i.e. with kill \-9,
526a stale lock file might remain, but usually
527.B samhain
528will be able to recognize that and remove the stale lock file
529on the next startup.
530.PP
531.SH EMAIL
532.PP
533E\-mails are sent (using built-in SMTP code)
534to one recipient only.
535The subject line contains timestamp
536and hostname, which are repeated in the message body.
537The body of the mail contains a line with a
538.I signature
539similar to that in the log file, computed from the message and a
540key. The key is iterated by a hash chain, and the initial
541key is revealed in the first email sent.
542Obviously, you have to believe that this first e\-mail is
543authentical ...
544.PP
545.SH CLIENT/SERVER USAGE
546.PP
547To monitor several machines, and collecting data by a central log server,
548.B samhain
549may be compiled as a client/server application. The log server
550.RB ( yule )
551will accept connection
552requests from registered clients only. With each client, the server will first
553engage in a challenge/response protocol for
554.I authentication
555of the client and
556.I establishing
557a
558.IR "session key" .
559.PP
560This protocol requires on the client side a
561.IR "password" ,
562and on the server side a
563.IR "verifier"
564that is computed from the
565.IR "password" .
566.PP
567To
568.I register
569a client, simply do the following:
570.br
571First, with the included utility program
572.B samhain_setpwd
573re\-set the compiled\-in default password of the
574client executable to your preferred
575value (with no option, a short usage help is printed).
576To allow for non-printable chars, the new value
577must be given as a 16\-digit hexadecimal string
578(only 0123456789ABCDEF in string), corresponding to an 8-byte password.
579.br
580Second, after re\-setting the password in the client executable,
581you can use the server's convenience function
582.B yule
583.B \-P
584.I password
585that will take as input the (16\-digit hex) password,
586compute the corresponding verifier, and outputs a default configuration file
587entry to register the client.
588.br
589Third, in the configuration file for the server, under the [Clients] section,
590enter
591the suggested registration entry of the form
592.IR "Client=hostname@salt@verifier" ,
593where
594.I hostname
595must be the (fully qualified) hostname of the machine on
596which the client will run.
597.B "Don't forget to reload the server configuration thereafter."
598.PP
599If a connection attempt is made, the server will lookup the entry for
600the connecting host, and use the corresponding value for the
601.I verifier
602to engage in the session key exchange. Failure to verify the client's
603response(s) will result in aborting the connection.
604.PP
605.SH STEALTH
606.PP
607.B samhain
608may be compiled with support for a
609.I stealth
610mode of operation, meaning that
611the program can be run without any obvious trace of its presence
612on disk. The supplied facilities are simple - they are more
613sophisticated than just running the program under a different name,
614and might thwart efforts using 'standard' Unix commands,
615but they will not resist a search using dedicated utilities.
616.PP
617In this mode, the runtime executable will hold no
618printable strings, and the configuration file is expected to be
619a postscript file with
620.I uncompressed
621image data, wherein
622the configuration data are hidden by steganography.
623To create such a file from an existing image, you may use e.g.
624the program
625.BR convert (1),
626which is part of the
627.BR ImageMagick (1)
628package, such as:
629.B "convert +compress"
630.IR "ima.jpg ima.ps" .
631.PP
632To hide/extract the configuration data within/from the postscript file,
633a utility program
634.B samhain_stealth
635is provided.
636Use it without options to get help.
637.PP
638Database and log file may be e.g. existing image files, to which
639data are appended, xor'ed with some constant to mask them as binary data.
640.PP
641The user is responsible by herself for re-naming the compiled
642executable(s) to unsuspicious names, and choosing (at compile time)
643likewise unsuspicious names for config file, database, and log (+lock) file.
644.PP
645.SH SECURITY
646.PP
647For security reasons,
648.B samhain
649will not write log or data files in a directory, remove the lock file,
650or read the configuration file, if any element
651in the path is owned or writeable by an untrusted user (including
652group-writeable files with untrusted users in the group, and world-writeable
653files).
654.br
655.I root
656and the
657.I effective
658user are always trusted. You can add more users in the configuration file.
659.PP
660Using a
661.I "numerical host address"
662in the e\-mail address is more secure than
663using the hostname (does not require
664DNS lookup).
665.PP
666If you use a
667.I precompiled
668.B samhain
669executable (e.g. from a
670binary distribution), in principle a prospective intruder could easily
671obtain a copy of the executable and analyze it in advance. This will
672enable her/him to generate fake audit trails and/or generate
673a trojan for this particular binary distribution.
674.br
675For this reason, it is possible for the user to add more key material into
676the binary executable. This is done with the command:
677.PP
678.BI "samhain " \-\-add\-key=key@/path/to/executable
679.PP
680This will read the file
681.I /path/to/executable, add the key
682.I key,
683which should not contain a '@' (because it has a special meaning, separating
684key from path), overwrite any key previously set by this command, and
685write the new binary to the location
686.I /path/to/executable.out
687(i.e. with .out appended). You should then copy the new binary to the location
688of the old one (i.e. overwrite the old one).
689.PP
690.B Note that using a precompiled samhain executable from a binary
691.B package distribution is not recommended unless you add in key material as
692.B described here.
693
694.PP
695.SH NOTES
696.PP
697For initializing the key(s),
698.I "/dev/random"
699is used, if available. This is a
700device supplying cryptographically strong
701(non-deterministic) random noise. Because it is slow,
702.B samhain
703might appear to hang at startup. Doing some random things
704(performing rain dances, spilling coffee, hunting the mouse) might speed up
705things. If you do not have
706.IR "/dev/random" ,
707lots of statistics from
708.BR vmstat (8)
709and the like will be pooled and mixed by a hash function.
710.PP
711Some hosts might check whether the sender of the mail is valid.
712Use only
713.I "login names"
714for the sender.
715.br
716For sending mails, you may need to set a relay host for the sender domain
717in the configuration file.
718.PP
719.SH BUGS
720.PP
721Whoever has the original signature key may change the log file and send fake
722e\-mails. The signature keys are e\-mailed at program startup
723with a one\-time pad encryption.
724This should be safe against an eavesdropper on the network,
725but not against someone with read access to the binary,
726.I if
727she has caught
728the e\-mail.
729.PP
730.SH FILES
731.PP
732.I /etc/samhainrc
733.br
734.I /usr/local/man/man8/samhain.8
735.br
736.I /usr/local/man/man5/samhainrc.5
737.br
738.I /var/log/samhain_log
739.br
740.I /var/lib/samhain/samhain_file
741.br
742.I /var/lib/samhain/samhain.html
743.br
744.I /var/run/samhain.pid
745
746.SH SEE ALSO
747.PP
748.BR samhainrc (5)
749
750.SH AUTHOR
751.PP
752Rainer Wichmann (http://la\-samhna.de)
753.SH BUG REPORTS
754.PP
755If you find a bug in
756.BR samhain ,
757please send electronic mail to
758.IR support@la\-samhna.de .
759Please include your operating system and its revision, the version of
760.BR samhain ,
761what C compiler you used to compile it, your 'configure' options, and
762any information that you deem helpful.
763.PP
764.SH COPYING PERMISSIONS
765.PP
766Copyright (\(co) 1999, 2004 Rainer Wichmann
767.PP
768Permission is granted to make and distribute verbatim copies of
769this manual page provided the copyright notice and this permission
770notice are preserved on all copies.
771.ig
772Permission is granted to process this file through troff and print the
773results, provided the printed document carries copying permission
774notice identical to this one except for the removal of this paragraph
775(this paragraph not being relevant to the printed manual page).
776..
777.PP
778Permission is granted to copy and distribute modified versions of this
779manual page under the conditions for verbatim copying, provided that
780the entire resulting derived work is distributed under the terms of a
781permission notice identical to this one.
782
783
784
Note: See TracBrowser for help on using the repository browser.