■ ■ ■ ■ ■ ■
src/main/java/org/owasp/wrongsecrets/challenges/docker/BinaryExecutionHelper.java
| skipped 24 lines |
25 | 25 | | if (Strings.isNullOrEmpty(guess)) { |
26 | 26 | | result = executeCommand(execFile, "spoil"); |
27 | 27 | | } else { |
28 | | - | result = executeCommand(execFile, "guess " + guess); |
| 28 | + | result = executeCommand(execFile, "guess", guess); |
29 | 29 | | } |
| 30 | + | log.info("stdout challenge {}: {}", challengeNumber, result); |
| 31 | + | |
30 | 32 | | deleteFile(execFile); |
31 | | - | log.info("stdout challenge {}: {}", challengeNumber, result); |
32 | 33 | | return result; |
33 | 34 | | } catch (IOException | NullPointerException | InterruptedException e) { |
34 | 35 | | log.warn("Error executing:", e); |
| skipped 18 lines |
53 | 54 | | |
54 | 55 | | } |
55 | 56 | | |
56 | | - | private String executeCommand(File execFile, String argument) throws IOException, InterruptedException { |
57 | | - | ProcessBuilder ps = new ProcessBuilder(execFile.getPath(), argument); |
| 57 | + | private String executeCommand(File execFile, String argument, String argument2) throws IOException, InterruptedException { |
| 58 | + | ProcessBuilder ps; |
| 59 | + | if (Strings.isNullOrEmpty(argument2)) { |
| 60 | + | ps = new ProcessBuilder(execFile.getPath(), argument); |
| 61 | + | } else { |
| 62 | + | ps = new ProcessBuilder(execFile.getPath(), argument, argument2); |
| 63 | + | } |
58 | 64 | | ps.redirectErrorStream(true); |
59 | 65 | | Process pr = ps.start(); |
60 | 66 | | BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream())); |
61 | 67 | | String result = in.readLine(); |
62 | 68 | | pr.waitFor(); |
63 | 69 | | return result; |
| 70 | + | } |
| 71 | + | |
| 72 | + | private String executeCommand(File execFile, String argument) throws IOException, InterruptedException { |
| 73 | + | return executeCommand(execFile, argument, ""); |
64 | 74 | | } |
65 | 75 | | |
66 | 76 | | private boolean useX86() { |
| skipped 57 lines |