shiro反序列化结合CommonsBeanutils
CommonsBeanutils是shiro本身的一个依赖,替换掉cc链想对通用一下 还是用之前的shiroDemo将pom.xml中的commons-collections删掉重新打包 然后用cb链生成payload 设置remeberMe的值 会出现这个错误
Unable to load class named [org.apache.commons.collections.comparators.ComparableComparator] from the thread context, current, or system/application ClassLoaders. All heuristics have been exhausted. Class could not be found.
但是我们并没有使用commons.collections 问题是出在了BeanComparator中 Comparator并没有什么作用 在 BeanComparator 类的构造函数处,当没有显式传入 Comparator 的情况下,则默认使用 ComparableComparator 。 既然此时没有 ComparableComparator ,我们需要找到一个类来替换,它满足下面这几个条件:
- 实现 java.util.Comparator 接口
- 实现 java.io.Serializable 接口
- Java、shiro或commons-beanutils自带,且兼容性强 通过IDEA的功能,我们找到一个 CaseInsensitiveComparator : 通过这个CASE_INSENSITIVE_ORDER就可以拿到一个CaseInsensitiveComparator对象 对CB链的POC进行改造 只需要改一句
public static final Comparator<String> CASE_INSENSITIVE_ORDER = new CaseInsensitiveComparator();
改为BeanComparator beanComparator = new BeanComparator("outputProperties");
BeanComparator beanComparator = new BeanComparator("outputProperties",String.CASE_INSENSITIVE_ORDER);
shiro反序列化结合CommonsBeanutils
http://example.com/2021/09/22/OldBlog/shiro反序列化结合commonsbeanutils/