国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 服務(wù)器 > Linux服務(wù)器 > 正文

Red Hat Linux 安全設(shè)置方法

2024-09-05 23:02:15
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
Windows Server 2003 系統(tǒng)配置方案

網(wǎng)絡(luò)安全是指網(wǎng)絡(luò)系統(tǒng)的硬件、軟件及其系統(tǒng)中的數(shù)據(jù)受到保護(hù),不受偶然的或者惡意的原因而遭到破壞、更改、泄露,系統(tǒng)連續(xù)可靠正常地運(yùn)行,網(wǎng)絡(luò)服務(wù)不中斷。

網(wǎng)絡(luò)安全從其本質(zhì)上來(lái)講就是網(wǎng)絡(luò)上的信息安全。從廣義來(lái)說(shuō),凡是涉及到網(wǎng)絡(luò)上信息的保密性、完整性、可用性、真實(shí)性和可控性的相關(guān)技術(shù)和理論都是網(wǎng)絡(luò)安全的研究領(lǐng)域。

1,最小化安全系統(tǒng),刪除不必要的軟件,關(guān)閉不必要的服務(wù).

# ntsysv
以下僅列出需要啟動(dòng)的服務(wù),未列出的服務(wù)一律推薦關(guān)閉,必要運(yùn)行的服務(wù)再逐個(gè)打開(kāi).
atd
crond
irqbalance
microcode_ctl
network
sshd
syslog

2,刪除finger程序,具體方法如下

#rpm –e finger

3,BOIS安全設(shè)置

4,帳號(hào)安全設(shè)置

修改/etc/login.def文件
PASS_MAX_DAYS   120 ?設(shè)置密碼過(guò)期日期
PASS_MIN_DAYS   0   ?設(shè)置密碼最少更改日期
PASS_MIN_LEN    10    ?設(shè)置密碼最小長(zhǎng)度
PASS_WARN_AGE   7  ?設(shè)置過(guò)期提前警告天數(shù)
確保/etc/shadow為root只讀
確保/etc/passwd為root讀寫(xiě)

定期用密碼工具檢測(cè)用戶(hù)密碼強(qiáng)度

5, /etc/exports

如果通過(guò)NFS把文件共享出來(lái),那么一定要配置”/etc/exports”文件,使得訪問(wèn)限制盡可能的嚴(yán)格.這就是說(shuō),不要使用通配符,不允許對(duì)根目錄有寫(xiě)權(quán)限,而且盡可能的只給讀權(quán)限.在/etc/exports文件加入:
/dir/to/export host1.mydomain.com(ro,root_squash)
/dir/to/export host2.mydomain.com(ro,root_squash)
建議最好不要使用NFS.

6,inetd.conf或xinetd.conf
如果是inetd.conf建議注釋掉所有的r開(kāi)頭的程序,exec等

7,TCP_Wrappers
在/etc/hosts.allow中加入允許的服務(wù),在/etc/hosts.deny里加入這么一行ALL:ALL

8,/etc/aliases文件

Aliases文件如果管理錯(cuò)誤或管理粗心就會(huì)造成安全隱患.把定義”decode”這個(gè)別名的行從aliases文件中刪除.
編輯aliases,刪除或注釋下面這些行:
#games: root
#ingres: root
#system: root
#toor: root
#uucp: root
#manager: root
#dumper: root
#operator: root
#decode: root
運(yùn)行/usr/bin/nesaliases重新加載.

9,防止sendmail被沒(méi)有授權(quán)的用戶(hù)濫用

編輯sendmail.cf
把PrivacyOptions=authwarnings
改為PrivacyOptions=authwarnings,noexpn,novrfy

10,不響應(yīng)ping

echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

11,使TCP SYN Cookie保護(hù)生效

Echo 1 > /proc/sys/net/ipv4/tcp_syncookies

12,刪除不必要的用戶(hù)和組用戶(hù)

刪除的用戶(hù),如adm,lp,sync,shutdown,halt,news,uucp,operator,games,gopher等
刪除的組,如adm,lp,news,uucp,games,dip,pppusers,popusers,slipusers等
可以設(shè)置不可更改位
chattr +i /etc/passwd
chattr +i /etc/shadow
chattr +i /etc/group
chattr +i /etc/gshadow

13,防止任何人都可以用su命令成為root

編輯su文件(vi /etc/pam.d/su),加入如下兩行
auth sufficient /lib/security/pam_rootok.so debug
auth required /lib/security/pam_wheel.so group=wheel
把能su為root的用戶(hù)加入wheel組
usermod  -G10 username

14,使Control+Alt+Delete關(guān)機(jī)鍵無(wú)效

