mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-02 16:49:10 +00:00
[TASK] Randomized Runtime
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package org.parabot.core.asm.redirect;
|
||||
|
||||
import org.parabot.api.calculations.Random;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.asm.RedirectClassAdapter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RuntimeRedirect {
|
||||
|
||||
@@ -11,32 +14,32 @@ public class RuntimeRedirect {
|
||||
}
|
||||
|
||||
public static int availableProcessors(Runtime r) {
|
||||
return 2;
|
||||
return Random.between(1, 4);
|
||||
}
|
||||
|
||||
public static long totalMemory(Runtime runtime) {
|
||||
return (long) 1024;
|
||||
return (long) Random.between(1024, 4096);
|
||||
}
|
||||
|
||||
public static long freeMemory(Runtime runtime) {
|
||||
return (long) 1024;
|
||||
return (long) Random.between(1024, 4096);
|
||||
}
|
||||
|
||||
public static Process exec(Runtime r, String[] s) {
|
||||
System.out.println("Blocked attempted command: " + s);
|
||||
Core.verbose("Blocked attempted command: " + Arrays.toString(s));
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
|
||||
public static Process exec(Runtime r, String s) {
|
||||
if (s.contains("ping")) {
|
||||
System.out.println("Faked attempted command: " + s);
|
||||
Core.verbose("Faked attempted command: " + s);
|
||||
try {
|
||||
return r.exec("ping 8.8.8.8");
|
||||
} catch (IOException e) {
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
} else {
|
||||
System.out.println("Blocked attempted command: " + s);
|
||||
Core.verbose("Blocked attempted command: " + s);
|
||||
throw RedirectClassAdapter.createSecurityException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user