Linux入侵监测系统LIDS原理(2)

http://tech.ddvip.com   2006年07月04日    社区交流 收藏本文

本文详细介绍Linux入侵监测系统LIDS原理(2)

  LIDS保护数据结构
  在分析完Linux文件系统后,让我们来看看LIDS是如何容VFS来保护文件和目录的。
在/usr/src/Linux/fs/lids.c
struct secure_ino {
unsigned long int ino; /* the inode number */
kdev_t dev; /* the dev number */
int type; /* the file type */
};

  上面的结构用一对来存储保护文件或目录的结点。“type”是用来标明保护结点文件类型的。
  LIDS有4种类型
  在/usr/src/Linux/include/Linux/fs.h
  #define LIDS_APPEND 1 /* APPEND ONLY FILE */
  #define LIDS_READONLY 2 /* Read Only File */
  #define LIDS_DEVICE 3 /* Protect MBR Writing to device */
  #define LIDS_IGNORE 4 /* Ignore the protection */
  通过secure_ino结构,我们能很容易的初使化保护的文件或是在内核里执行以下函数。

在/usr/src/Linux/fs/lids.c
int lids_add_inode(unsigned long int inode ,kdev_t dev , int type)
{
if ( last_secure == (LIDS_MAX_INODE-1))
return 0;
secure[last_secure].ino = inode;
secure[last_secure].dev = dev;
secure[last_secure].type = type;
secure[++last_secure].ino = 0;
#ifdef VFS_SECURITY_DEBUG
printk("lids_add_inode : return %d
",last_secure);
#endif
return last_secure;
}

  就象你在上面代码上可以看到的,给secure_ino加到一个结点上是非常容易的。被保护的结点会在系统启动的时候初使化。初使化程序在/usr/src/Linux/fs/lids.c的init_vfs_security()里。
  现在,让我们看看LIDS是如何来检查是否一个结点已经受到保护。

作者:第七乐章    责编:豆豆技术应用

正在加载评论...