forked from nidhi0512/JavaVulnerableLab
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCowsay1.java
More file actions
28 lines (23 loc) · 769 Bytes
/
Cowsay1.java
File metadata and controls
28 lines (23 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.scalesec.vulnado;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Cowsay {
public static String run(String input) {
ProcessBuilder processBuilder = new ProcessBuilder();
String cmd = "/usr/games/cowsay '" + input + "'";
System.out.println(cmd);
processBuilder.command("bash", "-c", cmd);
StringBuilder output = new StringBuilder();
try {
Process process = processBuilder.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
output.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return output.toString();
}
}