mirror of
https://github.com/frohoff/ysoserial.git
synced 2026-09-26 17:01:53 +08:00
Merge pull request #103 from frohoff/fixes
Various JDK Build/Test Fixes
This commit is contained in:
+38
-10
@@ -4,17 +4,45 @@ language: java
|
|||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.m2
|
- $HOME/.m2
|
||||||
|
- $HOME/.mvn/
|
||||||
|
|
||||||
# Travis CI provides OpenJDK 6, OpenJDK 7, Oracle JDK 7, and Oracle JDK 8.
|
# jdk6 requires workarounds https://github.com/travis-ci/travis-ci/issues/9713
|
||||||
# Sun JDK 6 is not provided, because it is EOL as of November 2012.
|
addons:
|
||||||
# OpenJDK 8 is available on our Trusty images, specify dist: trusty to make use of it.
|
apt:
|
||||||
jdk:
|
packages:
|
||||||
- oraclejdk8
|
- openjdk-6-jdk
|
||||||
#- oraclejdk7 #https://github.com/travis-ci/travis-ci/issues/7884
|
|
||||||
- openjdk8
|
before_install:
|
||||||
- openjdk7
|
- > # install mvn 3.2.5 for use with java6
|
||||||
#- openjdk6 #https://github.com/travis-ci/travis-ci/issues/8199
|
which $HOME/.mvn/3.2.5/bin/mvn || mkdir -p $HOME/.mvn/3.2.5 &&
|
||||||
|
curl https://apache.osuosl.org/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz |
|
||||||
|
tar xz -C $HOME/.mvn/3.2.5 --strip-components=1
|
||||||
|
- if [ "$TRAVIS_JDK_VERSION" == "openjdk6" ]; then jdk_switcher use openjdk6; fi
|
||||||
|
- mvn -v
|
||||||
|
|
||||||
|
after_script:
|
||||||
|
- > # print more detailed info about test results
|
||||||
|
cat target/surefire-reports/TEST-ysoserial.payloads.PayloadsTest.xml |
|
||||||
|
grep testcase -A1 | grep -B1 -E 'failure|error|skipped' | grep -v -- --
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- jdk: openjdk7
|
- jdk: oraclejdk11
|
||||||
|
- jdk: openjdk6
|
||||||
|
- jdk: openjdk7
|
||||||
|
- jdk: openjdk9
|
||||||
|
- jdk: openjdk10
|
||||||
|
- jdk: openjdk11
|
||||||
|
include:
|
||||||
|
#- jdk: oraclejdk7 #https://github.com/travis-ci/travis-ci/issues/7884
|
||||||
|
- jdk: oraclejdk8
|
||||||
|
- jdk: oraclejdk11
|
||||||
|
- jdk: openjdk6
|
||||||
|
env: PATH=$HOME/.mvn/3.2.5/bin:$PATH
|
||||||
|
- jdk: openjdk7
|
||||||
|
- jdk: openjdk8
|
||||||
|
- jdk: openjdk9
|
||||||
|
- jdk: openjdk10
|
||||||
|
- jdk: openjdk11
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -10,7 +10,9 @@ skip_tags: true
|
|||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- JAVA_HOME: C:\Program Files\Java\jdk1.6.0
|
- JAVA_HOME: C:\Program Files\Java\jdk1.6.0
|
||||||
|
M2_HOME: C:\bin\apache-maven-3.2.5
|
||||||
- JAVA_HOME: C:\Program Files\Java\jdk1.7.0
|
- JAVA_HOME: C:\Program Files\Java\jdk1.7.0
|
||||||
|
MAVEN_OPTS: -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
|
||||||
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
|
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
@@ -20,17 +22,19 @@ matrix:
|
|||||||
|
|
||||||
# install required tools (maven, secure-file, encrypted files)
|
# install required tools (maven, secure-file, encrypted files)
|
||||||
install:
|
install:
|
||||||
|
- cmd: if not exist "C:\bin\apache-maven-3.2.5\bin\*.*" cinst maven --version 3.2.5 --allow-empty-checksums
|
||||||
- cmd: echo %JAVA_HOME%
|
- cmd: echo %JAVA_HOME%
|
||||||
- cmd: echo %M2_HOME%
|
- cmd: echo %M2_HOME%
|
||||||
|
|
||||||
# build and install artifacts
|
# build and install artifacts
|
||||||
build_script:
|
build_script:
|
||||||
- mvn clean install -DskipTests
|
- '"%M2_HOME%\bin\mvn" clean install -DskipTests'
|
||||||
|
|
||||||
# verify artifacts
|
# verify artifacts
|
||||||
test_script:
|
test_script:
|
||||||
- mvn test
|
- '"%M2_HOME%\bin\mvn" test'
|
||||||
|
|
||||||
# preserve dependencies between builds
|
# preserve dependencies between builds
|
||||||
cache:
|
cache:
|
||||||
- C:\Users\appveyor\.m2
|
- C:\Users\appveyor\.m2
|
||||||
|
- C:\bin\apache-maven-3.2.5
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.20</version>
|
<version>3.0.0-M1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<trimStackTrace>false</trimStackTrace>
|
<trimStackTrace>false</trimStackTrace>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
@@ -311,6 +311,43 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>jdk6</id>
|
||||||
|
<activation>
|
||||||
|
<jdk>1.6</jdk>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.1</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.el</groupId>
|
||||||
|
<artifactId>javax.el-api</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<!-- workaround for non-overlapping TLS versions in JDK6 and central repo
|
||||||
|
https://central.sonatype.org/articles/2018/May/04/discontinued-support-for-tlsv11-and-below/ -->
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>repo1</id>
|
||||||
|
<url>http://repo1.maven.org/maven2</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>repo1</id>
|
||||||
|
<url>http://repo1.maven.org/maven2</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>hibernate5</id>
|
<id>hibernate5</id>
|
||||||
<activation>
|
<activation>
|
||||||
|
|||||||
@@ -9,11 +9,7 @@ import java.rmi.registry.Registry;
|
|||||||
import java.rmi.server.RMIClientSocketFactory;
|
import java.rmi.server.RMIClientSocketFactory;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.*;
|
||||||
import javax.net.ssl.SSLEngine;
|
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509ExtendedTrustManager;
|
|
||||||
|
|
||||||
import ysoserial.payloads.CommonsCollections1;
|
import ysoserial.payloads.CommonsCollections1;
|
||||||
import ysoserial.payloads.ObjectPayload;
|
import ysoserial.payloads.ObjectPayload;
|
||||||
@@ -30,15 +26,11 @@ import ysoserial.secmgr.ExecCheckingSecurityManager;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public class RMIRegistryExploit {
|
public class RMIRegistryExploit {
|
||||||
private static class TrustAllSSL extends X509ExtendedTrustManager {
|
private static class TrustAllSSL implements X509TrustManager {
|
||||||
private static final X509Certificate[] ANY_CA = {};
|
private static final X509Certificate[] ANY_CA = {};
|
||||||
public X509Certificate[] getAcceptedIssuers() { return ANY_CA; }
|
public X509Certificate[] getAcceptedIssuers() { return ANY_CA; }
|
||||||
public void checkServerTrusted(final X509Certificate[] c, final String t) { /* Do nothing/accept all */ }
|
public void checkServerTrusted(final X509Certificate[] c, final String t) { /* Do nothing/accept all */ }
|
||||||
public void checkClientTrusted(final X509Certificate[] c, final String t) { /* Do nothing/accept all */ }
|
public void checkClientTrusted(final X509Certificate[] c, final String t) { /* Do nothing/accept all */ }
|
||||||
public void checkServerTrusted(final X509Certificate[] c, final String t, final SSLEngine e) { /* Do nothing/accept all */ }
|
|
||||||
public void checkServerTrusted(final X509Certificate[] c, final String t, final Socket e) { /* Do nothing/accept all */ }
|
|
||||||
public void checkClientTrusted(final X509Certificate[] c, final String t, final SSLEngine e) { /* Do nothing/accept all */ }
|
|
||||||
public void checkClientTrusted(final X509Certificate[] c, final String t, final Socket e) { /* Do nothing/accept all */ }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RMISSLClientSocketFactory implements RMIClientSocketFactory {
|
private static class RMISSLClientSocketFactory implements RMIClientSocketFactory {
|
||||||
@@ -61,7 +53,7 @@ public class RMIRegistryExploit {
|
|||||||
Registry registry = LocateRegistry.getRegistry(host, port);
|
Registry registry = LocateRegistry.getRegistry(host, port);
|
||||||
final String className = CommonsCollections1.class.getPackage().getName() + "." + args[2];
|
final String className = CommonsCollections1.class.getPackage().getName() + "." + args[2];
|
||||||
final Class<? extends ObjectPayload> payloadClass = (Class<? extends ObjectPayload>) Class.forName(className);
|
final Class<? extends ObjectPayload> payloadClass = (Class<? extends ObjectPayload>) Class.forName(className);
|
||||||
|
|
||||||
// test RMI registry connection and upgrade to SSL connection on fail
|
// test RMI registry connection and upgrade to SSL connection on fail
|
||||||
try {
|
try {
|
||||||
registry.list();
|
registry.list();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.apache.commons.io.output.ThresholdingOutputStream;
|
|||||||
import ysoserial.payloads.annotation.Authors;
|
import ysoserial.payloads.annotation.Authors;
|
||||||
import ysoserial.payloads.annotation.Dependencies;
|
import ysoserial.payloads.annotation.Dependencies;
|
||||||
import ysoserial.payloads.annotation.PayloadTest;
|
import ysoserial.payloads.annotation.PayloadTest;
|
||||||
|
import ysoserial.payloads.util.JavaVersion;
|
||||||
import ysoserial.payloads.util.PayloadRunner;
|
import ysoserial.payloads.util.PayloadRunner;
|
||||||
import ysoserial.payloads.util.Reflections;
|
import ysoserial.payloads.util.Reflections;
|
||||||
|
|
||||||
@@ -40,9 +41,12 @@ import ysoserial.payloads.util.Reflections;
|
|||||||
"commons-fileupload:commons-fileupload:1.3.1",
|
"commons-fileupload:commons-fileupload:1.3.1",
|
||||||
"commons-io:commons-io:2.4"
|
"commons-io:commons-io:2.4"
|
||||||
} )
|
} )
|
||||||
@PayloadTest(harness="ysoserial.payloads.FileUploadTest")
|
@PayloadTest(harness="ysoserial.payloads.FileUploadTest", precondition = "isApplicableJavaVersion")
|
||||||
@Authors({ Authors.MBECHLER })
|
@Authors({ Authors.MBECHLER })
|
||||||
public class FileUpload1 implements ReleaseableObjectPayload<DiskFileItem> {
|
public class FileUpload1 implements ReleaseableObjectPayload<DiskFileItem> {
|
||||||
|
public static boolean isApplicableJavaVersion() {
|
||||||
|
return JavaVersion.isAtLeast(7);
|
||||||
|
}
|
||||||
|
|
||||||
public DiskFileItem getObject ( String command ) throws Exception {
|
public DiskFileItem getObject ( String command ) throws Exception {
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ import org.hibernate.type.Type;
|
|||||||
import org.hibernate.EntityMode;
|
import org.hibernate.EntityMode;
|
||||||
|
|
||||||
import ysoserial.payloads.annotation.Authors;
|
import ysoserial.payloads.annotation.Authors;
|
||||||
|
import ysoserial.payloads.annotation.PayloadTest;
|
||||||
import ysoserial.payloads.util.Gadgets;
|
import ysoserial.payloads.util.Gadgets;
|
||||||
|
import ysoserial.payloads.util.JavaVersion;
|
||||||
import ysoserial.payloads.util.PayloadRunner;
|
import ysoserial.payloads.util.PayloadRunner;
|
||||||
import ysoserial.payloads.util.Reflections;
|
import ysoserial.payloads.util.Reflections;
|
||||||
|
|
||||||
@@ -40,7 +42,11 @@ import ysoserial.payloads.util.Reflections;
|
|||||||
* @author mbechler
|
* @author mbechler
|
||||||
*/
|
*/
|
||||||
@Authors({ Authors.MBECHLER })
|
@Authors({ Authors.MBECHLER })
|
||||||
|
@PayloadTest(precondition = "isApplicableJavaVersion")
|
||||||
public class Hibernate1 implements ObjectPayload<Object>, DynamicDependencies {
|
public class Hibernate1 implements ObjectPayload<Object>, DynamicDependencies {
|
||||||
|
public static boolean isApplicableJavaVersion() {
|
||||||
|
return JavaVersion.isAtLeast(7);
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] getDependencies () {
|
public static String[] getDependencies () {
|
||||||
if ( System.getProperty("hibernate5") != null ) {
|
if ( System.getProperty("hibernate5") != null ) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ysoserial.payloads;
|
|||||||
|
|
||||||
import ysoserial.payloads.annotation.Authors;
|
import ysoserial.payloads.annotation.Authors;
|
||||||
import ysoserial.payloads.annotation.PayloadTest;
|
import ysoserial.payloads.annotation.PayloadTest;
|
||||||
|
import ysoserial.payloads.util.JavaVersion;
|
||||||
import ysoserial.payloads.util.PayloadRunner;
|
import ysoserial.payloads.util.PayloadRunner;
|
||||||
|
|
||||||
import com.sun.rowset.JdbcRowSetImpl;
|
import com.sun.rowset.JdbcRowSetImpl;
|
||||||
@@ -41,9 +42,12 @@ import com.sun.rowset.JdbcRowSetImpl;
|
|||||||
@SuppressWarnings ( {
|
@SuppressWarnings ( {
|
||||||
"restriction"
|
"restriction"
|
||||||
} )
|
} )
|
||||||
@PayloadTest( harness = "ysoserial.payloads.JRMPReverseConnectTest")
|
@PayloadTest(harness = "ysoserial.payloads.JRMPReverseConnectTest", precondition = "isApplicableJavaVersion")
|
||||||
@Authors({ Authors.MBECHLER })
|
@Authors({ Authors.MBECHLER })
|
||||||
public class Hibernate2 implements ObjectPayload<Object>, DynamicDependencies {
|
public class Hibernate2 implements ObjectPayload<Object>, DynamicDependencies {
|
||||||
|
public static boolean isApplicableJavaVersion() {
|
||||||
|
return JavaVersion.isAtLeast(7);
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] getDependencies () {
|
public static String[] getDependencies () {
|
||||||
return Hibernate1.getDependencies();
|
return Hibernate1.getDependencies();
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ import org.jboss.interceptor.spi.model.InterceptionModel;
|
|||||||
import org.jboss.interceptor.spi.model.InterceptionType;
|
import org.jboss.interceptor.spi.model.InterceptionType;
|
||||||
import ysoserial.payloads.annotation.Authors;
|
import ysoserial.payloads.annotation.Authors;
|
||||||
import ysoserial.payloads.annotation.Dependencies;
|
import ysoserial.payloads.annotation.Dependencies;
|
||||||
|
import ysoserial.payloads.annotation.PayloadTest;
|
||||||
import ysoserial.payloads.util.Gadgets;
|
import ysoserial.payloads.util.Gadgets;
|
||||||
|
import ysoserial.payloads.util.JavaVersion;
|
||||||
import ysoserial.payloads.util.PayloadRunner;
|
import ysoserial.payloads.util.PayloadRunner;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@@ -26,11 +28,15 @@ import java.util.*;
|
|||||||
by @matthias_kaiser
|
by @matthias_kaiser
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
|
@PayloadTest(precondition = "isApplicableJavaVersion")
|
||||||
@Dependencies({ "javassist:javassist:3.12.1.GA", "org.jboss.interceptor:jboss-interceptor-core:2.0.0.Final",
|
@Dependencies({ "javassist:javassist:3.12.1.GA", "org.jboss.interceptor:jboss-interceptor-core:2.0.0.Final",
|
||||||
"javax.enterprise:cdi-api:1.0-SP1", "javax.interceptor:javax.interceptor-api:3.1",
|
"javax.enterprise:cdi-api:1.0-SP1", "javax.interceptor:javax.interceptor-api:3.1",
|
||||||
"org.jboss.interceptor:jboss-interceptor-spi:2.0.0.Final", "org.slf4j:slf4j-api:1.7.21" })
|
"org.jboss.interceptor:jboss-interceptor-spi:2.0.0.Final", "org.slf4j:slf4j-api:1.7.21" })
|
||||||
@Authors({ Authors.MATTHIASKAISER })
|
@Authors({ Authors.MATTHIASKAISER })
|
||||||
public class JBossInterceptors1 implements ObjectPayload<Object> {
|
public class JBossInterceptors1 implements ObjectPayload<Object> {
|
||||||
|
public static boolean isApplicableJavaVersion() {
|
||||||
|
return JavaVersion.isAtLeast(7);
|
||||||
|
}
|
||||||
|
|
||||||
public Object getObject(final String command) throws Exception {
|
public Object getObject(final String command) throws Exception {
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import javax.management.openmbean.TabularType;
|
|||||||
import javax.xml.transform.Templates;
|
import javax.xml.transform.Templates;
|
||||||
|
|
||||||
import org.springframework.aop.framework.AdvisedSupport;
|
import org.springframework.aop.framework.AdvisedSupport;
|
||||||
import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl;
|
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
|
||||||
@@ -95,12 +94,11 @@ public class JSON1 implements ObjectPayload<Object> {
|
|||||||
// it's very likely that there are other proxy impls that could be used
|
// it's very likely that there are other proxy impls that could be used
|
||||||
AdvisedSupport as = new AdvisedSupport();
|
AdvisedSupport as = new AdvisedSupport();
|
||||||
as.setTarget(payload);
|
as.setTarget(payload);
|
||||||
InvocationHandler delegateInvocationHandler = (InvocationHandler) Reflections
|
InvocationHandler delegateInvocationHandler = (InvocationHandler) Reflections.newInstance("org.springframework.aop.framework.JdkDynamicAopProxy", as);
|
||||||
.getFirstCtor("org.springframework.aop.framework.JdkDynamicAopProxy").newInstance(as);
|
|
||||||
InvocationHandler cdsInvocationHandler = Gadgets.createMemoizedInvocationHandler(Gadgets.createMap("getCompositeType", rt));
|
InvocationHandler cdsInvocationHandler = Gadgets.createMemoizedInvocationHandler(Gadgets.createMap("getCompositeType", rt));
|
||||||
CompositeInvocationHandlerImpl invocationHandler = new CompositeInvocationHandlerImpl();
|
InvocationHandler invocationHandler = (InvocationHandler) Reflections.newInstance("com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl");
|
||||||
invocationHandler.addInvocationHandler(CompositeData.class, cdsInvocationHandler);
|
((Map) Reflections.getFieldValue(invocationHandler, "classToInvocationHandler")).put(CompositeData.class, cdsInvocationHandler);
|
||||||
invocationHandler.setDefaultHandler(delegateInvocationHandler);
|
Reflections.setFieldValue(invocationHandler, "defaultHandler", delegateInvocationHandler);
|
||||||
final CompositeData cdsProxy = Gadgets.createProxy(invocationHandler, CompositeData.class, ifaces);
|
final CompositeData cdsProxy = Gadgets.createProxy(invocationHandler, CompositeData.class, ifaces);
|
||||||
|
|
||||||
JSONObject jo = new JSONObject();
|
JSONObject jo = new JSONObject();
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ import org.jboss.weld.interceptor.spi.model.InterceptionModel;
|
|||||||
import org.jboss.weld.interceptor.spi.model.InterceptionType;
|
import org.jboss.weld.interceptor.spi.model.InterceptionType;
|
||||||
import ysoserial.payloads.annotation.Authors;
|
import ysoserial.payloads.annotation.Authors;
|
||||||
import ysoserial.payloads.annotation.Dependencies;
|
import ysoserial.payloads.annotation.Dependencies;
|
||||||
|
import ysoserial.payloads.annotation.PayloadTest;
|
||||||
import ysoserial.payloads.util.Gadgets;
|
import ysoserial.payloads.util.Gadgets;
|
||||||
|
import ysoserial.payloads.util.JavaVersion;
|
||||||
import ysoserial.payloads.util.PayloadRunner;
|
import ysoserial.payloads.util.PayloadRunner;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@@ -26,11 +28,15 @@ import java.util.*;
|
|||||||
by @matthias_kaiser
|
by @matthias_kaiser
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
|
@PayloadTest(precondition = "isApplicableJavaVersion")
|
||||||
@Dependencies({"javassist:javassist:3.12.1.GA", "org.jboss.weld:weld-core:1.1.33.Final",
|
@Dependencies({"javassist:javassist:3.12.1.GA", "org.jboss.weld:weld-core:1.1.33.Final",
|
||||||
"javax.enterprise:cdi-api:1.0-SP1", "javax.interceptor:javax.interceptor-api:3.1",
|
"javax.enterprise:cdi-api:1.0-SP1", "javax.interceptor:javax.interceptor-api:3.1",
|
||||||
"org.jboss.interceptor:jboss-interceptor-spi:2.0.0.Final", "org.slf4j:slf4j-api:1.7.21" })
|
"org.jboss.interceptor:jboss-interceptor-spi:2.0.0.Final", "org.slf4j:slf4j-api:1.7.21" })
|
||||||
@Authors({ Authors.MATTHIASKAISER })
|
@Authors({ Authors.MATTHIASKAISER })
|
||||||
public class JavassistWeld1 implements ObjectPayload<Object> {
|
public class JavassistWeld1 implements ObjectPayload<Object> {
|
||||||
|
public static boolean isApplicableJavaVersion() {
|
||||||
|
return JavaVersion.isAtLeast(7);
|
||||||
|
}
|
||||||
|
|
||||||
public Object getObject(final String command) throws Exception {
|
public Object getObject(final String command) throws Exception {
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package ysoserial.payloads;
|
|||||||
|
|
||||||
import ysoserial.payloads.annotation.Authors;
|
import ysoserial.payloads.annotation.Authors;
|
||||||
import ysoserial.payloads.annotation.PayloadTest;
|
import ysoserial.payloads.annotation.PayloadTest;
|
||||||
|
import ysoserial.payloads.util.JavaVersion;
|
||||||
import ysoserial.payloads.util.PayloadRunner;
|
import ysoserial.payloads.util.PayloadRunner;
|
||||||
|
|
||||||
|
|
||||||
@@ -28,9 +29,12 @@ import ysoserial.payloads.util.PayloadRunner;
|
|||||||
*
|
*
|
||||||
* @author mbechler
|
* @author mbechler
|
||||||
*/
|
*/
|
||||||
@PayloadTest ( harness = "ysoserial.payloads.MyfacesTest" )
|
@PayloadTest(harness = "ysoserial.payloads.MyfacesTest", precondition = "isApplicableJavaVersion")
|
||||||
@Authors({ Authors.MBECHLER })
|
@Authors({ Authors.MBECHLER })
|
||||||
public class Myfaces2 implements ObjectPayload<Object>, DynamicDependencies {
|
public class Myfaces2 implements ObjectPayload<Object>, DynamicDependencies {
|
||||||
|
public static boolean isApplicableJavaVersion() {
|
||||||
|
return JavaVersion.isAtLeast(7);
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] getDependencies () {
|
public static String[] getDependencies () {
|
||||||
return Myfaces1.getDependencies();
|
return Myfaces1.getDependencies();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import ysoserial.payloads.util.Reflections;
|
|||||||
* $ cat /tmp/upload_3805815b_2d50_4e00_9dae_a854d5a0e614_479431761.tmp
|
* $ cat /tmp/upload_3805815b_2d50_4e00_9dae_a854d5a0e614_479431761.tmp
|
||||||
* blue lobster
|
* blue lobster
|
||||||
*/
|
*/
|
||||||
@PayloadTest(harness = "ysoserial.payloads.FileUploadTest")
|
@PayloadTest(harness = "ysoserial.payloads.FileUploadTest", flaky="possible race condition")
|
||||||
@Dependencies({"org.apache.wicket:wicket-util:6.23.0", "org.slf4j:slf4j-api:1.6.4"})
|
@Dependencies({"org.apache.wicket:wicket-util:6.23.0", "org.slf4j:slf4j-api:1.6.4"})
|
||||||
@Authors({ Authors.JACOBAINES })
|
@Authors({ Authors.JACOBAINES })
|
||||||
public class Wicket1 implements ReleaseableObjectPayload<DiskFileItem> {
|
public class Wicket1 implements ReleaseableObjectPayload<DiskFileItem> {
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface PayloadTest {
|
public @interface PayloadTest {
|
||||||
|
|
||||||
String skip() default "";
|
String skip() default "";
|
||||||
|
|
||||||
String precondition() default "";
|
String precondition() default "";
|
||||||
|
|
||||||
String harness() default "";
|
String harness() default "";
|
||||||
|
|
||||||
|
String flaky() default "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ public class JavaVersion {
|
|||||||
}
|
}
|
||||||
JavaVersion v = new JavaVersion();
|
JavaVersion v = new JavaVersion();
|
||||||
String parts[] = property.split("\\.|_|-");
|
String parts[] = property.split("\\.|_|-");
|
||||||
v.major = Integer.parseInt(parts[1]);
|
int start = "1".equals(parts[0]) ? 1 : 0; // skip "1." prefix
|
||||||
v.minor = Integer.parseInt(parts[2]);
|
v.major = Integer.parseInt(parts[start + 0]);
|
||||||
v.update = Integer.parseInt(parts[3]);
|
v.minor = Integer.parseInt(parts[start + 1]);
|
||||||
|
v.update = Integer.parseInt(parts[start + 2]);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isAnnInvHUniversalMethodImpl() {
|
public static boolean isAnnInvHUniversalMethodImpl() {
|
||||||
JavaVersion v = JavaVersion.getLocalVersion();
|
JavaVersion v = JavaVersion.getLocalVersion();
|
||||||
return v != null && (v.major < 8 || (v.major == 8 && v.update <= 71));
|
return v != null && (v.major < 8 || (v.major == 8 && v.update <= 71));
|
||||||
@@ -37,5 +37,10 @@ public class JavaVersion {
|
|||||||
JavaVersion v = JavaVersion.getLocalVersion();
|
JavaVersion v = JavaVersion.getLocalVersion();
|
||||||
return v != null && (v.major > 8 && v.update >= 76);
|
return v != null && (v.major > 8 && v.update >= 76);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAtLeast(int major) {
|
||||||
|
JavaVersion v = JavaVersion.getLocalVersion();
|
||||||
|
return v != null && v.major >= major;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class Reflections {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Object getFieldValue(final Object obj, final String fieldName) throws Exception {
|
public static Object getFieldValue(final Object obj, final String fieldName) throws Exception {
|
||||||
final Field field = getField(obj.getClass(), fieldName);
|
final Field field = getField(obj.getClass(), fieldName);
|
||||||
return field.get(obj);
|
return field.get(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,13 +33,16 @@ public class Reflections {
|
|||||||
ctor.setAccessible(true);
|
ctor.setAccessible(true);
|
||||||
return ctor;
|
return ctor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object newInstance(String className, Object ... args) throws Exception {
|
||||||
|
return getFirstCtor(className).newInstance(args);
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> T createWithoutConstructor ( Class<T> classToInstantiate )
|
public static <T> T createWithoutConstructor ( Class<T> classToInstantiate )
|
||||||
throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
|
throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
|
||||||
return createWithConstructor(classToInstantiate, Object.class, new Class[0], new Object[0]);
|
return createWithConstructor(classToInstantiate, Object.class, new Class[0], new Object[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings ( {"unchecked"} )
|
@SuppressWarnings ( {"unchecked"} )
|
||||||
public static <T> T createWithConstructor ( Class<T> classToInstantiate, Class<? super T> constructorClass, Class<?>[] consArgTypes, Object[] consArgs )
|
public static <T> T createWithConstructor ( Class<T> classToInstantiate, Class<? super T> constructorClass, Class<?>[] consArgTypes, Object[] consArgs )
|
||||||
throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
|
throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
|
||||||
|
|||||||
@@ -16,12 +16,42 @@ public class DelegateSecurityManager extends SecurityManager {
|
|||||||
this.securityManager = securityManager;
|
this.securityManager = securityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BEGIN fixes for JDK10+ compatibility
|
||||||
|
|
||||||
@SuppressWarnings({"deprecation"})
|
@SuppressWarnings({"deprecation"})
|
||||||
@Override
|
//@Override
|
||||||
public boolean getInCheck() {
|
public boolean getInCheck() {
|
||||||
return getSecurityManager().getInCheck();
|
//return getSecurityManager().getInCheck();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"deprecation"})
|
||||||
|
//@Override
|
||||||
|
public boolean checkTopLevelWindow(Object window) {
|
||||||
|
//return getSecurityManager().checkTopLevelWindow(window);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"deprecation"})
|
||||||
|
//@Override
|
||||||
|
public void checkSystemClipboardAccess() {
|
||||||
|
//getSecurityManager().checkSystemClipboardAccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"deprecation"})
|
||||||
|
//@Override
|
||||||
|
public void checkAwtEventQueueAccess() {
|
||||||
|
//getSecurityManager().checkAwtEventQueueAccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"deprecation"})
|
||||||
|
//@Override
|
||||||
|
public void checkMemberAccess(Class<?> clazz, int which) {
|
||||||
|
//getSecurityManager().checkMemberAccess(clazz, which);
|
||||||
|
}
|
||||||
|
|
||||||
|
//END fixes for JDK10+ compatibility
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSecurityContext() {
|
public Object getSecurityContext() {
|
||||||
return getSecurityManager().getSecurityContext();
|
return getSecurityManager().getSecurityContext();
|
||||||
@@ -138,29 +168,11 @@ public class DelegateSecurityManager extends SecurityManager {
|
|||||||
getSecurityManager().checkPropertyAccess(key);
|
getSecurityManager().checkPropertyAccess(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"deprecation"})
|
|
||||||
@Override
|
|
||||||
public boolean checkTopLevelWindow(Object window) {
|
|
||||||
return getSecurityManager().checkTopLevelWindow(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkPrintJobAccess() {
|
public void checkPrintJobAccess() {
|
||||||
getSecurityManager().checkPrintJobAccess();
|
getSecurityManager().checkPrintJobAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"deprecation"})
|
|
||||||
@Override
|
|
||||||
public void checkSystemClipboardAccess() {
|
|
||||||
getSecurityManager().checkSystemClipboardAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({"deprecation"})
|
|
||||||
@Override
|
|
||||||
public void checkAwtEventQueueAccess() {
|
|
||||||
getSecurityManager().checkAwtEventQueueAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkPackageAccess(String pkg) {
|
public void checkPackageAccess(String pkg) {
|
||||||
|
|
||||||
@@ -177,12 +189,6 @@ public class DelegateSecurityManager extends SecurityManager {
|
|||||||
getSecurityManager().checkSetFactory();
|
getSecurityManager().checkSetFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"deprecation"})
|
|
||||||
@Override
|
|
||||||
public void checkMemberAccess(Class<?> clazz, int which) {
|
|
||||||
getSecurityManager().checkMemberAccess(clazz, which);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkSecurityAccess(String target) {
|
public void checkSecurityAccess(String target) {
|
||||||
getSecurityManager().checkSecurityAccess(target);
|
getSecurityManager().checkSecurityAccess(target);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
// TODO per-thread secmgr
|
||||||
public class ExecCheckingSecurityManager extends SecurityManager {
|
public class ExecCheckingSecurityManager extends SecurityManager {
|
||||||
public ExecCheckingSecurityManager() {
|
public ExecCheckingSecurityManager() {
|
||||||
this(true);
|
this(true);
|
||||||
@@ -41,7 +42,6 @@ public class ExecCheckingSecurityManager extends SecurityManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class ExecException extends RuntimeException {
|
public static class ExecException extends RuntimeException {
|
||||||
private final String threadName = Thread.currentThread().getName();
|
private final String threadName = Thread.currentThread().getName();
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package ysoserial;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class CiTest {
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
System.out.println("System.getProperties(): " + System.getProperties());
|
||||||
|
System.out.println("System.getenv(): " + System.getenv());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,6 @@ public class CommandExecTest implements CustomTest {
|
|||||||
@Override
|
@Override
|
||||||
public void run(Callable<Object> payload) throws Exception {
|
public void run(Callable<Object> payload) throws Exception {
|
||||||
Assert.assertFalse("test file should not exist", testFile.exists());
|
Assert.assertFalse("test file should not exist", testFile.exists());
|
||||||
Exception err;
|
|
||||||
try {
|
try {
|
||||||
payload.call();
|
payload.call();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -47,9 +47,12 @@ public class FileUploadTest implements CustomTest {
|
|||||||
payload.call();
|
payload.call();
|
||||||
|
|
||||||
File found = null;
|
File found = null;
|
||||||
for ( File f : this.repo.listFiles()) {
|
for (int i = 0; i < 50 && found == null; i++) { // try for 5s before failing
|
||||||
found = f;
|
for (File f : this.repo.listFiles()) {
|
||||||
break;
|
found = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
Assert.assertNotNull("File not copied", found);
|
Assert.assertNotNull("File not copied", found);
|
||||||
if (OS.get() != OS.WINDOWS) {
|
if (OS.get() != OS.WINDOWS) {
|
||||||
@@ -60,11 +63,21 @@ public class FileUploadTest implements CustomTest {
|
|||||||
} finally {
|
} finally {
|
||||||
if ( this.repo.exists()) {
|
if ( this.repo.exists()) {
|
||||||
for ( File f : this.repo.listFiles()) {
|
for ( File f : this.repo.listFiles()) {
|
||||||
f.deleteOnExit();
|
safeDeleteOnExit(f);
|
||||||
}
|
}
|
||||||
this.repo.deleteOnExit();
|
safeDeleteOnExit(this.repo);
|
||||||
}
|
}
|
||||||
this.source.deleteOnExit();
|
safeDeleteOnExit(this.source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void safeDeleteOnExit(File f) {
|
||||||
|
try {
|
||||||
|
if (f.exists()) {
|
||||||
|
f.deleteOnExit();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,8 @@ import org.junit.runner.RunWith;
|
|||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
import ysoserial.CustomDeserializer;
|
import ysoserial.*;
|
||||||
import ysoserial.CustomPayloadArgs;
|
|
||||||
import ysoserial.CustomTest;
|
|
||||||
import ysoserial.Deserializer;
|
|
||||||
import ysoserial.Serializer;
|
|
||||||
import ysoserial.util.Throwables;
|
import ysoserial.util.Throwables;
|
||||||
import ysoserial.WrappedTest;
|
|
||||||
import ysoserial.payloads.TestHarnessTest.ExecMockPayload;
|
import ysoserial.payloads.TestHarnessTest.ExecMockPayload;
|
||||||
import ysoserial.payloads.TestHarnessTest.NoopMockPayload;
|
import ysoserial.payloads.TestHarnessTest.NoopMockPayload;
|
||||||
import ysoserial.payloads.annotation.Dependencies;
|
import ysoserial.payloads.annotation.Dependencies;
|
||||||
@@ -71,10 +66,10 @@ public class PayloadsTest {
|
|||||||
public static void testPayload ( final Class<? extends ObjectPayload<?>> payloadClass, final Class<?>[] addlClassesForClassLoader )
|
public static void testPayload ( final Class<? extends ObjectPayload<?>> payloadClass, final Class<?>[] addlClassesForClassLoader )
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String command = "hostname";
|
String command = "hostname";
|
||||||
String[] deps = buildDeps(payloadClass);
|
|
||||||
|
|
||||||
PayloadTest t = payloadClass.getAnnotation(PayloadTest.class);
|
PayloadTest t = payloadClass.getAnnotation(PayloadTest.class);
|
||||||
|
|
||||||
|
int tries = 1;
|
||||||
if ( t != null ) {
|
if ( t != null ) {
|
||||||
if ( !t.skip().isEmpty() ) {
|
if ( !t.skip().isEmpty() ) {
|
||||||
Assume.assumeTrue(t.skip(), false);
|
Assume.assumeTrue(t.skip(), false);
|
||||||
@@ -83,8 +78,13 @@ public class PayloadsTest {
|
|||||||
if ( !t.precondition().isEmpty() ) {
|
if ( !t.precondition().isEmpty() ) {
|
||||||
Assume.assumeTrue("Precondition: " + t.precondition(), checkPrecondition(payloadClass, t.precondition()));
|
Assume.assumeTrue("Precondition: " + t.precondition(), checkPrecondition(payloadClass, t.precondition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! t.flaky().isEmpty()) {
|
||||||
|
tries = 5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] deps = buildDeps(payloadClass);
|
||||||
String payloadCommand = command;
|
String payloadCommand = command;
|
||||||
Class<?> customDeserializer = null;
|
Class<?> customDeserializer = null;
|
||||||
Object testHarness = null;
|
Object testHarness = null;
|
||||||
@@ -107,17 +107,28 @@ public class PayloadsTest {
|
|||||||
customDeserializer = ((CustomDeserializer)testHarness).getCustomDeserializer();
|
customDeserializer = ((CustomDeserializer)testHarness).getCustomDeserializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecCheckingSecurityManager sm = new ExecCheckingSecurityManager();
|
// TODO per-thread secmgr to enforce no detonation during deserialization
|
||||||
final byte[] serialized = sm.callWrapped(makeSerializeCallable(payloadClass, payloadCommand));
|
final byte[] serialized = makeSerializeCallable(payloadClass, payloadCommand).call();
|
||||||
Callable<Object> callable = makeDeserializeCallable(t, addlClassesForClassLoader, deps, serialized, customDeserializer);
|
Callable<Object> callable = makeDeserializeCallable(t, addlClassesForClassLoader, deps, serialized, customDeserializer);
|
||||||
if ( testHarness instanceof WrappedTest ) {
|
if ( testHarness instanceof WrappedTest ) {
|
||||||
callable = ( (WrappedTest) testHarness ).createCallable(callable);
|
callable = ( (WrappedTest) testHarness ).createCallable(callable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( testHarness instanceof CustomTest ) {
|
if (testHarness instanceof CustomTest) {
|
||||||
( (CustomTest) testHarness ).run(callable);
|
// if marked as flaky try up to 5 times
|
||||||
return;
|
Exception ex = new Exception();
|
||||||
|
for (int i = 0; i < tries; i++) {
|
||||||
|
try {
|
||||||
|
((CustomTest) testHarness).run(callable);
|
||||||
|
ex = null;
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ex != null) throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user