实验 3 - 审计系统¶
目标¶
完成本实验后,您将能够
- 从头开始创建一个简单且自定义的审计工具
- 使用和理解 Tripwire 等安全审计工具
完成本实验的预计时间:90 分钟
一个简单的自制完整性检查器¶
在安装和配置 Tripwire 之前,我们将创建一个执行类似功能的示例脚本。这个脚本将有助于更好地理解 Tripwire 和类似工具的功能。
该脚本严重依赖于 md5sum 程序。md5sum 程序用于为指定文件计算 128 位校验和(或“指纹”)。
该脚本的功能总结如下
在安装基本系统后,它将备份 /etc 目录中的一些系统配置文件,备份到 root 主目录中的名为 etc.bak 的目录中。
具体来说,它将备份 /etc 下所有以“*.conf”结尾的文件。
它在使用初始化选项(--initialization|-i)运行时执行此操作。
然后,该脚本将获取已知合适文件(未受污染的文件)的 md5 校验和。
MD5 校验和列表将存储在一个名为“md5_good”的文件中。
当脚本在验证模式下运行时,md5sum 程序将使用“--check”选项调用,以检查当前 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 配置文件、策略文件,然后运行配置脚本。该脚本将提示您输入一个密码短语,该密码短语将用于签名/保护配置文件、策略文件和数据库文件。
将您的 pwd 更改为 Tripwire 的工作目录:键入
[root@localhost root]# cd /etc/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
目录,看看是否有为您创建的报告。实验任务
记下创建的报告文件的文件名。
FILE_NAME =
再次运行完整性检查,但手动为报告文件指定一个文件名。键入
[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 中为您创建的默认报告(FILE_NAME)。键入
[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
实验任务
记下相关的变量。
接下来,通过检查 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
超级用户应该收到主题为“来自 Tripwire 的测试电子邮件”的消息。
确认电子邮件功能正常后,您可以尝试手动将其中一份报告的副本发送给自己。
问题
执行此操作的命令是什么?
微调 Tripwire¶
安装 Tripwire、对系统进行快照,然后运行第一次完整性检查后,您很可能会需要微调 Tripwire 以适应您特定环境的需要。这主要是因为随 Tripwire 提供的默认配置和策略文件可能并不完全适合您的需要,也不反映您文件系统上的实际对象。
您需要确定完整性检查期间报告文件中的文件系统违规是实际违规,还是对文件系统对象的合法/授权更改。同样,Tripwire 提供了几种执行此操作的方法。
更新策略文件¶
使用这种方法,您将通过更改策略文件中的规则来更改或微调 Tripwire 认为违反文件系统对象的内容。然后可以更新数据库,而无需完全重新初始化。这可以节省时间并通过保持策略文件与使用的数据库同步来维护安全性。
您将使用之前创建的报告文件 (/root/tripwire_report.txt) 来微调策略文件,首先阻止 Tripwire 报告原本就不在文件系统上的文件的缺失。
这将有助于大大缩短您必须管理的报告文件长度。
微调 Tripwire¶
使用 grep 命令筛选出报告文件中所有引用缺失文件的行(即包含单词“文件名”的行)。将输出重定向到另一个文件 - 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。这是因为数据库更新模式允许协调数据库和当前系统之间的任何差异。这将防止违规出现在未来的报告中。
此更新过程通过允许您更新数据库而无需重新初始化它来节省时间。
更新数据库¶
将您的 pwd 更改为 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”的手册页以了解以下变量的用途
LOOSEDIRECTORYCHECKING GLOBALEMAIL SYSLOGREPORTING
将可移动介质挂载到 /mnt/usbdrive 目录。输入
[root@localhost tripwire]# mount /dev/usbdrive /mnt/usbdrive
注意
如果您选择将文件存储在其他位置(例如 CD-ROM 介质),请对命令进行必要的调整。
将站点密钥、本地密钥和二进制文件重新定位到新配置文件中指定的位置。输入
[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