先寫個大概
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