如何防止移动设备对系统的造成危险?

来源:互联网 发布:淘宝求好评短信 编辑:程序博客网 时间:2024/05/16 10:44

通常linux中,默认创建文件系统是不允许设备文件挂载的,但是有时候我们会手创建文件系统,挂载此文件系统并不会刻意的去设置禁用suid权限,因此对linux系统造成了一定的威胁。下面通过一个示例演示:
[root@centos7 ~]# mkdir /mnt/sde1 #创建挂载点
[root@centos7 ~]# mount /dev/sde1 /mnt/sde1/ #挂载分区
[root@centos7 ~]# mount #查看挂载情况
/dev/sde1 on /mnt/sde1 type ext3 (rw,relatime,seclabel,data=ordered)
[root@centos7 ~]# cd /mnt/sde1/
[root@centos7 sde1]# cp /bin/cat . #复制命令
[root@centos7 sde1]# ls
cat lost+found
[root@centos7 sde1]# chmod u+s cat #添加特殊权限
[root@centos7 sde1]# ls
cat lost+found
[root@centos7 sde1]# su wang #切换到普通用户测试
[wang@centos7 sde1]$ cd /mnt/sde1/
[wang@centos7 sde1]$ ls
cat lost+found
[wang@centos7 sde1]$ ./cat /etc/shadow

若果我们使用移动设备的话,如果有人把移动设备复制命令并添加了特殊权限。对linux系统造成一定的威胁,所以建议不要随便使用别人的移动设备。
怎么去禁止这种情况的发生呢?
[root@centos7 ~]# mount -o remount,nosuid /dev/sde1
禁用挂载点nosuid权限,就解决了这个问题。

模拟一个移动U盘环境:
在CentOS7,模拟一个U盘
[root@centos7 ~]# blkid testfile
[root@centos7 ~]# mkdir /mnt/test
[root@centos7 ~]# mount /root/testfile /mnt/test/
[root@centos7 ~]# cd !$
cd /mnt/test/
[root@centos7 test]# cp /bin/vi .
[root@centos7 test]# cp /bin/cat .
[root@centos7 test]# chmod u+s *
[root@centos7 test]# umount /mnt/test/
[root@centos7 ~]# scp testfile IP:

切换至CentSO6上
[root@localhost~]#mount -o loop testfile /mnt/test/
[root@localhost~]#cd /mnt/test/
[root@localhost/mnt/test]#ls
cat lost+found vi
[root@localhost~]#cd /mnt/test/
[root@localhost/mnt/test]#ls
cat lost+found vi
[root@localhost/mnt/test]#su wang
[wang@localhost test]cd/mnt/test/[wang@localhosttest] ./vi /etc/shadow

阅读全文
0 0