实验 3 - 系统审计¶
目标¶
完成此实验后,您将能够
- 从零开始创建一个简单且自定义的审计工具
- 使用并理解 Tripwire 等安全审计工具
完成此实验室的估计时间:90 分钟
一个简单的自制完整性检查器¶
在安装和配置 Tripwire 之前,我们先创建一个执行类似功能的示例脚本。此脚本将有助于更深入地理解 Tripwire 和类似工具的工作原理。
该脚本在很大程度上依赖于 md5sum 程序。md5sum 程序用于为指定的 FILE 计算一个 128 位校验和(或“指纹”)。
该脚本的功能总结如下
-
在基础系统安装完成后,它会将 /etc 目录下的部分系统配置文件备份到 root 主目录下的一个名为 etc.bak 的目录中。
具体来说,它将备份 /etc 下所有后缀为 “*.conf” 的文件。
当使用初始化选项(--initialization | -i)运行时,它会执行此操作。
-
然后,脚本将获取已知安全文件(未被污染的文件)的 md5 校验和。
-
MD5 校验和列表将存储在一个名为 “md5_good” 的文件中。
-
当脚本在验证模式下运行时,将使用 “--check” 选项调用 md5sum 程序,以将当前 MD5 校验和与给定的列表(md5_good 文件)进行比较。
脚本会将验证输出打印到标准输出,并将结果的副本通过电子邮件发送给超级用户。
-
当 /etc 下的配置文件发生更改(无论合法还是非法)时,可以通过 `--rebuild | -r` 选项调用脚本来批准更改并重建基线伪数据库。
-
您可以定期手动运行脚本,或创建 cron 作业自动运行脚本。
下面的脚本可以进行微调和扩展,以执行比现在更多的工作。您可以根据自己的想象力来定制其功能。
如果您只是想快速完成工作,该脚本就足够了,但对于其他所有情况,都有 Tripwire。
练习 1¶
- 以 root 用户身份登录,并启动您选择的文本编辑器。输入以下文本:
#!/bin/sh
# This script checks for changes in the MD5 sums of files named "/etc/*.conf"
case $1 in
-i|--initialize)
# This section will run if the script is run in an initialization mode
# Delete old directory, make directory, backup good files, and change directory to /root/etc.bak
rm -rf /root/etc.bak
mkdir /root/etc.bak
cp /etc/*.conf /root/etc.bak
cd /root/etc.bak
# Create our baseline file containing a list of good MD5 sums
for i in /etc/*.conf; do
md5sum $i >> md5_good
done
echo -e "\nUntainted baseline file (~/etc.bak/md5_good) has been created !!\n"
;;
-v|--verify)
# This section will run if the script is called in a verify mode
cd /root/etc.bak
# Check if there is any file containing output from a previous run
if [ -f md5_diffs ]; then
rm -f md5_diffs # if it exists we delete it
fi
# We re-create the file with a pretty sub-heading and some advice
echo -e "\n **** Possibly tainted File(s) ****\n" > md5_diffs
# Run the md5sum program against a known good list i.e. "md5_good" file
md5sum -c md5_good 2> /dev/null | grep FAILED >> md5_diffs
if [ $? -ge 1 ]; then
echo "Nothing wrong here."
else
# Append some helpful text to the md5_diffs file
echo -e "\nUpdate the baseline file if you approve of the changes to the file(s) above \n" >> md5_diffs
echo -e "Re-run the script with the re-build option (e.g. ./check.sh --rebuild) to approve \n" >> md5_diffs
cat md5_diffs # print the md5_diffs file to the display
if [ -x /usr/bin/mail ]; then
mail -s "Changed Files" root < md5_diffs # also e-mail the md5_diffs file to root
fi
fi
;;
-r|--rebuild)
# This section is for re-building the Baseline file just in case
# the changes to the configuration files are legal and sanctioned
cd /root/etc.bak/
mv md5_good md5_good.bak # make a backup copy of the current untainted baseline file
for j in /etc/*.conf; do
md5sum $j >> md5_good
done
echo -e "\nBaseline file updated with approved changes !!!\n"
;;
*)
echo "This script accepts: only ( -i|--initialize or -v|--verify or -r|--rebuild ) parameters"
;;
esac
将上述文本保存在一个文本文件中,并将文件命名为 “check.sh”。
使用 check.sh 脚本¶
-
在 root 的主目录下创建一个名为 “scripts” 的目录。
-
将上面创建的脚本复制到您的 scripts 目录中。
-
使脚本可执行。
-
使用初始化选项运行脚本。输入:
[root@localhost scripts]# ./check.sh -i Untainted baseline file (~/etc.bak/md5_good) has been created !!
-
使用 `ls` 命令查看 root 主目录的内容。您应该会看到一个名为 `etc.bak` 的新目录。使用 `cat` 命令查看 `/root/etc.bak/md5_good` 文件。
-
使用验证选项运行脚本。输入:
[root@localhost scripts]# ./check.sh -v Nothing wrong here.
如果一切正常,您应该会看到上面的输出。
-
您将故意修改 `/etc` 目录下的 `/etc/kdump.conf` 文件。输入:
[root@localhost scripts]# echo "# This is just a test" >> /etc/kdump.conf
-
现在再次使用验证模式运行 check.sh 脚本。输入:
[root@localhost scripts]# ./check.sh -v **** /etc/kdump.conf: FAILED Update the baseline file if you approve of the changes to the file(s) above Re-run the script with the re-build option (e.g. ./check.sh --rebuild) to approve
-
根据上面的警告,您应该进一步调查以查看修改后的文件是否符合您的要求。如果符合,您可以运行带有 `--rebuild` 选项的脚本。要仅查看“已污染”文件和“未污染”文件之间的差异,可以输入:
[root@localhost scripts]# sdiff -s /etc/kdump.conf /root/etc.bak/kdump.conf
Tripwire¶
在构建任何新系统后,您应该做的第一件事就是获取系统已知良好状态的快照,然后再将系统“污染”或部署到生产环境中。
有多种工具可以实现这一点。Tripwire 就是其中之一。Tripwire 是一个高级工具,因此请准备好应对大量的选项、语法、怪癖和开关。
Tripwire 可以被视为一种基于主机的入侵检测系统 (IDS)。它通过获取“健康系统”的快照,然后将该健康状态与其他可疑状态进行比较来实现入侵检测功能。它提供了一种方法来了解/监控某些敏感文件是否被非法篡改。系统管理员当然会决定监控哪些文件。
Tripwire 的作者将其描述为开源安全、入侵检测、损坏评估与恢复以及取证软件。
Tripwire 将文件的最新签名与其在创建数据库时所取的签名进行比较。
安装和配置 Tripwire 所涉及的步骤如下:
-
从源代码或二进制文件安装软件
-
运行配置脚本:(twinstall.sh)。此脚本用于:a) 创建站点密钥、本地密钥,并提示输入两者的密码 b) 使用站点密钥对策略文件和配置文件进行签名
-
初始化 Tripwire 数据库
-
运行第一次完整性检查。
-
编辑配置文件 (twcfg.txt)
-
编辑策略文件 (twpol.txt)
Tripwire 接受以下命令行选项:
数据库初始化模式
-m i --init
-v --verbose
-s --silent, --quiet
-c cfgfile --cfgfile cfgfile
-p polfile --polfile polfile
-d database --dbfile database
-S sitekey --site-keyfile sitekey
-L localkey --local-keyfile localkey
-P passphrase --local-passphrase passphrase
-e --no-encryption
完整性检查模式
-m c --check
-I --interactive
-v --verbose
-s --silent, --quiet
-c cfgfile --cfgfile cfgfile
-p polfile --polfile polfile
-d database --dbfile database
-r report --twrfile report
-S sitekey --site-keyfile sitekey
-L localkey --local-keyfile localkey
-P passphrase --local-passphrase passphrase
-n --no-tty-output
-V editor --visual editor
-E --signed-report
-i list --ignore list
-l { level | name } --severity { level | name }
-R rule --rule-name rule
-x section --section section
-M --email-report
-t { 0|1|2|3|4 } --email-report-level { 0|1|2|3|4 }
-h --hexadecimal
[ object1 [ object2... ]]
数据库更新模式
-m u --update
-v --verbose
-s --silent, --quiet
-c cfgfile --cfgfile cfgfile
-p polfile --polfile polfile
-d database --dbfile database
-r report --twrfile report
-S sitekey --site-keyfile sitekey
-L localkey --local-keyfile localkey
-P passphrase --local-passphrase passphrase
-V editor --visual editor
-a --accept-all
-Z { low | high } --secure-mode { low | high }
策略更新模式
-m p --update-policy
-v --verbose
-s --silent, --quiet
-c cfgfile --cfgfile cfgfile
-p polfile --polfile polfile
-d database --dbfile database
-S sitekey --site-keyfile sitekey
-L localkey --local-keyfile localkey
-P passphrase --local-passphrase passphrase
-Q passphrase --site-passphrase passphrase
-Z { low | high } --secure-mode { low | high }
policyfile.txt
`tripwire` 命令选项摘要
SYNOPSIS
Database Initialization: tripwire { -m i | --init } [ options... ]
Integrity Checking: tripwire { -m c | --check } [ options... ]
[ object1 [ object2... ]]
Database Update: tripwire { -m u | --update } [ options... ]
Policy update: tripwire { -m p | --update-policy } [ options... ]
policyfile.txt
Test: tripwire { -m t | --test } [ options... ]
`twadmin`¶
`twadmin` 实用程序执行与 Tripwire 文件和配置选项相关的管理功能。具体来说,`twadmin` 允许对 Tripwire 文件进行编码、解码、签名和验证,并提供生成和更改本地和站点密钥的方法。
Create Configuration File: twadmin [-m F|--create-cfgfile][options] cfgfile.txt
Print Configuration File: twadmin [-m f|--print-cfgfile] [options]
Create Policy File: twadmin [-m P|--create-polfile] [options] polfile.txt
Print Policy File: twadmin [-m p|--print-polfile] [options]
Remove Encryption: twadmin [-m R|--remove-encryption] [options] [file1...]
Encryption: twadmin [-m E|--encrypt] [options] [file1...]
Examine Encryption: twadmin [-m e|--examine] [options] [file1...]
Generate Keys: twadmin [-m G|--generate-keys] [options]
`twprint`¶
以纯文本格式打印 Tripwire 数据库和报告文件。
打印报告模式
-m r --print-report
-v --verbose
-s --silent, --quiet
-c cfgfile --cfgfile cfgfile
-r report --twrfile report
-L localkey --local-keyfile localkey
-t { 0|1|2|3|4 } --report-level { 0|1|2|3|4 }
打印数据库模式
-m d --print-dbfile
-v --verbose
-s --silent, --quiet
-c cfgfile --cfgfile cfgfile
-d database --dbfile database
-L localkey --local-keyfile localkey
[object1 [object2 ...]
`siggen`¶
`siggen` 是 Tripwire 的签名收集例程。它是一个显示指定文件哈希函数值的实用程序。
OPTIONS
‐t, --terse
Terse mode. Prints requested hashes for a given file on one line, delimited by spaces, with no extraneous information.
‐h, --hexadecimal
Display results in hexadecimal rather than base64 notation.
‐a, --all
Display all hash function values (default).
‐C, --CRC32
Display CRC-32, POSIX 1003.2 compliant 32-bit Cyclic Redundancy Check.
‐M, --MD5
Display MD5, the RSA Data Security, Inc. Message Digest Algorithm.
‐S, --SHA
Display SHA, Tripwire's implementation of the NIST Secure Hash Standard, SHS (NIST FIPS 180).
‐H, --HAVAL
Display Haval value, a 128-bit hash code.
file1 [ file2... ]
List of filesystem objects for which to display values.
练习 2¶
安装 Tripwire¶
-
检查您的系统上是否已安装 Tripwire。输入:
[root@localhost root]# rpm -q tripwire tripwire-*
如果获得与上面类似的输出,则表示您已安装。跳过下一步。
-
如果未安装,请获取 Tripwire 二进制文件并进行安装。输入:
[root@localhost root]# dnf -y install tripwire
配置 Tripwire¶
配置 Tripwire 包括(如果需要)自定义 Tripwire 配置文件、策略文件,然后运行配置脚本。脚本将提示您输入一个密码,该密码将用于签名/保护配置文件、策略文件和数据库文件。
-
将您的当前目录更改为 Tripwire 的工作目录:输入:
[root@localhost root]# cd /etc/tripwire/
-
列出目录内容。
-
使用任何分页器或文本编辑器查看/研究目录中的文件。
-
目前,我们将接受 Tripwire 配置文件 (twcfg.txt) 和提供的默认策略文件 (twpol.txt) 的默认设置。
-
以 root 用户身份执行 Tripwire 配置实用程序。您将被提示(两次)输入站点密钥文件密码。选择您不会忘记的任何密码(站点密钥用于 twcfg.txt 文件和 twpol.txt 文件)。输入:
[root@localhost tripwire]# tripwire-setup-keyfiles ..... Enter the site keyfile passphrase: Verify the site keyfile passphrase: ...... Generating key (this may take several minutes)...Key generation complete.
接下来,您将被提示输入本地密钥。同样,请选择另一个您不会忘记的密码。(本地密钥用于签名 Tripwire 数据库文件和报告文件)。
Enter the local keyfile passphrase: Verify the local keyfile passphrase: .... Generating key (this may take several minutes)...Key generation complete.
选择密码后,`tripwire-setup-keyfiles` 程序将继续实际创建/签名原始纯文本文件的加密版本(即分别创建 tw.cfg 和 tw.pol)。您将被再次提示输入之前选择的密码。此时,只需按照提示操作,直到脚本退出。
---------------------------------------------- Signing configuration file... Please enter your site passphrase: ******** ---------------------------------------------- Signing policy file... Please enter your site passphrase: ******** ...... Wrote policy file: /etc/tripwire/tw.pol
实验任务
列出 /etc/tripwire 目录的新内容。
-
根据 `tripwire-setup-keyfiles` 实用程序运行时收到的警告,您现在需要将配置文件的纯文本版本和策略文件从本地系统移走。您可以将它们存储在外部可移动介质上,或者就地加密它们(例如使用 GPG 等工具),或者如果您觉得足够大胆,可以完全删除它们。输入:
[root@localhost tripwire]# mkdir /root/tripwire_stuff && mv twcfg.txt twpol.txt /root/tripwire_stuff
注意
如果忘记密码,保留纯文本版本可能会很有用。然后,您可以根据随着时间推移而微调的配置和策略,重新运行 `tripwire-setup-keyfiles`。
初始化数据库¶
初始化数据库是 Tripwire 的术语,表示获取您决定监控的文件(基于策略文件)的初始“未被污染”的快照。这会生成数据库,并使用本地密钥对数据库进行签名。数据库将作为所有未来完整性检查的基线。
-
仍然以 root 用户身份登录,输入:
[root@localhost tripwire]# tripwire --init Please enter your local passphrase: Parsing policy file: /etc/tripwire/tw.pol Generating the database... *** Processing Unix File System ***
在提示时输入您的本地密码。数据库创建将运行完成,您应该会看到类似下面的输出:
数据库已成功生成。
-
使用 `ls` 命令验证数据库是否已在指定位置创建。输入:
[root@localhost tripwire]# ls -lh /var/lib/tripwire/$(hostname).twd -rw-r--r--. 1 root root 3.3M Sep 27 18:35 /var/lib/tripwire/localhost.twd
练习 3¶
完整性检查和查看报告¶
在本实验中,您将学习如何运行系统完整性检查并查看 Tripwire 为您生成的报告。
运行完整性检查¶
在此模式下(完整性检查模式)运行 Tripwire 会将当前文件系统对象与其在 Tripwire 数据库中的属性进行比较。当 Tripwire 在此模式下运行时,数据库与当前文件系统对象之间的差异将打印到标准输出。检查完成后,Tripwire 还会在 twcfg.txt 文件中指定的目录(/var/lib/tripwire/report/)中生成一个报告文件。
-
运行完整性检查。输入:
[root@localhost tripwire]# tripwire --check
在此检查过程中,您会看到一些 [预期的] 警告信息流过。
检查 `/var/lib/tripwire/report` 目录,看是否也在此处为您创建了报告。
实验任务
记下创建的报告文件的名称。
文件名 =
-
再次运行完整性检查,但手动指定报告文件的文件名。输入:
[root@localhost tripwire]# tripwire -m c -r /root/tripwire_report.twr
-
确保在 root 的主目录下创建了一个新文件。输入:
[root@localhost tripwire]# ls -l /root/tripwire_report.twr
检查报告¶
Tripwire 的报告文件是在完整性检查期间发现的规则违规的集合。
有几种方法可以查看 Tripwire 报告文件:
- 在完整性检查期间
- 以电子邮件的形式自动发送给您
- 使用 Tripwire 包提供的 `twprint` 命令
注意
您可能从之前的实验中注意到,Tripwire 默认使用系统的 FQDN 名称、日期和时间组合来命名报告文件。
-
首先切换到默认报告目录,并查看步骤 1 中为您创建的默认报告(文件名)。输入:
[root@localhost report]# cd /var/lib/tripwire/report && twprint --print-report -r <FILE_NAME>
替换
上面您之前记下的值。 要使用上面命令的简写形式,请键入:
[root@localhost report]# twprint -m r -r <FILE_NAME> | less
我们将输出通过管道传递给 `less` 命令,因为报告滚动得很快。
-
现在查看您在 root 主目录下手动创建的另一个报告。输入:
[root@localhost root]# cd && twprint --print-report -r /root/tripwire_report.twr | less
-
做好准备,仔细研究报告文件的输出。
-
您应该再次注意到 Tripwire 创建了报告文件的二进制/数据格式。在 root 的主目录下创建一个纯文本版本的报告文件。输入:
[root@localhost root]# twprint --print-report -r /root/tripwire_report.twr > tripwire_report.txt
通过电子邮件查看报告¶
在这里,您将测试 Tripwire 的电子邮件功能。Tripwire 的电子邮件通知系统使用 Tripwire 配置文件(twcfg.txt)中指定的设置。
-
首先查看配置文件,并记下控制 Tripwire 电子邮件通知系统的相关变量。要查看配置文件,请输入:
[root@localhost report]# twadmin -m f | less
实验任务
写下相关的变量。
-
接下来,通过检查 say postfix 的状态来确保您的本地邮件系统已启动并正在运行。输入:
[root@localhost report]# systemctl -n 0 status postfix ....... Active: active (running) since Thu 2023-08-31 16:21:26 UTC; 3 weeks 6 days ago .......
您的输出应该与上面类似。如果您的邮件系统未运行,请先解决该问题并使其运行,然后再继续。
-
向 root 发送测试消息。输入:
[root@localhost report]# tripwire --test --email root
-
使用 mail 程序检查 root 的邮件。输入:
[root@localhost report]# mail
超级用户应该收到一封主题为“Test email message from Tripwire”的消息。
-
在确认电子邮件功能正常工作后,您可以尝试手动将其中一份报告的副本发送给自己。
问题
为此的命令是什么?
微调 Tripwire¶
在安装 Tripwire、获取系统快照然后运行第一次完整性检查之后,您很可能需要微调 Tripwire 以适应您特定环境的需求。这主要是因为 Tripwire 附带的默认配置和策略文件可能不完全符合您的需求,或者不能准确反映您的文件系统上的实际对象。
您需要确定在完整性检查期间报告文件中的文件系统违规是实际的违规还是对您的文件系统对象的合法/授权更改。Tripwire 提供了几种方法来实现这一点。
更新策略文件¶
通过此方法,您可以通过更改策略文件中的规则来更改或微调 Tripwire 认为对您的文件系统对象构成的违规。然后可以在不完全重新初始化的 Re-initialize 的情况下更新数据库。这可以节省时间并保持安全,因为它可以使策略文件与它使用的数据库保持同步。
您将使用之前创建的报告文件(/root/tripwire_report.txt)来微调您的策略文件,首先阻止 Tripwire 报告从未存在于文件系统中的文件的缺失。
这将大大缩短您需要管理的报告文件的长度。
微调 Tripwire¶
-
使用 grep 命令过滤掉报告文件中所有提及丢失文件的行(即包含“Filename”一词的行)。将输出重定向到另一个文件 - tripwire_diffs.txt。输入:
[root@localhost root]# grep Filename /root/tripwire_report.txt > tripwire_diffs.txt
-
查看您上面创建的文件内容。输入:
[root@localhost root]# less tripwire_diffs.txt 207: Filename: /proc/scsi 210: Filename: /root/.esd_auth 213: Filename: /root/.gnome_private 216: Filename: /sbin/fsck.minix 219: Filename: /sbin/mkfs.bfs ..................................
-
现在您需要编辑 Tripwire 策略文件,并注释掉或删除文件中不应存在的条目。例如,有些文件不在您的系统上,有些文件永远不会存在。例如,策略文件试图监控的文件之一是 /proc/scsi 文件。如果您的系统上没有 SCSI 设备,那么监控此文件就没有意义。
另一个关于是否监控的值得商榷的例子是 `/var/lock/subsys/` 目录下的各种锁定文件。选择是否监控这些文件应由个人决定。
重新创建策略文件的文本版本 - 以防您将其删除(按建议)从本地系统。输入:
[root@localhost root]# twadmin --print-polfile > twpol.txt
-
使用任何文本编辑器打开您上面创建的文本文件。注释掉您不想监控的对象引用。您可以参考之前创建的 tripwire_diffs.txt 文件作为指南。输入:
[root@localhost root]# vi twpol.txt
保存更改并关闭文件。
-
运行 `tripwire` 进入策略文件更新模式。输入:
[root@localhost root]# tripwire --update-policy /root/twpol.txt
在提示时输入您的本地和站点密码。
一个新签名的加密策略文件将在 `/etc/tripwire/` 目录下为您创建。
-
删除或移除本地系统上的策略文件的文本版本。
-
运行上述步骤 5 中的命令还会在 `/var/lib/tripwire/report` 目录为您创建一个报告文件。
实验任务
写下您最新的报告文件名。
-
再次运行系统的完整性检查,直到您确信已获得良好的系统基线,可以据此做出未来决策。
问题
为此的命令是什么?
更新数据库¶
在完整性检查后以数据库更新模式运行 `tripwire` 是微调 Tripwire 的一种快速简单的方法。这是因为数据库更新模式允许调和数据库与当前系统之间的任何差异。这将防止违规在未来的报告中显示。
此更新过程通过允许您在不重新初始化数据库的情况下更新数据库来节省时间。
更新数据库¶
-
将您的当前目录更改为 Tripwire 在您的系统上存储报告文件的位置。输入:
[root@localhost root]# cd /var/lib/tripwire/report/
-
您将首先以交互方式使用数据库更新模式。输入:
[root@localhost report]# tripwire --update -Z low -r <LATEST_REPORT>
替换
使用您之前记下的报告文件名。 上面的命令还将启动您的默认文本编辑器(例如 `vi`),它将向您展示所谓的“更新投票箱”。您可能需要滚动浏览文件。
标记为“[x]”的条目表示数据库应使用该特定对象进行更新。
从投票箱“[ ]”中删除“x”以阻止使用该对象的最新值更新数据库。
使用您文本编辑器的常规键击保存并退出编辑器。
-
接下来,尝试以非交互方式使用数据库更新模式。即,您将接受报告文件中的所有条目,而无需提示。输入:
[root@localhost report]# tripwire --update -Z low -a -r <LATEST_REPORT>
Tripwire 配置文件¶
您将从微调配置文件开始执行这些练习。在之前的实验中,我们建议您删除或删除 Tripwire 文件在系统上的所有明文版本。您将通过编辑 Tripwire 配置文件中的一些变量来创建更安全的 Tripwire 安装。您将指定 Tripwire 应始终在可移动介质(如软盘或 CDROM)上查找策略和配置文件的二进制版本。
-
将您的当前目录更改为 /etc/tripwire。
-
生成配置文件的明文版本。输入:
[root@localhost tripwire]# twadmin --print-cfgfile > twcfg.txt
-
在您的文本编辑器中打开您上面创建的配置文件。输入:
[root@localhost tripwire]# vi twcfg.txt
编辑文件使其看起来像下面的示例文件:
(注意:新添加和更改的变量已为您高亮显示)
1 ROOT =/usr/sbin 2 POLFILE =/mnt/usbdrive/tw.pol 3 DBFILE =/var/lib/tripwire/$(HOSTNAME).twd 4 REPORTFILE =/var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr 5 SITEKEYFILE =/mnt/usbdrive/site.key 6 LOCALKEYFILE =/mnt/usbdrive/$(HOSTNAME)-local.key 7 EDITOR =/bin/vi 8 LATEPROMPTING =false 9 LOOSEDIRECTORYCHECKING =true 10 GLOBALEMAIL =root@localhost 11 MAILNOVIOLATIONS =true 12 EMAILREPORTLEVEL =3 13 REPORTLEVEL =3 14 MAILMETHOD =SENDMAIL 15 SYSLOGREPORTING =true 16 MAILPROGRAM =/usr/sbin/sendmail -oi -t
实验任务
查阅 `twconfig` 的 man 页以了解这些变量的含义。
LOOSEDIRECTORYCHECKING GLOBALEMAIL SYSLOGREPORTING
-
将可移动介质挂载到 /mnt/usbdrive 目录。输入:
[root@localhost tripwire]# mount /dev/usbdrive /mnt/usbdrive
注意
如果您选择将文件存储在其他位置(例如 CDROM 介质),请对命令进行必要的调整。
-
将站点密钥、本地密钥和二进制文件移动到新配置文件中指定的位置。输入:
[root@localhost tripwire]# mv site.key tw.pol localhost.localdomain-local.key /mnt/usbdrive
-
创建明文配置文件的二进制版本。输入:
[root@localhost tripwire]# twadmin --create-cfgfile -S /mnt/usbdrive/site.key twcfg.txt*
`/etc/tripwire/tw.cfg` 文件将为您创建。
-
测试您的新设置。卸载 USB 驱动器并弹出它。
-
尝试运行一个需要软盘上存储文件的 `tripwire` 命令。输入:
[root@localhost tripwire]# twadmin --print-polfile ### Error: File could not be opened. ### Filename: /mnt/usbdrive/tw.pol ### No such file or directory ### ### Unable to print policy file. ### Exiting...
您应该会收到与上面类似的错误。
-
挂载存储 Tripwire 文件的介质,然后再次尝试上述命令。
问题
这次命令是否成功运行?
-
搜索并删除您迄今为止在系统上创建的所有 Tripwire 配置文件的纯文本版本。
每次要管理 Tripwire 的某个方面时都必须挂载和卸载可移动介质可能会非常麻烦,但其回报可能是额外的安全性。您绝对应该考虑将 Tripwire 数据库的原始副本存储在 DVD 等只读介质上。
附加练习¶
-
配置您的 Tripwire 安装,使其每天凌晨 2 点运行完整性检查,并通过电子邮件将完整性检查报告发送给系统上的超级用户。
提示
您可能需要使用 cron 作业来完成此操作。
作者:Wale Soyinka
贡献者:Steven Spencer, Ganna Zhyrnova