Sysadmin手记:如何利用mtree做FreeBSD操作系统文件完整性审计

Sysadmin手记:如何利用mtree做FreeBSD操作系统文件完整性审计

http://dawnh.net/freebsd/252/use-mtree-for-freebsd-filesystem-integrity-auditing/

摘抄编译自 http://blogs.techrepublic.com.com/security/?p=283

对于一个Sysadmin来说,如何加固系统是一个长盛不衰的话题。然而再坚固的系统也有失守的时候,有时就可能因为非常细小的一点疏漏,导致整个 系统被攻破。所以对于Sysadmin来说,尽可能地保证系统安全是其一,其二还要会更快速有效地发现系统被入侵或者控制这种行为。因此完善的日志体系是 必要的。然而还有很多日志无法记录的入侵和破坏行为,这就要求从其他方面想办法。对于Windows操作系统,从Win2k起就有一个SFC系统,一旦系 统核心文件被更改,就会提醒管理员并生成审计日志。这玩艺在Win2003又进一步发展,不过貌似也是非常不好用。MS在即将发布的Windows 2008里面建立了一种名为Trusted Platform的框架,进一步完善了SFC,其原理大体应该也是核心部件的数字签名以及认证机制,只不过做的更完善一些了。我现在的PC就是因为某 P2P网络电视修改了tcpip.sys导致不断生成这个模块的error日志,大体说明这玩艺还是堪用的。不过Windows更难于发现的破坏行为大多 在注册表而不是文件系统,所以此方面恐怕还要更为复杂一些。

扯远了,对于unix类操作系统来说,这方面就没有那么复杂了,因为一个系统本身设计哲学的原因:一切皆是文件。因此,只要能有效监控文件系统的更 改,就可以抓住一切针对系统的不良行为。以前有过不少人写过Linux系统可以对整个根做md5sum来实现,这个对于其他Unix类系统也适用。然而对 于FreeBSD来说,有一个更为方便的工具–mtree。

其实mtree这东西本来是用于安装系统或软件时预先创建目录树的,因为其有散列计算以及权限对比等能力,将其作为一个文件系统完整性审计工具也是 刚好。另外还有一个很重要的原因是这个工具为基本发行版所附带,属于随手拈来的东西。假使系统被入侵,基础命令集像ps,top被替换地乱七八糟,也很少 会有人想到在mtree上动手脚。即使为了万全的可信任概率考虑,也可以使用rescue CD里的这个工具,还有它依赖的运行库也是非常之少,甚至临时从其他系统cp一个来用也完全可以。
说了这么多废话,其实用法非常简单,如下:

mtree -c -K sha256digest -p / > mtree.txt

-c代表输出至stdout,然后用转向定位到文件。

-K代表使用的散列方法,sha256可谓足够安全了吧。

-p代表要做mtree的目录,指定根自然是对整个文件系统做了。如果按照实际使用需求,其实不应该包含入一些被更改频率很高的目录,例如/var/log等。想做得更完善一点就可以写个脚本读取某文件里的目录列表挨个mtree了。

完成后mtree.txt里面就是我们要获取的审计信息了。
根据mtree.txt再来对照文件系统来检查更改情况则用以下命令:

mtree -f /path-to-mtree.txt -K sha256digest -p /

无输出则表示文件系统没更改,如果有输出,应该是以下类型的结果:

. changed

modification time expected Mon Sep 10 13:40:01 2007 found Mon Sep 10 14:08:21 2007

mtree.txt changed

size expected 0 found 24407

modification time expected Mon Sep 10 14:08:09 2007 found Mon Sep 10 14:08:11 2007

SHA-256 expected e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 found cb61a409d5e71a69ebbaa713e6d752db275a04f1629b86c4e52a835c70c422df

xxx extra

yyy missing

changed代表文件有变动,extra则代表为新建的文件,missing自然是代表文件没了。一目了然。

这样我们所要做的就是定期为文件系统做一个mtree.txt并妥善保管好,并在系统疑似出问题时拿出它来检查了。

Mtree is a powerful tree creation tool for the Unity editor. Nominated for best Artistic Tool 2019 Unity Awards. Every game needs vegetation, and while there are numerous vegetation packs for sale on the asset store, nothing beats the usefulness of having total control over the look and performance of the assets. Mtree will not only create beautiful looking vegetation, it will streamline your workflow by removing the need of modelling, unwrapping, importing your vegetation models from another software, and doing it all over again when you need to change a small detail. With Mtree, there will be less iterations over your models, and they will be quicker. Mtree trees are made in unity, for unity, the material is right, the dimensions are right, and everything is simple. Moreover, a good mesh is not enough in order to have a believable vegetation asset, you need a good shader, a good wind displacement solution, and vertex data to feed those; Mtree will answer every one of these needs. Mtree offers an intuitive, simple, yet complete solution for crafting AAA trees in a matter of minutes. With Mtree you can: • Create a trunk of any shape. • Add branches, grow them, split stem, add more branches. • Add leafs of any shape. • Bake the ambient occlusion in the vertex data. • Control the polygon count, get the most out of the fewest triangles. • Create Branches textures from a single leaf texture with the Branch Editor. • Save your finished tree as a prefab that is convenient to use. What Mtree will do for you: • Automatically create LOD levels. • Create and assign materials to the bark and leaves of your trees. • Make branches react to the colliders of your scene. • Create and render a billboard when you save the tree as prefab. • Bake the ambient occlusion when you save the tree as prefab. • Create vertex color data that will be used to drive the wind simulation and random color variation.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值