mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
Fixed issue with reflection
This commit is contained in:
+2
-2
@@ -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.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.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>
|
||||
<artifactId>client</artifactId>
|
||||
<version>2.2.36</version>
|
||||
<version>2.2.4</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -58,13 +58,9 @@
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>deploy.bat</exclude>
|
||||
<exclude>package.bat</exclude>
|
||||
<exclude>clean.bat</exclude>
|
||||
</excludes>
|
||||
<!--<includes>-->
|
||||
<!--<include>deploy.bat</include>-->
|
||||
<!--<include>package.bat</include>-->
|
||||
<!--<include>clean.bat</include>-->
|
||||
<!--</includes>-->
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class Landing {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
if (!Core.inDebugMode() && !Core.isValid()) {
|
||||
if (!Core.inDebugMode() && !Core.isValid() && Core.hasValidation()) {
|
||||
UILog.log("Updates",
|
||||
"Please download the newest version of Parabot at "
|
||||
+ Configuration.DOWNLOAD_BOT,
|
||||
@@ -76,81 +76,83 @@ public final class Landing {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
final String arg = args[i].toLowerCase();
|
||||
switch (arg.toLowerCase()) {
|
||||
case "-createdirs":
|
||||
Directories.validate();
|
||||
System.out
|
||||
.println("Directories created, you can now run parabot.");
|
||||
System.exit(0);
|
||||
break;
|
||||
case "-debug":
|
||||
Core.setDebug(true);
|
||||
break;
|
||||
case "-v":
|
||||
case "-verbose":
|
||||
Core.setVerbose(true);
|
||||
break;
|
||||
case "-server":
|
||||
ServerSelector.initServer = args[++i];
|
||||
break;
|
||||
case "-login":
|
||||
username = args[++i];
|
||||
password = args[++i];
|
||||
break;
|
||||
case "-loadlocal":
|
||||
Core.setLoadLocal(true);
|
||||
break;
|
||||
case "-dump":
|
||||
Core.setDump(true);
|
||||
break;
|
||||
case "-scriptsbin":
|
||||
Directories.setScriptCompiledDirectory(new File(args[++i]));
|
||||
break;
|
||||
case "-serversbin":
|
||||
Directories.setServerCompiledDirectory(new File(args[++i]));
|
||||
break;
|
||||
case "-clearcache":
|
||||
File[] cache = Directories.getCachePath().listFiles();
|
||||
if (cache != null) {
|
||||
for (File f : cache) {
|
||||
if (f.exists() && f.canWrite()) {
|
||||
f.delete();
|
||||
case "-createdirs":
|
||||
Directories.validate();
|
||||
System.out
|
||||
.println("Directories created, you can now run parabot.");
|
||||
System.exit(0);
|
||||
break;
|
||||
case "-debug":
|
||||
Core.setDebug(true);
|
||||
break;
|
||||
case "-v":
|
||||
case "-verbose":
|
||||
Core.setVerbose(true);
|
||||
break;
|
||||
case "-server":
|
||||
ServerSelector.initServer = args[++i];
|
||||
break;
|
||||
case "-login":
|
||||
username = args[++i];
|
||||
password = args[++i];
|
||||
break;
|
||||
case "-loadlocal":
|
||||
Core.setLoadLocal(true);
|
||||
break;
|
||||
case "-dump":
|
||||
Core.setDump(true);
|
||||
break;
|
||||
case "-scriptsbin":
|
||||
Directories.setScriptCompiledDirectory(new File(args[++i]));
|
||||
break;
|
||||
case "-serversbin":
|
||||
Directories.setServerCompiledDirectory(new File(args[++i]));
|
||||
break;
|
||||
case "-clearcache":
|
||||
File[] cache = Directories.getCachePath().listFiles();
|
||||
if (cache != null) {
|
||||
for (File f : cache) {
|
||||
if (f.exists() && f.canWrite()) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "-mac":
|
||||
byte[] mac = new byte[6];
|
||||
String str = args[++i];
|
||||
if (str.toLowerCase().equals("random")) {
|
||||
new java.util.Random().nextBytes(mac);
|
||||
} else {
|
||||
i--;
|
||||
for (int j = 0; j < 6; j++) {
|
||||
mac[j] = Byte.parseByte(args[++i], 16); // parses a hex
|
||||
// number
|
||||
break;
|
||||
case "-mac":
|
||||
byte[] mac = new byte[6];
|
||||
String str = args[++i];
|
||||
if (str.toLowerCase().equals("random")) {
|
||||
new java.util.Random().nextBytes(mac);
|
||||
} else {
|
||||
i--;
|
||||
for (int j = 0; j < 6; j++) {
|
||||
mac[j] = Byte.parseByte(args[++i], 16); // parses a hex
|
||||
// number
|
||||
}
|
||||
}
|
||||
}
|
||||
NetworkInterface.setMac(mac);
|
||||
break;
|
||||
case "-proxy":
|
||||
ProxyType type = ProxyType.valueOf(args[++i].toUpperCase());
|
||||
if (type == null) {
|
||||
System.err.println("Invalid proxy type:" + args[i]);
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
ProxySocket.setProxy(type, args[++i],
|
||||
Integer.parseInt(args[++i]));
|
||||
break;
|
||||
case "-auth":
|
||||
ProxySocket.auth = true;
|
||||
ProxySocket.setLogin(args[++i], args[++i]);
|
||||
break;
|
||||
case "-no_sec":
|
||||
Core.disableSec();
|
||||
break;
|
||||
NetworkInterface.setMac(mac);
|
||||
break;
|
||||
case "-proxy":
|
||||
ProxyType type = ProxyType.valueOf(args[++i].toUpperCase());
|
||||
if (type == null) {
|
||||
System.err.println("Invalid proxy type:" + args[i]);
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
ProxySocket.setProxy(type, args[++i],
|
||||
Integer.parseInt(args[++i]));
|
||||
break;
|
||||
case "-auth":
|
||||
ProxySocket.auth = true;
|
||||
ProxySocket.setLogin(args[++i], args[++i]);
|
||||
break;
|
||||
case "-no_sec":
|
||||
Core.disableSec();
|
||||
break;
|
||||
case "-no_validation":
|
||||
Core.disableValidation();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,17 @@ public class Core {
|
||||
private static boolean dump;
|
||||
private static boolean loadLocal; //Loads both local and public scripts/servers
|
||||
|
||||
private static boolean validate = true;
|
||||
private static boolean secure = true;
|
||||
|
||||
|
||||
public static void disableValidation() {
|
||||
Core.validate = false;
|
||||
}
|
||||
|
||||
public static boolean hasValidation() {
|
||||
return validate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return <b>true</b> if no new version is found, otherwise <b>false</b>.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static boolean checksumValid(){
|
||||
File f = new File(Landing.class.getProtectionDomain().getCodeSource().getLocation().getFile());
|
||||
if (f.isFile()) {
|
||||
|
||||
@@ -107,6 +107,7 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
||||
|
||||
if(class_out != null)
|
||||
class_out.println(owner);
|
||||
|
||||
super.visitMethodInsn(opcode, owner, name, desc);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,47 +1,127 @@
|
||||
package org.parabot.core.asm.redirect;
|
||||
|
||||
import org.parabot.core.asm.RedirectClassAdapter;
|
||||
import org.parabot.environment.scripts.Script;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.parabot.core.asm.RedirectClassAdapter;
|
||||
|
||||
public class ClassRedirect {
|
||||
|
||||
public static Object newInstance(Class<?>c){
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
|
||||
public static Field getDeclaredField(Class<?> c, String s) throws NoSuchFieldException, SecurityException{
|
||||
System.out.println(c.getName() + "." + c.getDeclaredField(s) + " Blocked.");
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
|
||||
public static Method getDeclaredMethod(Class<?>c,String name,Class<?>... params) throws NoSuchMethodException, SecurityException{
|
||||
System.out.println(c.getName() + "#" + c.getDeclaredMethod(name,params) + " Blocked.");
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
|
||||
public static Class<?> forName(String name) throws ClassNotFoundException{
|
||||
if(name.contains("parabot"))
|
||||
throw new ClassNotFoundException();
|
||||
return Class.forName(name);
|
||||
}
|
||||
|
||||
public static ClassLoader getClassLoader(Class<?>c){
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
|
||||
public static String getName(Class<?>c){
|
||||
if(c.getName().contains("parabot"))
|
||||
return "java.lang.String";
|
||||
return c.getName();
|
||||
}
|
||||
|
||||
public static InputStream getResourceAsStream(Class<?>c, String res){
|
||||
if(res.contains(".class"))
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
return c.getResourceAsStream(res);
|
||||
}
|
||||
|
||||
public static Object newInstance(Class<?> c) throws IllegalAccessException, InstantiationException {
|
||||
if (validStack()){
|
||||
return c.newInstance();
|
||||
}
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
|
||||
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.");
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
|
||||
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.");
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
|
||||
public static Class<?> forName(String name) throws ClassNotFoundException {
|
||||
if (name.contains("parabot"))
|
||||
throw new ClassNotFoundException();
|
||||
return Class.forName(name);
|
||||
}
|
||||
|
||||
public static ClassLoader getClassLoader(Class<?> c) {
|
||||
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) {
|
||||
if (c.getName().contains("parabot"))
|
||||
return "java.lang.String";
|
||||
return c.getName();
|
||||
}
|
||||
|
||||
public static InputStream getResourceAsStream(Class<?> c, String res) {
|
||||
if (validStack()) {
|
||||
return c.getResourceAsStream(res);
|
||||
}
|
||||
if (res.contains(".class")) {
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
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;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -85,6 +86,10 @@ public class RefClass extends RefModifiers {
|
||||
return this.clazz.getCanonicalName();
|
||||
}
|
||||
|
||||
public Annotation[] getAnnotations(){
|
||||
return this.clazz.getAnnotations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of this class
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user