先写个大概
0. dirtycow
不同的dirtycow有不同执行条件。
使用前先对照此表根据内核版本确认是否已经修复 https://github.com/dirtycow/dirtycow.github.io/wiki/Patched-Kernel-Versions
比如 https://github.com/dirtycow/dirtycow.github.io/wiki/PoCs 列表中
Ubuntu最常用的应该是 https://github.com/FireFart/dirtycow/blob/master/dirty.c 。
https://github.com/securifera/cowcron 支持RHEL系。
1. 内核漏洞
不同内核对应不同exploit
https://github.com/SecWiki/linux-kernel-exploits
2. Pwn suid 或者 guid文件
suid文件为以文件所有者权限运行的文件,文件所有者为root的suid文件值得注意。
find / -perm +2000 -user root -type f -print
find / -perm -1000 -type d 2>/dev/null # Sticky bit - Only the owner of the directory or the owner of a file can delete or rename here.
find / -perm -g=s -type f 2>/dev/null # SGID (chmod 2000) - run as the group, not the user who started it.
find / -perm -u=s -type f 2>/dev/null # SUID (chmod 4000) - run as the owner, not the user who started it.
find / -perm -g=s -o -perm -u=s -type f 2>/dev/null # SGID or SUID
for i in `locate -r "bin$"`; do find $i \( -perm -4000 -o -perm -2000 \) -type f 2>/dev/null; done
find / -perm -g=s -o -perm -4000 ! -type l -maxdepth 3 -exec ls -ld {} \; 2>/dev/null
3. 高权限进程或者服务漏洞
查看高权限的service,是否有可利用的exploit.
4. 高权限进程或者服务目录是否可写
替换可执行文件,等待服务重启。
5. Corntab 高权限定时任务
是否可以编辑以root运行的corntab脚本
6. Sudo -l 看是否有可以高权限执行的命令或者脚本
比如可以sudo /usr/bin/python,或者sudo nmap --interactive等等
7. 其他思路(CTF式提权)
- /etc/passwd是否有编辑权限,如果可编辑,构造新用户及密码hash值写入/etc/passwd
- 找可疑文件,SSH Private Key或许隐写其中, 如果SSH Private Key使用了密码短语,可以用sshng2john.py转换私钥然后用John破解之 😛
8. 辅助脚本
https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh
https://github.com/crsftw/OSCP-cheat-sheet/blob/master/PRIVESC/Linux/unix-privesc-check
https://github.com/mzet-/linux-exploit-suggester/blob/master/linux-exploit-suggester.sh
https://github.com/NullArray/RootHelper
https://github.com/SecWiki/linux-kernel-exploits