ysoserial URLDNS gadget分析笔记

首先查看给出的gadget chain

因为反序列化时如果被反序列化的类里实现了Serializable接口且有readObject的话就会执行该方法里的实现,所以跟进readObject,

重写反序列化,计算流的字节,然后使用putval方法来处理HashMap.hash()方法处理key返回的结果

跟进hash,在该方法中对传来的参数做了一次判断,当key不为空时调用到key.hashCode

因为key是前面传过来的对象u

所以根据URLDNS类得知实际为URL类中的hashcode方法

在该方法中做了一次判断,当hashcode的值为-1时就进入到handler.hashCode,在URLStreamHandler.hashCode中做了发起dns的请求的操作,具体为:

参数传入了getHostAddress,在该方法里将u.getHost的值传进getByName,u.getHost即传来的参数url:


最后使用InetAddress.getByName(host)获取主机名,也就是在这里发出了dnslog请求


声明:
本文章用于学习交流,严禁用于非法操作,出现后果一切自行承担,阅读此文章表示你已同意本声明。

Disclaimer:
This article is for study and communication. It is strictly forbidden to use it for illegal operations. All consequences shall be borne by yourself. Reading this article means that you have agreed to this statement.