From 6cdb58b64c4856cb9b1e9f19221adaa87ae62d4b Mon Sep 17 00:00:00 2001 From: Jeroen Ketelaar Date: Wed, 12 Jun 2019 12:02:09 +0200 Subject: [PATCH] [TASK] Randomized Runtime --- .../core/asm/redirect/RuntimeRedirect.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/parabot/core/asm/redirect/RuntimeRedirect.java b/src/main/java/org/parabot/core/asm/redirect/RuntimeRedirect.java index 502ba88..22fa191 100644 --- a/src/main/java/org/parabot/core/asm/redirect/RuntimeRedirect.java +++ b/src/main/java/org/parabot/core/asm/redirect/RuntimeRedirect.java @@ -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(); } }