lynis check
System Tools
检查系统可执行程序环境变量路径nginx
Boot and services
GRUB2 菜单项进入单用户模式已经设置密码shell
其余是检查开始运行的服务,目前是运行24项服务,开机启动是21项服务数据库
- 服务脚本目录: /lib/systemd/system/
- service文件权限: 0644
Kernel
运行级别、已装入模块、内核配置和核心转储apache
- 检查运行级别 RUNLEVEL 5
- 检查内核版本类型,以及加载模块数量
- 检查内核config文件,default I/O kernel scheduler,
- core dumps 配置,默认没有开启,
- setuid core dumps 配置为默认
- 检查是否须要重启
Kernel Hardening
- Comparing sysctl key pairs with scan profile ,每一项后面是lynis给出的建议值,例如 (exp: 1)
- kernel.core_uses_pid (exp: 1) 每一个消息队列的大小(单位:字节)限制
- kernel.ctrl-alt-del (exp: 0) 是否捕获ctrl+alt+delete按键组合时的信号, 0,捕获,1,不捕获
- kernel.sysrq (exp: 0) 是否开启SysRq功能, 0,禁用,1,启用
- net.ipv4.conf.all.accept_redirects (exp: 0) ICMP接收重定向报文(全局设置) 0,忽略, 1 ,转发
- net.ipv4.conf.all.accept_source_route (exp: 0) 接受全部源地址信息包(全局设置) 0,丢弃, 1 ,转发
- net.ipv4.conf.all.bootp_relay (exp: 0)
- net.ipv4.conf.all.forwarding (exp: 0) 配置主机网络接口的行为, 0 禁止转发,1,容许转发
- net.ipv4.conf.all.log_martians (exp: 1) 将包含非法地址信息的ip包记录到内核日志(全局设置) 0 关闭, 1 开启
- net.ipv4.conf.all.mc_forwarding (exp: 0) 多播路由 0 关闭, 1 开启
- net.ipv4.conf.all.proxy_arp (exp: 0) ARP代理 0 关闭, 1 开启
- net.ipv4.conf.all.rp_filter (exp: 1) 逆向路径过滤 (Reverse Path Filtering) 0 关闭, 1 Strict mode, 2 Loose mode
- net.ipv4.conf.all.send_redirects (exp: 0) ICMP发送重定向报文 0 关闭, 1 开启
- net.ipv4.conf.default.accept_redirects (exp: 0) ICMP接收重定向报文(默认设置) 0 忽略, 1 转发
- net.ipv4.conf.default.accept_source_route (exp: 0) 接受全部源地址信息包(默认设置) 0 丢弃, 1 转发
- net.ipv4.conf.default.log_martians (exp: 1) 将包含非法地址信息的ip包记录到内核日志(默认设置) 0 关闭, 1 开启
- net.ipv4.icmp_echo_ignore_broadcasts (exp: 1) 设置是否响应icmp echo请求广播, 0 响应, 1 忽略
- net.ipv4.icmp_ignore_bogus_error_responses (exp: 1) 忽略由网络中的那些声称回应地址是广播地址的主机生成的ICMP错误 0 响应, 1 忽略
- net.ipv4.tcp_syncookies (exp: 1) 表示开启SYN Cookies,当出现SYN等待队列溢出时,启用cookies来处理,可防范少许SYN攻击, 0 关闭, 1 启用
- net.ipv4.tcp_timestamps (exp: 0) 开启时间戳,防范那些伪造的 sequence 号码 0 关闭, 1 开启
如下是针对ipv6的,和ipv4 的同参数功能相同
- net.ipv6.conf.all.accept_redirects (exp: 0)
- net.ipv6.conf.all.accept_source_route (exp: 0)
- net.ipv6.conf.default.accept_redirects (exp: 0)
- net.ipv6.conf.default.accept_source_route (exp: 0)
- man proc
- 网络部分 https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
Memory and processes
检查僵尸进程和输入输出等待进程,ps -aux
安全
- /proc/memento
- dead/zombie processes
- IO waiting processes
Users, Groups and Authentication
用户组编号、sudoers文件、可插拔验证模块(PAM)配置、密码老化和默认掩码服务器
- 检查 UID ID groupname 的惟一性
- 检查 group files 和 password file 文件的一致性 (TODO)
- 检查命名服务:
- 网络信息服务 (Network Information Service, NIS)
- 轻型目录访问协议(Lightweight Directory Access Protocol,LDAP)
- 检查sudo配置及其权限, /etc/sudoers 默认权限 0440
- PAM认证配置文件检查,密码强度配置检查
- 检查 LDAP module in PAM 是否配置,及其 LDAP authentication Support
- 检查帐户的到期日期,密码为空的配置状况
- default umask (todo) /etc/profile 755 /etc/login.defs 644 /etc/init.d/rc 644
Shells
- /etc/shells 查看当前系统存在的shell数量
- 测试是否存在 Shellshock 漏洞
File systems
挂载点、临时文件和根文件系统cookie
- 检查 /home /tmp 挂载点
- 检查 是否存在UNIX文件系统 FFS/UFS (BSD体系)
- 检查 swap分区,测试swap分区状态
- 检查 /tmp old files 和 sticky bit,正确的权限 (1777)
- 检查 根分区是否开启 ACL 支持 已经开启 (todo)
- 检查 Locate database (todo)
- 检查是否存在加密文件系统 否
Storage
检查 USB存储(usb-storage)和火线开放式主机控制器接口(firewire ohci) [ NOT DISABLED ] (todo)网络
相关配置文件dom
- /lib/modprobe.d/aliases.conf
- /etc/modprobe.d/*
NFS
- 查询 是否存在 rpc 程序 (Remote Procedure Call,远程过程调用)
- 查询 NFS 版本,协议,服务
Software: name services
- 检查默认的 DNS search domain
- 检查 search domains
- 检查 /etc/resolv.conf 是否存在 options 配置项
- 检查 DNS domain name
- 检查 nscd,bind,PowerDNS,ypbind 运行状态
- 检查 /etc/hosts
- duplicates
- hostname
- localhost
Ports and packages
- 包管理套件: dpkg apt-get
- 检查配置文件,以及是否存在安装更新仓库: 相关配置 /etc/apt/sources.list.d/*
- 包管理套件对应的数据库完整性和一致性检查,是针对包依赖关系,而不是包的文件内容,相关命令
dpkg -C
- 检查 vulnerable packages (还没太理解含义)
Networking
名称服务器、混杂接口和链接状态ssh
- 检查是否配置nameservers 建议至少两个可用的nameserver
- 检查是否存在默认的网关,
- 检查listening ports (TCP/UDP) 发现22个,经过下面命令能够查询
netstat -tlnp
netstat -ulnp
- 检查网卡是否支持Promiscuous工做模式(混杂工做模式)
ifconfig [interface] promisc
ifconfig [interface] -promisc
- 检查当前链接状态,可执行命令查看
netstat -nat
- 检查DHCP客户端程序运行状态
Printers and Spools
打印服务默认不安装
Software: e-mail and messaging
检查系统中 Exim Postfix Qmail Sendmail 的运行状态
Software: firewalls
- 检查 iptables 运行状态
- 检查 PF firewall (UNIX BSD 体系防火墙)
- 检查 host based firewall 配置是否开启
SSH Support
- PermitRootLogin 设置root远程登陆策略,默认是 without-password
- StrictModes 设置ssh在接收登陆请求以前是否检查用户家目录和rhosts文件的权限和全部权
- AllowUsers 用户白名单
- AllowGroups 用户组白名单
- Protocol 支持的协议版本
Logging and files
- 检查日志服务运行状态,当前系统是rsyslog,
- 其余同类软件Syslog-NG,RFC 3195,minilogd
- logrotate进程是否运行,日志文件管理工具,用于截断(或轮循)、压缩,删除旧日志文件,备份历史日志文件等
- 检查是否在使用已经删除的文件(deleted files in use)
- log directories (static list) (todo)
- open log files (todo)
Insecure services
Banners and identification
- 检查 /etc/motd /etc/issue /etc/issue.net
Scheduled tasks
- 检查 crontab atd 服务运行状态
- 检查 计划任务运行状态
Accounting
- 检查 帐户信息
- sysstat accounting data 默认没有开启
- auditd 检查规则,配置文件,日志文件
Time and Synchronization
- 检查 ntp 服务或者客户端是否存在
- 检查 NTP client是否在/etc/anacrontab,/etc/crontab 或 cron.d files 中
Cryptography
- 检查SSL证书是否过时
Virtualization
Security frameworks
- 检查 AppArmor,SELinux,Grsecurity 是否开启或支持
Software: file integrity
检查如下文件完整性检查工具是否存在
AFICK,AIDE,Osiris,Samhain,Tripwire,syscheck,mtree
Software: System tooling
saltstack,puppet,cfengine,chef,func,fabric
File Permissions
- 检查 /etc/lilo.conf 和 $HOME/.ssh
Home directories
Hardening
- 检查是否存在编译器
- 检查是否存在恶意软件扫描工具
检查是否存在如下软件或服务
- apache
- nginx
- PHP
- MySQL
- PostgreSQL
- Oracle
- Squid
- OpenLDAP 运行实例
- SNMP 服务