[BUGFIX] Added redirect for issue #161

For `exec(Ljava/lang/Runtime;[Ljava/lang/String;)Ljava/lang/Process;`
This commit is contained in:
JKetelaar
2017-02-03 00:11:21 +01:00
parent 25d46acb16
commit d6f45ed9cb
@@ -6,34 +6,39 @@ import java.io.IOException;
public class RuntimeRedirect { public class RuntimeRedirect {
public static Runtime getRuntime(){ public static Runtime getRuntime() {
return Runtime.getRuntime(); return Runtime.getRuntime();
} }
public static int availableProcessors(Runtime r){ public static int availableProcessors(Runtime r) {
return 2; return 2;
} }
public static long totalMemory(Runtime runtime){ public static long totalMemory(Runtime runtime) {
return (long) 1024; return (long) 1024;
} }
public static long freeMemory(Runtime runtime){ public static long freeMemory(Runtime runtime) {
return (long) 1024; return (long) 1024;
} }
public static Process exec(Runtime r,String s){ public static Process exec(Runtime r, String[] s) {
if (s.contains("ping")){ System.out.println("Blocked attempted command: " + s);
System.out.println("Faked attempted command: " + s); throw RedirectClassAdapter.createSecurityException();
try { }
return r.exec("ping 127.0.0.1");
} catch (IOException e) { public static Process exec(Runtime r, String s) {
throw RedirectClassAdapter.createSecurityException(); if (s.contains("ping")) {
} System.out.println("Faked attempted command: " + s);
}else{ try {
System.out.println("Blocked attempted command: " + s); return r.exec("ping 127.0.0.1");
throw RedirectClassAdapter.createSecurityException(); } catch (IOException e) {
} throw RedirectClassAdapter.createSecurityException();
} }
} else {
System.out.println("Blocked attempted command: " + s);
throw RedirectClassAdapter.createSecurityException();
}
}
} }