查找沒有所有者的文件

如果***獲得並改變了一些系統文件,這些系統文件就會成爲安全漏洞。任何人都有寫權

限的目錄也同樣有危險,因爲***可以根據他們的需要自由地添加或刪除文件。在正常情況下

有些文件是可寫的,包括一些“ /dev”目錄下的文件和符號連接。

在系統中定位任何人都有寫權限的文件和目錄可以使用下面的命令:

[root@Aid]# find / -type f \( -perm -2 -o -perm -20 \) -exec ls -lg {} \;

[root@Aid]# find / -type d \( -perm -2 -o -perm -20 \) -exec ls -ldg {} \;


注意  Tripware軟件這樣的文件和目錄完整性檢查器能夠掃描、管理和方便地發現改變過的任何人都有寫權限的文件。

發現沒有所有者的文件就意味着有******系統了。不能允許沒有所有者的文件存在。如果在系統中發現了沒有所有者的文件或目錄,先查看它的完整性,如果一切正常,給它一個所有者。有時候卸載程序可能會出現一些沒有所有者的文件或目錄,在這種情況下可以把這些文件和目錄刪除掉。

定位系統中沒有所有者的文件可以使用下面的命令:

[root@Aid]# find / -nouser -o -nogroup

注意 不用管“ /dev”目錄下的那些文件。

查找“ .rhosts”文件是日常管理工作的一部分,因爲這些文件不允許存在於系統中。記住,

***只要有系統中的一個賬號就可能***整個網絡。

可以用下面的命令定位系統中的“ .rhosts”文件:

[root@Aid]# find /home -name .rhosts

也可以用一個 cron任務定期地查看、報告和刪除 $HOME/.rhosts文件。同時,也必須讓用戶

知道會經常地進行這種審覈。

r o o t身份在“ / e t c / c r o n . d a i l y”目錄下,創建“ f i n d _ r h o s t s _ f i l e s”腳本文件( t o u c h

/etc/cron.daily/find_rhosts_files),並在腳本文件中加入下面幾行:

#!/bin/sh

/usr/bin/find /home -name .rhosts | (cat <<EO

.This is an automated report of possible existent ".rhosts" files on the server

deep.openarch.com, generated by the find utility command.

New detected ".rhosts" files under the "/home" directory include:

EOF

Cat

) | /bin/mail -s "Content of .rhosts file audit report" root

然後,讓這個腳本可執行,把所有者和組設置成 root

[root@Aid]# chmod 755 /etc/cron.daily/find_rhosts_files

[root@Aid]# chown 0.0 /etc/cron.daily/find_rhosts_files

每天都會有一份主題爲 Content of .rhosts file audit report的郵件發給 root,報告新發現的

.rhosts”文件。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章