編輯inittab文件,注釋掉
Ca:ctrlaltdel:/sbin/shutdown –t3 –r now
運(yùn)行/sbin/init q 使設(shè)置生效

15,創(chuàng)建所有重要的日志文件的硬拷貝

如果服務(wù)器比較重要,可以考慮把ssh,mail,引導(dǎo)信息等打印出來(lái).在/etc/syslog.conf文件中加入一行.:
Authpriv.*;mail.*;local7.*;auth.*;daemon.info /dev/lp0
執(zhí)行/etc/rc.d/init.d/syslog restart
或者把日志發(fā)送到其它服務(wù)器保存

authpriv.*                 /var/log/secure
要把它發(fā)送到192.168.0.2,就可以這樣修改
authpriv.* @192.168.0.2                /var/log/secure

16,改變/etc/rc.d/init.d目錄下的腳本文件的訪問(wèn)許可

chmod –R 700 /etc/rc.d/init.d/*
注意:慎重修改此安全設(shè)置

17,/etc/rc.d/rc.local

把此文件中無(wú)關(guān)的信息全部注釋,不讓任何人看到任何有關(guān)主機(jī)的信息.
刪除/etc下的issue和issue.net

18,帶S位的程序

可以清除s位的程序包括但不限于:
從來(lái)不用的程序;
不希望非root用戶(hù)運(yùn)行的程序;
偶爾用用,但是不介意先用su命令變?yōu)閞oot后再運(yùn)行.
find / -type f /( -perm 04000 –o –perm -02000 /)  -print
chmod a-s 程序名

19,查看系統(tǒng)隱藏文件

find / -name “.*” –print

20,查找任何人都有寫(xiě)權(quán)限的文件和目錄

find / -type f  /( -perm -2  -o perm -20 /) ls
find / -type f  /( -perm -2 –o –perm -20 /) ls

21,查找系統(tǒng)中沒(méi)有主人的文件

find / -nouser –o –nogroup

22,查找.rhosts文件

find /home -name “.rhosts”
如果有,請(qǐng)刪除它.

23,收回系統(tǒng)編譯器的權(quán)限或刪除

如: chmod 700 /usr/bin/gcc

一、磁盤(pán)分區(qū)

1、如果是新安裝系統(tǒng),對(duì)磁盤(pán)分區(qū)應(yīng)考慮安全性:

1)根目錄(/)、用戶(hù)目錄(/home)、臨時(shí)目錄(/tmp)和/var目錄應(yīng)分開(kāi)到不同的磁盤(pán)分區(qū);

2)以上各目錄所在分區(qū)的磁盤(pán)空間大小應(yīng)充分考慮,避免因某些原因造成分區(qū)空間用完而導(dǎo)致系統(tǒng)崩潰;

2、對(duì)于/tmp和/var目錄所在分區(qū),大多數(shù)情況下不需要有suid屬性的程序,所以應(yīng)為這些分區(qū)添加nosuid屬性;

方法一:修改/etc/fstab文件,添加nosuid屬性字。例如:

/dev/hda2 /tmp ext2 exec,dev,nosuid,rw 0 0

方法二:如果對(duì)/etc/fstab文件操作不熟,建議通過(guò)Linuxconf程序來(lái)修改。

運(yùn)行l(wèi)inuxconf程序;

選擇”File systems”下的”Access local drive”;

選擇需要修改屬性的磁盤(pán)分區(qū);

選擇”No setuid programs allowed”選項(xiàng);

根據(jù)需要選擇其它可選項(xiàng);

正常退出。(一般會(huì)提示重新mount該分區(qū))

二、安裝

1、對(duì)于非測(cè)試主機(jī),不應(yīng)安裝過(guò)多的軟件包。這樣可以降低因軟件包而導(dǎo)致出現(xiàn)安全漏洞的可能性。

2、對(duì)于非測(cè)試主機(jī),在選擇主機(jī)啟動(dòng)服務(wù)時(shí)不應(yīng)選擇非必需的服務(wù)。例如routed、ypbind等。

三、安全配置與增強(qiáng)

內(nèi)核升級(jí)。起碼要升級(jí)至2.2.16以上版本。

GNU libc共享庫(kù)升級(jí)。(警告:如果沒(méi)有經(jīng)驗(yàn),不可輕易嘗試。可暫緩。)

關(guān)閉危險(xiǎn)的網(wǎng)絡(luò)服務(wù)。echo、chargen、shell、login、finger、NFS、RPC等

關(guān)閉非必需的網(wǎng)絡(luò)服務(wù)。talk、ntalk、pop-2等

常見(jiàn)網(wǎng)絡(luò)服務(wù)安全配置與升級(jí)

確保網(wǎng)絡(luò)服務(wù)所使用版本為當(dāng)前最新和最安全的版本。

取消匿名FTP訪問(wèn)

去除非必需的suid程序

使用tcpwrapper

使用ipchains防火墻

日志系統(tǒng)syslogd

一些細(xì)節(jié):

1.操作系統(tǒng)內(nèi)部的log file是檢測(cè)是否有網(wǎng)絡(luò)入侵的重要線索,當(dāng)然這個(gè)假定你的logfile不被侵入者所破壞,如果你有臺(tái)服務(wù)器用專(zhuān)線直接連到Internet上,這意味 著你的IP地址是永久固定的地址,你會(huì)發(fā)現(xiàn)有很多人對(duì)你的系統(tǒng)做telnet/ftp登錄嘗試,試著運(yùn)行#more /var/log/secure   grep refused 去檢查。

2. 限制具有SUID權(quán)限標(biāo)志的程序數(shù)量,具有該權(quán)限標(biāo)志的程序以root身份運(yùn)行,是一個(gè)潛在的安全漏洞,當(dāng)然,有些程序是必須要具有該標(biāo)志的,象passwd程序。

3.BIOS安全。設(shè)置BIOS密碼且修改引導(dǎo)次序禁止從軟盤(pán)啟動(dòng)系統(tǒng)。

4. 用戶(hù)口令。用戶(hù)口令是Linux安全的一個(gè)最基本的起點(diǎn),很多人使用的用戶(hù)口令就是簡(jiǎn)單的‘passWord,這等于給侵入者敞開(kāi)了大門(mén),雖然從理論上說(shuō) 沒(méi)有不能確解的用戶(hù)口令,只要有足夠的時(shí)間和資源可以利用。比較好的用戶(hù)口令是那些只有他自己能夠容易記得并理解的一串字符,并且絕對(duì)不要在任何地方寫(xiě)出 來(lái)。

5./etc/eXPorts 文件。如果你使用NFS網(wǎng)絡(luò)文件系統(tǒng)服務(wù),那么確保你的/etc/exports具有最嚴(yán)格的存取權(quán)限設(shè)置,不意味著不要使用任何通配符,不允許root寫(xiě)權(quán)限,mount成只讀文件系統(tǒng)。編輯文件/etc/exports并且加:例如:

/dir/to/export host1.mydomain.com(ro,root_squash)

/dir/to/export host2.mydomain.com(ro,root_squash)

/dir/to/export 是你想輸出的目錄,host.mydomain.com是登錄這個(gè)目錄的機(jī)器名,

ro意味著mount成只讀系統(tǒng),root_squash禁止root寫(xiě)入該目錄。

為了讓上面的改變生效,運(yùn)行/usr/sbin/exportfs -a

6.確信/etc/inetd.conf的所有者是root,且文件權(quán)限設(shè)置為600 。

[root@deep]# chmod 600 /etc/inetd.conf
ENSURE that the owner is root.
[root@deep]# stat /etc/inetd.conf
File: “/etc/inetd.conf”
Size: 2869 Filetype: Regular File
Mode: (0600/-rw——-) Uid: ( 0/ root) Gid: ( 0/ root)
Device: 8,6 Inode: 18219 Links: 1
Access: Wed Sep 22 16:24:16 1999(00000.00:10:44)
Modify: Mon Sep 20 10:22:44 1999(00002.06:12:16)
Change:Mon Sep 20 10:22:44 1999(00002.06:12:16)

編輯/etc/inetd.conf禁止以下服務(wù):

ftp, telnet, shell, login, exec, talk, ntalk, imap, pop-2, pop-3, finger,

auth, etc. 除非你真的想用它。

特別是禁止那些r命令.如果你用ssh/scp,那么你也可以禁止掉telnet/ftp。

為了使改變生效,運(yùn)行#killall -HUP inetd

你也可以運(yùn)行#chattr +i /etc/inetd.conf使該文件具有不可更改屬性。

只有root才能解開(kāi),用命令

#chattr -i /etc/inetd.conf

7. TCP_WRAPPERS

默認(rèn)地,Redhat Linux允許所有的請(qǐng)求,用TCP_WRAPPERS增強(qiáng)你的站點(diǎn)的安全性是舉手

之勞,你可以放入

“ALL: ALL”到/etc/hosts.deny中禁止所有的請(qǐng)求,然后放那些明確允許的請(qǐng)求到

/etc/hosts.allow中,如:

sshd: 192.168.1.10/255.255.255.0 gate.openarch.com

對(duì)IP地址192.168.1.10和主機(jī)名gate.openarch.com,允許通過(guò)ssh連接。

配置完了之后,用tcpdchk檢查

[root@deep]# tcpdchk

tcpchk是TCP_Wrapper配置檢查工具,

它檢查你的tcp wrapper配置并報(bào)告所有發(fā)現(xiàn)的潛在/存在的問(wèn)題。

8. 別名文件aliases

編輯別名文件/etc/aliases(也可能是/etc/mail/aliases),移走/注釋掉下面的行。

# Basic system aliases — these MUST be present.
MAILER-DAEMON: postmaster
postmaster: root
# General redirections for pseudo accounts.
bin: root
daemon: root
#games: root ?remove or comment out.
#ingres: root ?remove or comment out.
nobody: root
#system: root ?remove or comment out.
#toor: root ?remove or comment out.
#uUCp: root ?remove or comment out.
# Well-known aliases.
#manager: root ?remove or comment out.
#dumper: root ?remove or comment out.
#operator: root ?remove or comment out.
# trap decode to catch security attacks
#decode: root
# Person who should get roots mail
#root: marc

最后更新后不要忘記運(yùn)行/usr/bin/newaliases,使改變生效。

9.阻止你的系統(tǒng)響應(yīng)任何從外部/內(nèi)部來(lái)的ping請(qǐng)求。

既然沒(méi)有人能ping通你的機(jī)器并收到響應(yīng),你可以大大增強(qiáng)你的站點(diǎn)的安全性。你可以加下面的一行命令到/etc/rc.d/rc.local,以使每次啟動(dòng)后自動(dòng)運(yùn)行。

echo 1 >; /proc/sys/net/ipv4/icmp_echo_ignore_all

10. 不要顯示出操作系統(tǒng)和版本信息。

如果你希望某個(gè)人遠(yuǎn)程登錄到你的服務(wù)器時(shí)不要顯示操作系統(tǒng)和版本信息,你能改變

/etc/inetd.conf中的一行象下面這樣:

telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd -h

加-h標(biāo)志在最后使得telnet后臺(tái)不要顯示系統(tǒng)信息,而僅僅顯示login:

11.The /etc/host.conf file

編輯host.conf文件(vi /etc/host.conf)且加下面的行:

# Lookup names via DNS first then fall back to /etc/hosts.
order bind,hosts
# We dont have machines with multiple IP addresses on the same card
(like virtual server,IP Aliasing).
multi off
# Check for IP address spoofing.
nospoof on
IP Spoofing: IP-Spoofing is a security exploit that works by tricking
computers in a trust relationship that you are someone that you really arent.

12. The /etc/securetty file
該文件指定了允許root登錄的tty設(shè)備,/etc/securetty被/bin/login程序讀取,它的
格式是一行一個(gè)被允許的名字列表,如你可以編輯/etc/securetty且注釋出下面的行。

tty1
#tty2
#tty3
#tty4
#tty5
#tty6
#tty7
#tty8

意味著root僅僅被允許在tty1終端登錄。

13. 特別的帳號(hào)
禁止所有默認(rèn)的被操作系統(tǒng)本身啟動(dòng)的且不需要的帳號(hào),當(dāng)你第一次裝上系統(tǒng)時(shí)就應(yīng)該做此檢查,Linux提供了各種帳號(hào),你可能不需要,如果你不需要這個(gè)帳號(hào),就移走它,你有的帳號(hào)越多,就越容易受到攻擊。
為刪除你系統(tǒng)上的用戶(hù),用下面的命令:

[root@deep]# userdel username
為刪除你系統(tǒng)上的組用戶(hù)帳號(hào),用下面的命令:
[root@deep]# groupdel username
在終端上打入下面的命令刪掉下面的用戶(hù)。
[root@deep]# userdel adm
[root@deep]# userdel lp
[root@deep]# userdel sync
[root@deep]# userdel shutdown
[root@deep]# userdel halt
[root@deep]# userdel mail
如果你不用sendmail服務(wù)器,procmail.mailx,就刪除這個(gè)帳號(hào)。
[root@deep]# userdel news
[root@deep]# userdel uucp
[root@deep]# userdel operator
[root@deep]# userdel games
如果你不用X windows 服務(wù)器,就刪掉這個(gè)帳號(hào)。
[root@deep]# userdel gopher
[root@deep]# userdel ftp
如果你不允許匿名FTP,就刪掉這個(gè)用戶(hù)帳號(hào)。
打入下面的命令刪除組帳號(hào)
[root@deep]# groupdel adm
[root@deep]# groupdel lp
[root@deep]# groupdel mail
如不用Sendmail服務(wù)器,刪除這個(gè)組帳號(hào)
[root@deep]# groupdel news
[root@deep]# groupdel uucp
[root@deep]# groupdel games
如你不用X Windows,刪除這個(gè)組帳號(hào)
[root@deep]# groupdel dip
[root@deep]# groupdel pppusers
[root@deep]# groupdel popusers
如果你不用POP服務(wù)器,刪除這個(gè)組帳號(hào)
[root@deep]# groupdel slipusers
用下面的命令加需要的用戶(hù)帳號(hào)
[root@deep]# useradd username
用下面的命令改變用戶(hù)口令
[root@deep]# passwd username

用chattr命令給下面的文件加上不可更改屬性。
[root@deep]# chattr +i /etc/passwd
[root@deep]# chattr +i /etc/shadow
[root@deep]# chattr +i /etc/group
[root@deep]# chattr +i /etc/gshadow

14. 阻止任何人su作為root.
如果你不想任何人能夠su作為root,你能編輯/etc/pam.d/su加下面的行:

auth sufficient /lib/security/pam_rootok.so debug
auth required /lib/security/pam_wheel.so group=isd

意味著僅僅isd組的用戶(hù)可以su作為root.
然后,如果你希望用戶(hù)admin能su作為root.就運(yùn)行下面的命令。

[root@deep]# usermod -G10 admin

16. 資源限制
對(duì)你的系統(tǒng)上所有的用戶(hù)設(shè)置資源限制可以防止DoS類(lèi)型攻擊(denial of service attacks)
如最大進(jìn)程數(shù),內(nèi)存數(shù)量等。例如,對(duì)所有用戶(hù)的限制象下面這樣:

編輯/etc/security/limits.con加:
* hard core 0
* hard rss 5000
* hard nproc 20

你也必須編輯/etc/pam.d/login文件加/檢查這一行的存在。

session required /lib/security/pam_limits.so

上面的命令禁止core files“core 0”,限制進(jìn)程數(shù)為“nproc 50“,且限制內(nèi)存使用
為5M“rss 5000”。

17. The /etc/lilo.conf file

a) Add: restricted
加這一行到每一個(gè)引導(dǎo)映像下面,就這表明如果你引導(dǎo)時(shí)用(linux single),則需要一個(gè)password.

b) Add: password=some_password
當(dāng)與restricted聯(lián)合用,且正常引導(dǎo)時(shí),需要用戶(hù)輸入密碼,你也要確保lilo.conf
文件不能被不屬于root的用戶(hù)可讀,也免看到密碼明文。下面是例子:

編輯/etc/lilo.conf加:
boot=/dev/sda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
Default=linux
restricted ?add this line.
password=some_password ?add this line.
image=/boot/vmlinuz-2.2.12-20
label=linux
initrd=/boot/initrd-2.2.12-10.img
root=/dev/sda6
read-only
[root@deep]# chmod 600 /etc/lilo.conf (不再能被其他用戶(hù)可讀).
[root@deep]# /sbin/lilo -v (更新lilo配置).
[root@deep]# chattr +i /etc/lilo.conf(阻止該文件被修改)

18. 禁止 Control-Alt-Delete 重啟動(dòng)機(jī)器命令

[root@deep]# vi /etc/inittab
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
To
#ca::ctrlaltdel:/sbin/shutdown -t3 -r now
[root@deep]# /sbin/init q

19. 重新設(shè)置/etc/rc.d/init.d/目錄下所有文件的許可權(quán)限
[root@deep]# chmod -R 700 /etc/rc.d/init.d/*
僅僅root可以讀,寫(xiě),執(zhí)行上述所有script file.

20. The /etc/rc.d/rc.local file
默認(rèn)地,當(dāng)你login到linux server時(shí),它告訴你linux版本名,內(nèi)核版本名和服務(wù)器
主機(jī)名。它給了你太多的信息,如果你就希望得到提示login: ,編輯/etc/rc.d/rc.local放#在下面的行前面:

# This will overwrite /etc/issue at every boot. So, make any changes you
# want to make to /etc/issue here or you will lose them when you reboot.
#echo “” >; /etc/issue
#echo “$R” >;>; /etc/issue
#echo “Kernel $(uname -r) on $a $(uname -m)” >;>; /etc/issue
#
#cp -f /etc/issue /etc/issue.net
#echo >;>; /etc/issue

然后,做下面的事情:

[root@deep]# rm -f /etc/issue
[root@deep]# rm -f /etc/issue.net
[root@deep]# touch /etc/issue
[root@deep]# touch /etc/issue.net

21. 被root擁有的程序的位。

移走那些被root擁有程序的s位標(biāo)志,當(dāng)然有些程序需要這個(gè),用命令‘chmod a-s'完成這個(gè)。

注:前面帶(*)號(hào)的那些程序一般不需要擁有s位標(biāo)志。

[root@deep]# find / -type f /( -perm -04000 -o -perm -02000 /) /-exec ls –lg {} /;
-rwsr-xr-x 1 root root 33120 Mar 21 1999 /usr/bin/at
*-rwsr-xr-x 1 root root 30560 Apr 15 20:03 /usr/bin/chage
*-rwsr-xr-x 1 root root 29492 Apr 15 20:03 /usr/bin/gpasswd
-rwsr-xr-x 1 root root 3208 Mar 22 1999 /usr/bin/disable-paste
-rwxr-sr-x 1 root man 32320 Apr 9 1999 /usr/bin/man
-r-s–x–x 1 root root 10704 Apr 14 17:21 /usr/bin/passwd
-rws–x–x 2 root root 517916 Apr 6 1999 /usr/bin/suidperl
-rws–x–x 2 root root 517916 Apr 6 1999 /usr/bin/sperl5.00503
-rwxr-sr-x 1 root mail 11432 Apr 6 1999 /usr/bin/lockfile
-rwsr-sr-x 1 root mail 64468 Apr 6 1999 /usr/bin/procmail
-rwsr-xr-x 1 root root 21848 Aug 27 11:06 /usr/bin/crontab
-rwxr-sr-x 1 root slocate 15032 Apr 19 14:55 /usr/bin/slocate
*-r-xr-sr-x 1 root tty 6212 Apr 17 11:29 /usr/bin/wall
*-rws–x–x 1 root root 14088 Apr 17 12:57 /usr/bin/chfn
*-rws–x–x 1 root root 13800 Apr 17 12:57 /usr/bin/chsh
*-rws–x–x 1 root root 5576 Apr 17 12:57 /usr/bin/newgrp
*-rwxr-sr-x 1 root tty 8392 Apr 17 12:57 /usr/bin/write
-rwsr-x— 1 root squid 14076 Oct 7 14:48 /usr/lib/squid/pinger
-rwxr-sr-x 1 root utmp 15587 Jun 9 09:30 /usr/sbin/utempter
*-rwsr-xr-x 1 root root 5736 Apr 19 15:39 /usr/sbin/usernetctl
*-rwsr-xr-x 1 root bin 16488 Jul 6 09:35 /usr/sbin/traceroute
-rwsr-sr-x 1 root root 299364 Apr 19 16:38 /usr/sbin/sendmail
-rwsr-xr-x 1 root root 34131 Apr 16 18:49 /usr/libexec/pt_chown
-rwsr-xr-x 1 root root 13208 Apr 13 14:58 /bin/su
*-rwsr-xr-x 1 root root 52788 Apr 17 15:16 /bin/mount
*-rwsr-xr-x 1 root root 26508 Apr 17 20:26 /bin/umount
*-rwsr-xr-x 1 root root 17652 Jul 6 09:33 /bin/ping
-rwsr-xr-x 1 root root 20164 Apr 17 12:57 /bin/login
*-rwxr-sr-x 1 root root 3860 Apr 19 15:39 /sbin/netreport
-r-sr-xr-x 1 root root 46472 Apr 17 16:26 /sbin/pwdb_chkpwd
[root@deep]# chmod a-s /usr/bin/chage
[root@deep]# chmod a-s /usr/bin/gpasswd
[root@deep]# chmod a-s /usr/bin/wall
[root@deep]# chmod a-s /usr/bin/chfn
[root@deep]# chmod a-s /usr/bin/chsh
[root@deep]# chmod a-s /usr/bin/newgrp
[root@deep]# chmod a-s /usr/bin/write
[root@deep]# chmod a-s /usr/sbin/usernetctl
[root@deep]# chmod a-s /usr/sbin/traceroute
[root@deep]# chmod a-s /bin/mount
[root@deep]# chmod a-s /bin/umount
[root@deep]# chmod a-s /bin/ping
[root@deep]# chmod a-s /sbin/netreport

你可以用下面的命令查找所有帶s位標(biāo)志的程序:

[root@deep]# find / -type f /( -perm -04000 -o -perm -02000 /) /-exec ls -lg {} /;

>; suid-sgid-results

把結(jié)果輸出到文件suid-sgid-results中。

為了查找所有可寫(xiě)的文件和目錄,用下面的命令:

[root@deep]# find / -type f /( -perm -2 -o -perm -20 /) -exec ls -lg {} /; >; ww-files-results

[root@deep]# find / -type d /( -perm -2 -o -perm -20 /) -exec ls -ldg {} /; >; ww-directories-results

用下面的命令查找沒(méi)有擁有者的文件:

[root@deep]# find / -nouser -o -nogroup >; unowed-results

用下面的命令查找所有的.rhosts文件:

[root@deep]# find /home -name .rhosts >; rhost-results

建議替換的常見(jiàn)網(wǎng)絡(luò)服務(wù)應(yīng)用程序

WuFTPD

WuFTD從1994年就開(kāi)始就不斷地出現(xiàn)安全漏洞,黑客很容易就可以獲得遠(yuǎn)程root訪問(wèn)(Remote Root Access)的權(quán)限,而且很多安全漏洞甚至不需要在FTP服務(wù)器上有一個(gè)有效的帳號(hào)。最近,WuFTP也是頻頻出現(xiàn)安全漏洞。

它的最好的替代程序是ProFTPD。ProFTPD很容易配置,在多數(shù)情況下速度也比較快,而且它的源代碼也比較干凈(緩沖溢出的錯(cuò)誤比較少)。 有許多重要的站點(diǎn)使用ProFTPD。sourceforge.net就是一個(gè)很好的例子(這個(gè)站點(diǎn)共有3,000個(gè)開(kāi)放源代碼的項(xiàng)目,其負(fù)荷并不小 啊!)。一些Linux的發(fā)行商在它們的主FTP站點(diǎn)上使用的也是ProFTPD,只有兩個(gè)主要Linux的發(fā)行商(SuSE和Caldera)使用 WuFTPD。

ProFTPD的另一個(gè)優(yōu)點(diǎn)就是既可以從inetd運(yùn)行又可以作為單獨(dú)的daemon運(yùn)行。這樣就可以很容易解決inetd帶來(lái)的一些問(wèn)題,如:拒 絕服務(wù)的攻擊(denial of service attack),等等。系統(tǒng)越簡(jiǎn)單,就越容易保證系統(tǒng)的安全。WuFTPD要么重新審核一遍全部的源代碼(非常困難),要么完全重寫(xiě)一遍代碼,否則 WuFTPD必然要被ProFTPD代替。

Telnet

Telnet是非常非常不安全的,它用明文來(lái)傳送密碼。它的安全的替代程序是OpenSSH。

OpenSSH在Linux上已經(jīng)非常成熟和穩(wěn)定了,而且在Windows平臺(tái)上也有很多免費(fèi)的客戶(hù)端軟件。Linux的發(fā)行商應(yīng)該采用 OpenBSD的策略:安裝OpenSSH并把它設(shè)置為默認(rèn)的,安裝Telnet但是不把它設(shè)置成默認(rèn)的。對(duì)于不在美國(guó)的Linux發(fā)行商,很容易就可以 在Linux的發(fā)行版中加上OpenSSH。美國(guó)的Linux發(fā)行商就要想一些別的辦法了(例如:Red Hat在德國(guó)的FTP服務(wù)器上(ftp.redhat.de)就有最新的OpenSSH的rpm軟件包)。

Telnet是無(wú)可救藥的程序。要保證系統(tǒng)的安全必須用OpenSSH這樣的軟件來(lái)替代它。

Sendmail

最近這些年,Sendmail的安全性已經(jīng)提高很多了(以前它通常是黑客重點(diǎn)攻擊的程序)。然而,Sendmail還是有一個(gè)很?chē)?yán)重的問(wèn)題。一旦出 現(xiàn)了安全漏洞(例如:最近出現(xiàn)的Linux內(nèi)核錯(cuò)誤),Sendmail就是被黑客重點(diǎn)攻擊的程序,因?yàn)镾endmail是以root權(quán)限運(yùn)行而且代碼很 龐大容易出問(wèn)題。

幾乎所有的Linux發(fā)行商都把Sendmail作為默認(rèn)的配置,只有少數(shù)幾個(gè)把Postfix或Qmail作為可選的軟件包。但是,很少有Linux的發(fā)行商在自己的郵件服務(wù)器上使用Sendmail。SuSE和Red Hat都使用基于Qmail的系統(tǒng)。

Sendmail并不一定會(huì)被別的程序完全替代。但是它的兩個(gè)替代程序Qmail和Postfix都比它安全、速度快,而且特別是Postfix比它容易配置和維護(hù)。

su

su是用來(lái)改變當(dāng)前用戶(hù)的ID,轉(zhuǎn)換成別的用戶(hù)。你可以以普通用戶(hù)登錄,當(dāng)需要以root身份做一些事的時(shí)候,只要執(zhí)行“su”命令,然后輸入 root的密碼。su本身是沒(méi)有問(wèn)題的,但是它會(huì)讓人養(yǎng)成不好的習(xí)慣。如果一個(gè)系統(tǒng)有多個(gè)管理員,必須都給他們r(jià)oot的口令。

su的一個(gè)替代程序是sudo。Red Hat 6.2中包含這個(gè)軟件。sudo允許你設(shè)置哪個(gè)用戶(hù)哪個(gè)組可以以root身份執(zhí)行哪些程序。你還可以根據(jù)用戶(hù)登錄的位置對(duì)他們加以限制(如果有人“破”了 一個(gè)用戶(hù)的口令,并用這個(gè)帳號(hào)從遠(yuǎn)程計(jì)算機(jī)登錄,你可以限制他使用sudo)。Debian也有一個(gè)類(lèi)似的程序叫super,與sudo比較各有優(yōu)缺點(diǎn)。

讓用戶(hù)養(yǎng)成良好的習(xí)慣。使用root帳號(hào)并讓多個(gè)人知道root的密碼并不是一個(gè)好的習(xí)慣。這就是被入侵的原因,因?yàn)樗卸鄠€(gè)系統(tǒng)管理員他們都有root的特權(quán)。一個(gè)亂成一團(tuán)的系統(tǒng)是很容易被入侵的。

named

大部分Linux的發(fā)行商都解決了這個(gè)問(wèn)題。named以前是以root運(yùn)行的,因此當(dāng)named出現(xiàn)新的漏洞的時(shí)候,很容易就可以入侵一些很重要 的計(jì)算機(jī)并獲得root權(quán)限。現(xiàn)在只要用命令行的一些參數(shù)就能讓named以非root的用戶(hù)運(yùn)行。而且,現(xiàn)在絕大多數(shù)Linux的發(fā)行商都讓 named以普通用戶(hù)的權(quán)限運(yùn)行。命令格式通常為:named -u ; -g ;

INN

在INN的文檔中已經(jīng)明確地指出:“禁止這項(xiàng)功能(verifycancels),這項(xiàng)功能是沒(méi)有用的而且將被除掉”。大約在一個(gè)月前,一個(gè)黑客發(fā) 布了當(dāng) “verifycancels”生效的時(shí)候入侵INN的方法。Red Hat是把“verifycancels”設(shè)為有效的。任何setuid/setgid的程序或網(wǎng)絡(luò)服務(wù)程序都要正確地安裝并且進(jìn)行檢查以保證盡量沒(méi)有安 全漏洞。

安全守則

1. 廢除系統(tǒng)所有默認(rèn)的帳號(hào)和密碼。

2. 在用戶(hù)合法性得到驗(yàn)證前不要顯示公司題頭、在線幫助以及其它信息。

3. 廢除“黑客”可以攻擊系統(tǒng)的網(wǎng)絡(luò)服務(wù)。

4. 使用6到8位的字母數(shù)字式密碼。

5. 限制用戶(hù)嘗試登錄到系統(tǒng)的次數(shù)。

6. 記錄違反安全性的情況并對(duì)安全記錄進(jìn)行復(fù)查。

7. 對(duì)于重要信息,上網(wǎng)傳輸前要先進(jìn)行加密。

8. 重視專(zhuān)家提出的建議,安裝他們推薦的系統(tǒng)“補(bǔ)丁”。

9. 限制不需密碼即可訪問(wèn)的主機(jī)文件。

10.修改網(wǎng)絡(luò)配置文件,以便將來(lái)自外部的TCP連接限制到最少數(shù)量的端口。不允許諸如tftp,sunrpc,printer,rlogin或rexec之類(lèi)的協(xié)議。

11.用upas代替sendmail。sendmail有太多已知漏洞,很難修補(bǔ)完全。

12.去掉對(duì)操作并非至關(guān)重要又極少使用的程序。

13.使用chmod將所有系統(tǒng)目錄變更為711模式。這樣,攻擊者們將無(wú)法看到它們當(dāng)中有什么東西,而用戶(hù)仍可執(zhí)行。

14.只要可能,就將磁盤(pán)安裝為只讀模式。其實(shí),僅有少數(shù)目錄需讀寫(xiě)狀態(tài)。

15.將系統(tǒng)軟件升級(jí)為最新版本。老版本可能已被研究并被成功攻擊,最新版本一般包括了這些問(wèn)題的補(bǔ)救。

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 鹤峰县| 定兴县| 同心县| 甘南县| 湛江市| 沐川县| 泸西县| 华阴市| 嘉鱼县| 百色市| 蒲江县| 蒙城县| 车险| 黔江区| 和林格尔县| 义马市| 绥德县| 都江堰市| 日土县| 广水市| 宣化县| 丹棱县| 灌南县| 德州市| 长葛市| 齐齐哈尔市| 大田县| 滨海县| 鄂尔多斯市| 金昌市| 澄城县| 右玉县| 迁安市| 湖州市| 桦甸市| 西吉县| 中西区| 安吉县| 东平县| 香格里拉县| 定南县|