7.3实战:创建一个让root都无法删除的文件

发现windows中 有文件删除不了,怎么办?  使用360 强制删除,粉碎文件 
那么在Linux下怎么办?

[root@xuegod63 ~]# touch hack.sh aa.sh 
[root@xuegod63 ~]# ll hack.sh aa.sh 
-rw-r--r-- 1 root root 0 May 24 21:29 aa.sh
-rw-r--r-- 1 root root 0 May 24 21:29 hack.sh
[root@xuegod63 ~]# rm -rf aa.sh

黑客使用xshell悄悄执行在后台添加attr扩展属性:(这个别让学员看到^_^)

[root@xuegod63 ~]# chattr  +i hack.sh

删除文件:

[root@xuegod63 ~]# rm -rf  hack.sh  #发现删除不了

为什么删除不了?

从REHL6 开始,新增加文件系统扩展属性:
命令:chattr   
参数:  a  只能追加内容   ;  i  不能被修改
+a: 只能追加内容  如: echo aaa  >> hack.sh
+i:即Immutable,系统不允许对这个文件进行任何的修改。如果目录具有这个属性,那么任何的进程只能修改目录之下的文件,不允许建立和删除文件。
注:immutable  [ɪˈmju:təbl]  不可改变的  ;  Append [əˈpend] 追加
-i :移除i参数。  -a :移除a参数
解决:

[root@xuegod63 ~]# lsattr hack.sh
----i----------- hack.sh
[root@xuegod63 ~]# chattr -i hack.sh
[root@xuegod63 ~]# echo aa >> hack.sh
[root@xuegod63 ~]# lsattr hack.sh   #查看扩展属性
---------------- hack.sh
[root@xuegod63 ~]# chat
chat    chattr  
[root@xuegod63 ~]# chattr +a hack.sh
[root@xuegod63 ~]# rm -rf hack.sh
rm: 无法删除"hack.sh": 不允许的操作
[root@xuegod63 ~]# echo aaa >> hack.sh

猜你喜欢

转载自blog.csdn.net/weixin_40744265/article/details/89509468
今日推荐