8. 文件权限 8.2 删除所有不使用的sgid文件 8.3 删除/etc下所有组可写文件 8.4 删除/etc下所有world可写文件 8.5 将权限为rw-rw-rw-的文件改为rw-r—r— 8.6 改变rwxrwxrwx文件的权限 8.7 查找world,group可写的目录 8.8 确保每个root启动的脚本属于root 8.9 确保所有cron行为有记录 8.10 改变utmp,utmpx的权限 8.11 查找无用户文件 8.12 查找无组文件 8.13 改变/var/cron权限 9.日志和监控 9.2 记录所有inetd服务 9.3 修改syslog.conf 9.4 创建/var/adm/loginlog来记录登陆失败信息 9.4 安装Tripwire 9.5 安装IDS工具,比如snort 二、应用程序安全配置 2. NFS服务 2.2 如必须使用,则设置nfs特殊tcp,udp端口 2.3 打开nfs port monitoring功能 3. NIS服务 4. Ftp服务 4.4 创建ftp banner 4.5 创建/etc/ftpusers文件 5. Telnet服务
8.1 删除所有不使用的suid文件
列出系统中所有 suid 文件
find / -type f \( -perm -4000 \) –exec ls –al {} \;
find / -type f \( -perm -4000 \) –exec ls –al {} \; > $HOME/search-4-suid-files.txt
首先备份 suid 文件:
mkdir /opt/backup/suid
find / -type f \( -perm -4000 \) -print |cpio -pudm /opt/backup/suid
删除前建立tar备份,不要删除suid-files.tar!!
cd /opt/backup; tar –cvpf suid-files.tar /opt/backup/suid/*
rm –r /opt/backup/suid
去除所有suid 文件中的suid 位
find / -type f \( -perm -4000 \) –exec chmod –s {} \;
再查一遍
find / -type f \( -perm –4000 \) –exec ls –al {} \;
对一些常用文件建立suid 位
chmod u+s /usr/bin/su
chmod u+s /usr/bin/passwd
chmod u+s /usr/bin/ps
列出系统中所有 suid 文件
find / -type f \( -perm -2000 \) –exec ls –al {} \;
find / -type f \( -perm -2000 \) –exec ls –al {} \; > $HOME/search-4-sgid-files.txt
首先备份 sgid 文件:
mkdir /opt/backup/sgid
find / -type f \( -perm -2000 \) -print |cpio -pudm /opt/backup/sgid
删除前建立tar备份,不要删除sgid-files.tar!!
cd /opt/backup; tar –cvpf sgid-files.tar /opt/backup/sgid/*
rm –r /opt/backup/sgid
去除所有sgid 文件中的sgid 位
find / -type f \( -perm -2000 \) –exec chmod –s {} \;
再查一遍
find / -type f \( -perm –2000 \) –exec ls –al {} \;
对一些常用文件建立sgid 位
find /etc -type f \( -perm -20 \) –exec ls –al {} \;
find /etc -type f \( -perm -20 \) –exec ls –al {} \; > search-4-group-writeable-in-etc.txt
/etc下不应有组可写文件,去掉写权限
find /etc -type f \( -perm –20 \) –exec chmod g-w {} \;
find /etc -type f \( -perm -2 \) –exec xargs ls –als {} \;
find /etc -type f \( -perm -2 \) –exec xargs ls –als {} \; > search-4-world-writeable-in-etc.txt
/etc下不应有world可写文件,去掉写权限
find /etc -type f \( -perm –2 \) –exec xargs chmod w-w {} \;
find / -type f -perm 666 |xargs ls -al > perm-666-before-change.txt
decide if one of these files are critical
find / -type f -perm 666 –exec chmod 644 {} \;
find / -type f -perm 666 –exec xargs ls –al {} \; > perm-666-after-change.txt
find / -type f -perm 777 –exec xargs ls -al {} \; > perm-777-before-change.txt
decide if one of these files are critical
find / -type f -perm 777 –exec xargs chmod 755 {} \;
find / -type f -perm 777 –exec xargs ls -al {} \; > perm-777-after-change.txt
find / -type d \( -perm 2 \) –print > search-4-world-writeable-directories.txt
find /etc -type f \( -perm -20 \) –print > search-4-group-writeable-dir.txt
首先查找所有启动脚本的属主
find /etc -type f -print | grep rc | egrep -v "skel|tty|mail|snmp|Mail" | xargs ls -al > rc-
files before change txt
改变属主
find /etc -type f -print | grep rc | egrep -v "skel|tty|mail|snmp|Mail" | xargs chown
root:root
find /etc -type f -print | grep rc | egrep -v "skel|tty|mail|snmp|Mail" | xargs ls -al > rc-files-after-change.txt
ls -al /etc/init.d > etc-init.d-before.change.txt
chown root:root /etc/init.d
ls -al /etc/init.d > etc-init.d-after-change.txt
此项用于防止木马攻击
(升级或打补丁后需要重做此项)
在/etc/default/cron中 CRONLOG=YES
删除/var/spool/cron/crontabs 目录中除了root文件外所有文件
chmod 644 /var/adm/utmp
1) find / -type f -nouser > files-nouser-before-change
2) find / -type f -nouser | xargs chwon nobody:nobody
3) find / -type f -nouser > files-nouser-after-change
1) find / -type f -nogroup > files-nogroup-before-change
2) find / -type f -nogroup | xargs chgrp nobody
3) find / -type f -nogroup > files-nogroup-after-change
chmod 700 /var/cron && chown root /var/cron && chgrp sys /var/cron
9.1 将cron logfiles的大小设为2M
/etc/cron.d/logchecker中 LIMIT=4096
编辑/etc/init.d/inetsvc,有如下条目
/usr/sbin/ifconfig –au netmask + broadcast +
/usr/sbin/inetd -s –t
编辑syslog.conf,增加
*.debug /var/adm/compass.messages #记录debug信息
auth.info /var/log/authlog
touch /var/adm/loginlog
chmod 600 /var/adm/loginlog
chown root /var/adm/loginlog
chgrp sys /var/adm/loginlog
Modification
Tripwire为完整性检查工具,能有效防止木马
9.6 安装日志检测工具,比如swatch
9.7 设置banner
在/etc/issue中编辑警告banner
1.总体安全考虑
应用程序以非特权用户运行
定义应用程序属主
删除所有的samples
chroot,改变进程的root目录
具体应用考虑
2.1 禁止nfs服务
杀掉如下NFS进程: lockd, nfsd, statd, mountd
NFS是由/etc/dfs/dfstab文件控制,为了禁止NFS服务的后台程序
将/etc/rc2.d/S15nfs.server文件改名 K15nfs.server
将/etc/rc2.d/S73nfs.client文件改名 K13nfs.client
/etc/dfs/dfstab 文件有几个选项
share –F nfs –o [rw/ro] /目录名
client端有读写权限, ro是client端只有读权限 [建议使用ro选项]
ndd -set /dev/tcp tcp_extra_priv_ports_add 2049
ndd -set /dev/udp udp_extra_priv_ports_add 2049
在/etc/system中加入
set nfssrv:nfs_portmon = 1
set nfs:nfs_portmon = 1
NIS是不安全的服务,建议卸载运行包,使用和设置NIS+会更安全
4.1 在/etc/passwd文件中
ftp:x:30000:30000:Anonymous FTP:/ftp目录:/nosuchshell
4.2在/etc/shadow文件中
ftp:NP:6445::::::
4.3 FTP-server的配置文件/etc/ftpaccess
class local real * 重定义真实用户为local
class remote guest,anonymous * 重定义匿名用户为remote
limit local 100 Any /ftp目录/msgs/limit.local限制登录用户数
limit remote 100 Any / ftp目录/msgs/limit.remote 限制登录用户数
banner /ftp目录/msgs/msg.banner
loginfails 2 重试次数
readme README* login
readme README* cwd=*
message /ftp目录/msgs/welcome.msg login local remote
message /ftp目录/msgs/cwd.msg cwd=* remote
compress yes local,remote
tar yes remote,local
log commands real
log transfers anonymous,real,guest inbound,outbound
shutdown /ftp目录/msgs/shutmsg
创建Banner文件 /etc/ftp-banner
将系统用户加入:root daemon sys bin adm lp smtp uucp nuucp listen
nobody noaccess news ingres audit admin sync nobody4
touch /etc/ftpusers
for user in root daemon bin sys nobody noaccess \
nobody4 uucp nuucp adm lp smtp listen
do
echo $user >>/etc/ftpusers
done
chown root /etc/ftpusers
chgrp root /etc/ftpusers
chmod 600 /etc/ftpusers
Modification
5.1 删除/etc/default/telnetd的Banner内容
5.2 尽量使用ssh来替代telnet
Solaris基本安全配置规范
0
相关文章