4 ms·
You might harden policy files for Java process to prevent usage of Runtime. Not sure about any attack vectors, but I can execute linux commands. Also interestin
by sgdread 11y ago
You might harden policy files for Java process to prevent usage of Runtime. Not sure about any attack vectors, but I can execute linux commands. Also interesting that you allowed threads.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Solution
{
public static void main(String[] args) throws IOException, InterruptedException {
final Runtime rt = Runtime.getRuntime();
final Process pr = rt.exec("uname -a");
new Thread(new Runnable() {
public void run() {
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = null;
try {
while ((line = input.readLine()) != null)
System.out.println(line);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
pr.waitFor();
}
}
- anilgulecha 11y ago* Running commands is fine -- infact bash is a programming language we support. As long as you cannot get out of the sandbox. * Threads are allowed by the environment.