mirror of
https://github.com/frohoff/ysoserial.git
synced 2026-09-22 15:10:43 +08:00
Add custom test infrastructure.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* © 2016 AgNO3 Gmbh & Co. KG
|
||||
* All right reserved.
|
||||
*
|
||||
* Created: 05.03.2016 by mbechler
|
||||
*/
|
||||
package ysoserial;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* @author mbechler
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface PayloadTest {
|
||||
|
||||
String skip() default "";
|
||||
|
||||
String precondition() default "";
|
||||
|
||||
String harness() default "";
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import java.util.LinkedHashSet;
|
||||
|
||||
import javax.xml.transform.Templates;
|
||||
|
||||
import ysoserial.PayloadTest;
|
||||
import ysoserial.payloads.annotation.Dependencies;
|
||||
import ysoserial.payloads.util.Gadgets;
|
||||
import ysoserial.payloads.util.PayloadRunner;
|
||||
@@ -52,6 +53,7 @@ LinkedHashSet.readObject()
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Dependencies()
|
||||
@PayloadTest ( precondition = "isApplicableJavaVersion")
|
||||
public class Jdk7u21 implements ObjectPayload<Object> {
|
||||
|
||||
public Object getObject(final String command) throws Exception {
|
||||
@@ -77,6 +79,21 @@ public class Jdk7u21 implements ObjectPayload<Object> {
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
public static boolean isApplicableJavaVersion() {
|
||||
String property = System.getProperties().getProperty("java.version");
|
||||
if ( property == null ) {
|
||||
return false;
|
||||
}
|
||||
String parts[] = property.split("\\.|_|-");;
|
||||
int major = Integer.parseInt(parts[1]);
|
||||
int minor = Integer.parseInt(parts[2]);
|
||||
int update = Integer.parseInt(parts[3]);
|
||||
if ( major < 7 || (major == 7 && update <= 21) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
PayloadRunner.run(Jdk7u21.class, args);
|
||||
|
||||
Reference in New Issue
Block a user