服务器 频道

Solaris基本安全配置规范

  8. 文件权限
  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 

  8.2 删除所有不使用的sgid文件
  列出系统中所有 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 位

  8.3 删除/etc下所有组可写文件
  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 {} \;

  8.4 删除/etc下所有world可写文件
  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 {} \;

  8.5 将权限为rw-rw-rw-的文件改为rw-r—r—
  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

  8.6 改变rwxrwxrwx文件的权限 
  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

  8.7 查找world,group可写的目录
  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

  8.8 确保每个root启动的脚本属于root
  首先查找所有启动脚本的属主
  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
  此项用于防止木马攻击
  (升级或打补丁后需要重做此项)

  8.9 确保所有cron行为有记录
  在/etc/default/cron中 CRONLOG=YES
  删除/var/spool/cron/crontabs 目录中除了root文件外所有文件

  8.10 改变utmp,utmpx的权限
  chmod 644 /var/adm/utmp

  8.11 查找无用户文件
  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

  8.12 查找无组文件
  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

  8.13 改变/var/cron权限
  chmod 700 /var/cron && chown root /var/cron && chgrp sys /var/cron

  9.日志和监控
  9.1 将cron logfiles的大小设为2M
  /etc/cron.d/logchecker中 LIMIT=4096

  9.2 记录所有inetd服务
  编辑/etc/init.d/inetsvc,有如下条目
  /usr/sbin/ifconfig –au netmask + broadcast +
  /usr/sbin/inetd -s –t

  9.3 修改syslog.conf
  编辑syslog.conf,增加
  *.debug /var/adm/compass.messages #记录debug信息
  auth.info /var/log/authlog

  9.4 创建/var/adm/loginlog来记录登陆失败信息
  touch /var/adm/loginlog
  chmod 600 /var/adm/loginlog
  chown root /var/adm/loginlog
  chgrp sys /var/adm/loginlog
  Modification

  9.4 安装Tripwire
  Tripwire为完整性检查工具,能有效防止木马

  9.5 安装IDS工具,比如snort
  9.6 安装日志检测工具,比如swatch
  9.7 设置banner
  在/etc/issue中编辑警告banner

  二、应用程序安全配置

  1.总体安全考虑
  应用程序以非特权用户运行
  定义应用程序属主
  删除所有的samples
  chroot,改变进程的root目录
  具体应用考虑

  2. NFS服务
  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选项]

  2.2 如必须使用,则设置nfs特殊tcp,udp端口
  ndd -set /dev/tcp tcp_extra_priv_ports_add 2049
  ndd -set /dev/udp udp_extra_priv_ports_add 2049

  2.3 打开nfs port monitoring功能
  在/etc/system中加入
  set nfssrv:nfs_portmon = 1
  set nfs:nfs_portmon = 1

  3. NIS服务
  NIS是不安全的服务,建议卸载运行包,使用和设置NIS+会更安全

  4. Ftp服务
  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

  4.4 创建ftp banner
  创建Banner文件 /etc/ftp-banner

  4.5 创建/etc/ftpusers文件
  将系统用户加入: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. Telnet服务
  5.1 删除/etc/default/telnetd的Banner内容
  5.2 尽量使用ssh来替代telnet 

0
相关文章