mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-08 00:38:38 +00:00
Fixed issue with reflection
This commit is contained in:
+1
-1
@@ -5,5 +5,5 @@ mvn install:install-file -DgroupId=${project.groupId} -DartifactId=${project.art
|
|||||||
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.33 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.33.jar -DlocalRepositoryPath=../../Maven-Repository
|
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.33 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.33.jar -DlocalRepositoryPath=../../Maven-Repository
|
||||||
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.34 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.34.jar -DlocalRepositoryPath=../../Maven-Repository
|
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.34 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.34.jar -DlocalRepositoryPath=../../Maven-Repository
|
||||||
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.35 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.35.jar -DlocalRepositoryPath=../../Maven-Repository
|
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.35 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.35.jar -DlocalRepositoryPath=../../Maven-Repository
|
||||||
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.35 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.35.jar -DlocalRepositoryPath=../../Maven-Repository
|
|
||||||
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.36 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.36.jar -DlocalRepositoryPath=../../Maven-Repository
|
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.36 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.36.jar -DlocalRepositoryPath=../../Maven-Repository
|
||||||
|
:: mvn install:install-file -DgroupId=org.parabot -DartifactId=client -Dversion=2.2.4 -Dpackaging=jar -Dfile=../target/Parabot-V2.2.4.jar -DlocalRepositoryPath=../../Maven-Repository
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>org.parabot</groupId>
|
<groupId>org.parabot</groupId>
|
||||||
<artifactId>client</artifactId>
|
<artifactId>client</artifactId>
|
||||||
<version>2.2.36</version>
|
<version>2.2.4</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
@@ -58,13 +58,9 @@
|
|||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>deploy.bat</exclude>
|
<exclude>deploy.bat</exclude>
|
||||||
<exclude>package.bat</exclude>
|
|
||||||
<exclude>clean.bat</exclude>
|
|
||||||
</excludes>
|
</excludes>
|
||||||
<!--<includes>-->
|
<!--<includes>-->
|
||||||
<!--<include>deploy.bat</include>-->
|
<!--<include>deploy.bat</include>-->
|
||||||
<!--<include>package.bat</include>-->
|
|
||||||
<!--<include>clean.bat</include>-->
|
|
||||||
<!--</includes>-->
|
<!--</includes>-->
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public final class Landing {
|
|||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Core.inDebugMode() && !Core.isValid()) {
|
if (!Core.inDebugMode() && !Core.isValid() && Core.hasValidation()) {
|
||||||
UILog.log("Updates",
|
UILog.log("Updates",
|
||||||
"Please download the newest version of Parabot at "
|
"Please download the newest version of Parabot at "
|
||||||
+ Configuration.DOWNLOAD_BOT,
|
+ Configuration.DOWNLOAD_BOT,
|
||||||
@@ -149,8 +149,10 @@ public final class Landing {
|
|||||||
case "-no_sec":
|
case "-no_sec":
|
||||||
Core.disableSec();
|
Core.disableSec();
|
||||||
break;
|
break;
|
||||||
}
|
case "-no_validation":
|
||||||
|
Core.disableValidation();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,17 @@ public class Core {
|
|||||||
private static boolean dump;
|
private static boolean dump;
|
||||||
private static boolean loadLocal; //Loads both local and public scripts/servers
|
private static boolean loadLocal; //Loads both local and public scripts/servers
|
||||||
|
|
||||||
|
private static boolean validate = true;
|
||||||
private static boolean secure = true;
|
private static boolean secure = true;
|
||||||
|
|
||||||
|
public static void disableValidation() {
|
||||||
|
Core.validate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasValidation() {
|
||||||
|
return validate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enabled loadLocal mode
|
* Enabled loadLocal mode
|
||||||
*
|
*
|
||||||
@@ -118,7 +127,6 @@ public class Core {
|
|||||||
* Checks the version of the bot using a checksum of the jar comparison against checksum given by the website
|
* Checks the version of the bot using a checksum of the jar comparison against checksum given by the website
|
||||||
* @return <b>true</b> if no new version is found, otherwise <b>false</b>.
|
* @return <b>true</b> if no new version is found, otherwise <b>false</b>.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static boolean checksumValid(){
|
private static boolean checksumValid(){
|
||||||
File f = new File(Landing.class.getProtectionDomain().getCodeSource().getLocation().getFile());
|
File f = new File(Landing.class.getProtectionDomain().getCodeSource().getLocation().getFile());
|
||||||
if (f.isFile()) {
|
if (f.isFile()) {
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
|||||||
|
|
||||||
if(class_out != null)
|
if(class_out != null)
|
||||||
class_out.println(owner);
|
class_out.println(owner);
|
||||||
|
|
||||||
super.visitMethodInsn(opcode, owner, name, desc);
|
super.visitMethodInsn(opcode, owner, name, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,34 @@
|
|||||||
package org.parabot.core.asm.redirect;
|
package org.parabot.core.asm.redirect;
|
||||||
|
|
||||||
|
import org.parabot.core.asm.RedirectClassAdapter;
|
||||||
|
import org.parabot.environment.scripts.Script;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.parabot.core.asm.RedirectClassAdapter;
|
|
||||||
|
|
||||||
public class ClassRedirect {
|
public class ClassRedirect {
|
||||||
|
|
||||||
public static Object newInstance(Class<?>c){
|
public static Object newInstance(Class<?> c) throws IllegalAccessException, InstantiationException {
|
||||||
|
if (validStack()){
|
||||||
|
return c.newInstance();
|
||||||
|
}
|
||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Field getDeclaredField(Class<?> c, String s) throws NoSuchFieldException, SecurityException {
|
public static Field getDeclaredField(Class<?> c, String s) throws NoSuchFieldException, SecurityException {
|
||||||
|
if (validStack()) {
|
||||||
|
return c.getDeclaredField(s);
|
||||||
|
}
|
||||||
System.out.println(c.getName() + "." + c.getDeclaredField(s) + " Blocked.");
|
System.out.println(c.getName() + "." + c.getDeclaredField(s) + " Blocked.");
|
||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Method getDeclaredMethod(Class<?> c, String name, Class<?>... params) throws NoSuchMethodException, SecurityException {
|
public static Method getDeclaredMethod(Class<?> c, String name, Class<?>... params) throws NoSuchMethodException, SecurityException {
|
||||||
|
if (validStack()) {
|
||||||
|
return c.getDeclaredMethod(name, params);
|
||||||
|
}
|
||||||
System.out.println(c.getName() + "#" + c.getDeclaredMethod(name, params) + " Blocked.");
|
System.out.println(c.getName() + "#" + c.getDeclaredMethod(name, params) + " Blocked.");
|
||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
@@ -32,6 +43,63 @@ public class ClassRedirect {
|
|||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Field[] getDeclaredFields(Class<?> c) {
|
||||||
|
if (validStack()) {
|
||||||
|
return c.getDeclaredFields();
|
||||||
|
}
|
||||||
|
System.out.println(c.getName() + "#getDeclaredFields()" + " Blocked.");
|
||||||
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Method[] getDeclaredMethods(Class<?> c) {
|
||||||
|
if (validStack()) {
|
||||||
|
return c.getDeclaredMethods();
|
||||||
|
}
|
||||||
|
System.out.println(c.getName() + "#getDeclaredMethods()" + " Blocked.");
|
||||||
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Field[] getFields(Class<?> c){
|
||||||
|
if (validStack()) {
|
||||||
|
return c.getFields();
|
||||||
|
}
|
||||||
|
System.out.println(c.getName() + "#getFields()" + " Blocked.");
|
||||||
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Annotation[] getAnnotations(Class<?> c){
|
||||||
|
if (validStack()){
|
||||||
|
return c.getAnnotations();
|
||||||
|
}
|
||||||
|
System.out.println(c.getName() + "#getFields()" + " Blocked.");
|
||||||
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Method[] getMethods(Class<?> c){
|
||||||
|
if (validStack()) {
|
||||||
|
return c.getMethods();
|
||||||
|
}
|
||||||
|
System.out.println(c.getName() + "#getMethods()" + " Blocked.");
|
||||||
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Method getMethod(Class<?> c, String name, Class<?>... params) throws NoSuchMethodException, SecurityException {
|
||||||
|
if (validStack()) {
|
||||||
|
return c.getMethod(name, params);
|
||||||
|
}
|
||||||
|
System.out.println(c.getName() + "#getMethod()" + " Blocked.");
|
||||||
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Field getField(Class<?> c, String name)
|
||||||
|
throws NoSuchFieldException, SecurityException {
|
||||||
|
if (validStack()) {
|
||||||
|
return c.getField(name);
|
||||||
|
}
|
||||||
|
System.out.println(c.getName() + "#getField()" + " Blocked.");
|
||||||
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
|
}
|
||||||
|
|
||||||
public static String getName(Class<?> c) {
|
public static String getName(Class<?> c) {
|
||||||
if (c.getName().contains("parabot"))
|
if (c.getName().contains("parabot"))
|
||||||
return "java.lang.String";
|
return "java.lang.String";
|
||||||
@@ -39,9 +107,21 @@ public class ClassRedirect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static InputStream getResourceAsStream(Class<?> c, String res) {
|
public static InputStream getResourceAsStream(Class<?> c, String res) {
|
||||||
if(res.contains(".class"))
|
if (validStack()) {
|
||||||
|
return c.getResourceAsStream(res);
|
||||||
|
}
|
||||||
|
if (res.contains(".class")) {
|
||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
|
}
|
||||||
return c.getResourceAsStream(res);
|
return c.getResourceAsStream(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean validStack() {
|
||||||
|
Exception e = new Exception();
|
||||||
|
for (StackTraceElement elem : e.getStackTrace()) {
|
||||||
|
if (elem.getClassName().equals(Script.class.getName()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.parabot.core.reflect;
|
package org.parabot.core.reflect;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -85,6 +86,10 @@ public class RefClass extends RefModifiers {
|
|||||||
return this.clazz.getCanonicalName();
|
return this.clazz.getCanonicalName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Annotation[] getAnnotations(){
|
||||||
|
return this.clazz.getAnnotations();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type of this class
|
* Gets the type of this class
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user