Jun 15

[原]用Tripwire实现系统完整性检查 晴

linuxing , 12:56 , 网络服务 » 安全相关 , 评论(0) , 引用(0) , 阅读(53695) , Via 本站原创 | |

六、其他
1、参数简写
在一些技术资料里面会提到tripwire的一些简单参数,大概包括:
tripwire:
引用
Database Initialization:  tripwire [-m i|--init] [options]
Integrity Checking:  tripwire [-m c|--check] [object1 [object2...]]
Database Update:  tripwire [-m u|--update]
Policy Update:  tripwire [-m p|--update-policy] policyfile.txt

twadmin:
引用
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:
引用
Print Database:  twprint [-m d|--print-dbfile] [options] [object1 [object2...]]
Print Report:  twprint [-m r|--print-report] [options]

那类似下面的命令:
tripwire --init

就可以写成:
tripwire -m i

或者
twprint --print-report --twrfile mail.linuxfly.org-20070614-155313.twr

写成:
twprint -m r --twrfile mail.linuxfly.org-20070614-155313.twr

2、维护策略文件和配置文件
在使用site.key对策略文件和配置文件加密和签名后,为安全起见,都会把明文的twcfg.txt和twpol.txt删掉。但如果您需要修改策略和配置文件,这还是必须要用到这两个文件的。
所以,可以使用下面的命令恢复:
cd /etc/tripwire
twadmin --print-cfgfile > twcfg.txt
twadmin --print-polfile > twpol.txt

在修改完毕上述两个文件后,再签名并初始化数据库即可。
3、配置策略
增加策略:
引用

#定义规则的名称及级别
(rulename = "My check files",
severity = 50
)
{
#添加/etc整个目录树及子目录及其下的文件
/etc -> $(SEC_CRIT)
#添加/etc目录及其下的文件,但不包括其子目录
#/etc -> $(SEC_CRIT) (recurse=1)
#添加/etc目录,但不包括其下的文件及子目录
#/etc -> $(SEC_CRIT) (recurse=0)
#排除一个文件或目录
!/etc/dhcpd.conf

/sbin/e2fsck -> $(SEC_CRIT) ;
/bin/cp -> $(SEC_CRIT) ;
/opt/oracle -> $(SEC_INVARIANT) ;
/etc/csh.cshrc -> $(SEC_CONFIG) ;
}

可以看到,规则的一般形式就是:
filename -> rule ;
其中rule有很多不同的定义,例如默认的:
引用
SEC_CRIT      = $(IgnoreNone)-SHa ;  # Critical files that cannot change
SEC_SUID      = $(IgnoreNone)-SHa ;  # Binaries with the SUID or SGID flags set
SEC_BIN       = $(ReadOnly) ;        # Binaries that should not change
SEC_CONFIG    = $(Dynamic) ;         # Config files that are changed infrequently but accessed often
SEC_LOG       = $(Growing) ;         # Files that grow, but that should never change ownership
SEC_INVARIANT = +tpug ;              # Directories that should never change permission or ownership
SIG_LOW       = 33 ;                 # Non-critical files that are of minimal security impact
SIG_MED       = 66 ;                 # Non-critical files that are of significant security impact
SIG_HI        = 100 ;                # Critical files that are significant points of vulnerability

而recurse=n就是定义递归深度,0为目录本身这一层。
根据这些定义,我们就可以按照不同的操作系统版本或应用,对策略文件进行裁减和增加,以满足我们的要求。(要知道,全部文件都验证是非常耗费资源和时间的,也是不必要的)
这些命令可以对指定的文件或目录检测:
tripwire -m c /bin/cp /etc

也可以对某一规则检测:
tripwire -m c --rule-name "My check files"

还可以对某一等级检测:
tripwire --check --severity 50

4、提高安全性
从前面的介绍可以看到,tripwire对系统完整性的检查,关键是依赖于数据库的情况。而数据库也是可以被重新初始化的。因此,如果数据库和被验证的机器一同存放,则万一机器被入侵,是无法判断数据库是否就是正常的“原始”状态。
所以,对于重要的系统,可以把数据库备份到只读的介质上(例如光盘),或备份到远端安全机器中,然后通过ssh等远程协议进行校验的工作。(本机校验也可能因crond给修改而带来问题)
当然,这种方式需要注意两点:
引用
a)定时更新数据库,并备份;
b)只有重要的系统需要这样做,而一般crond的计划工作都是可以信任的。

5、参考文章:
http://www.xsec.org/index.php?module=archives&act=view&type=3&id=14
ppt教程文件:
内文分页: [1] [2] [3]
Tags:
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]