免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12345
最近访问板块 发新帖
楼主: 苦中作乐
打印 上一主题 下一主题

如何隐藏自己的进程? [复制链接]

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
41 [报告]
发表于 2006-11-07 10:47 |只看该作者
原帖由 albcamus 于 2006-11-7 10:43 发表


其实意思差不多,总之就是防范万一入侵者穿过防火墙、绕过IDS,拿到了机器的root权限,还可以限制他做一些事情。  

root:0:0:root:/root:/bin/hell

论坛徽章:
0
42 [报告]
发表于 2006-11-07 11:20 |只看该作者
看了关于task_struct、file、inode等结构,总结了一下很多地方不明白,下面是我的一些理解,不知道对不对,请各位指点一下:

task_struct这个数据结构与文件相关的一个成员有两个

  1. /* filesystem information */
  2.         struct fs_struct *fs;
  3. /* open file information */
  4.         struct files_struct *files;
复制代码

其中:
struct fs_struct主要是作为文件系统的一些内容,包括根目录、当前工作目录、mount的文件系统信息、初始化umask等。
struct files_struct存储了当前进程所有打开的文件信息:

  1. /*
  2. * Open file table structure
  3. */
  4. struct files_struct {
  5.         atomic_t count;
  6.         spinlock_t file_lock;     /* Protects all the below members.  Nests inside tsk->alloc_lock */
  7.         int max_fds;
  8.         int max_fdset;
  9.         int next_fd;
  10.         struct file ** fd;      /* current fd array */
  11.         fd_set *close_on_exec;
  12.         fd_set *open_fds;
  13.         fd_set close_on_exec_init;
  14.         fd_set open_fds_init;
  15.         struct file * fd_array[NR_OPEN_DEFAULT];
  16. };
复制代码

其中包括了指向文件对象数组的指针struct file ** fd,文件对象file是直接和文件内容相关联的

  1. struct file {
  2.         struct list_head        f_list;
  3.         struct dentry           *f_dentry;
  4.         struct vfsmount         *f_vfsmnt;
  5.         struct file_operations  *f_op;
  6.         atomic_t                f_count;
  7.         unsigned int            f_flags;
  8.         mode_t                  f_mode;
  9.         int                     f_error;
  10.         loff_t                  f_pos;
  11.         struct fown_struct      f_owner;
  12.         unsigned int            f_uid, f_gid;
  13.         struct file_ra_state    f_ra;

  14.         unsigned long           f_version;
  15.         void                    *f_security;
  16.         
  17.         /* needed for tty driver, and maybe others */
  18.         void                    *private_data;

  19. #ifdef CONFIG_EPOLL
  20.         /* Used by fs/eventpoll.c to link all the hooks to this file */
  21.         struct list_head        f_ep_links;
  22.         spinlock_t              f_ep_lock;
  23. #endif /* #ifdef CONFIG_EPOLL */
  24.         struct address_space    *f_mapping;
  25. };
复制代码

其中最重要的是struct file_operations  *f_op,描述了对文件对象的操作,也就是读写文件的一些注册处理函数

  1. struct file_operations {
  2.         struct module *owner;
  3.         loff_t (*llseek) (struct file *, loff_t, int);
  4.         ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
  5.         ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
  6.         ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
  7.         ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t);
  8.         int (*readdir) (struct file *, void *, filldir_t);
  9.         unsigned int (*poll) (struct file *, struct poll_table_struct *);
  10.         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
  11.         int (*mmap) (struct file *, struct vm_area_struct *);
  12.         int (*open) (struct inode *, struct file *);
  13.         int (*flush) (struct file *);
  14.         int (*release) (struct inode *, struct file *);
  15.         int (*fsync) (struct file *, struct dentry *, int datasync);
  16.         int (*aio_fsync) (struct kiocb *, int datasync);
  17.         int (*fasync) (int, struct file *, int);
  18.         int (*lock) (struct file *, int, struct file_lock *);
  19.         ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
  20.         ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
  21.         ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
  22.         ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
  23.         unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
  24.         int (*check_flags)(int);
  25.         int (*dir_notify)(struct file *filp, unsigned long arg);
  26.         int (*flock) (struct file *, int, struct file_lock *);
  27. };
复制代码

再有一个重要的结构就是inode,文件系统管理一个文件的所有信息都存储在inode结构中,是一个静态的东西,即只要文件存在其相应的inode信息就存在,文件的名字可以改变,但是其inode号是不会变的。而上面的file结构是为了和打开文件进程交互的,只有当文件被某一个进程打开的时候才创建一个file结构,如果同一个文件被不同的进程分别打开,那么内存中会维护两个不同的file结构,file结构中的f_op初始化的时候来自inode的i_fop,进程这个时候才可以对文件进行基本的读写操作。这个时候可以修改f_op中的注册函数地址为我们自己的函数,就可以修改文件的操作函数集。

上面是我自己这几天看书的一些理解,不知道对不对!

论坛徽章:
0
43 [报告]
发表于 2006-11-07 11:28 |只看该作者

回复 42楼 苦中作乐 的帖子

看Documentation/filesystems/vfs.txt, 内核版有我翻译的版本。 不过ULK2/ULK3讲得也很好,不必这文档差

论坛徽章:
0
44 [报告]
发表于 2006-11-07 11:56 |只看该作者
谢谢了,去看看,我看得是《Linux设备驱动程序》V3!

论坛徽章:
0
45 [报告]
发表于 2006-11-07 12:38 |只看该作者
好帖,顶起来学习~~~

论坛徽章:
0
46 [报告]
发表于 2006-11-03 21:07 |只看该作者
是不是可以检测进程的行为。即使得到root用户,对进程进行操作,如果该操作不属于我们规定的行为,我们就可以定义为是进程的异常,取消该行为。现在在windows下有不少这样类似的软件,如sana公司的产品。我也是正在学习中,不是很懂
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP