以下为个人学习笔记和习题整理
# 获取系统信息
cat /etc/issue 查看发行版
cat /etc/*-release 查看发行版
cat /proc/version uname -a 查看内核版本
rpm -q kernel 红帽系统特有
dmesg | grep Linux
ls /boot | grep vmlinuz-
lsb_release -a
# 检查用户权限
sudo -l
cat /etc/sudoers
whoami
# 检查密码文件
cat /etc/passwd
cat /etc/shadow
ls -l /etc/passwd
ls -l /etc/shadow
passwd文件中存储了用户,shadow文件中存储的是密码的hash。出于安全的考虑,passwd是全用户可读,root可写的。而Shadow是仅root可读写的。
passwd由冒号分割,第一列是用户名,第二列是密码,x代表密码hash被放在shadow里面了(这样非root就看不到了)。
# 查看环境变量
搜寻有配置错误的环境变量,查看是否优先从不安全的路径执行文件。
cat /etc/profile
cat /etc/bashrc
cat ~/.bash_profile
cat ~/.bashrc
cat ~/.bash_logout
cat ~/.bash_history
env
set
# 检查历史文件及命令
cat ~/.*_history
# 搜寻可被低权限用户使用的 root 权限程序
crontab -l
ls -alh /var/spool/cron
ls -al /etc/ | grep cron
ls -al /etc/cron*
cat /etc/cron*
cat /etc/at.allow
cat /etc/at.deny
cat /etc/cron.allow
cat /etc/cron.deny
cat /etc/crontab
cat /etc/anacrontab
cat /var/spool/cron/crontabs/root
# 检查以 root 权限的进程是否存在漏洞
ps aux | grep root
ps -ef | grep root
# 搜索纯文本凭据的文件
grep -ir user *
grep -ir pass *
# 查找可写的配置文件
find /etc/ -writable -type f 2>/dev/null