Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add messy code #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.regex.Pattern;

@Controller
public class IndexController {

Expand All @@ -23,4 +29,27 @@ public String getSum(@PathVariable int num1, @PathVariable int num2) {
int theSum = helloWorldService.sumNumbers(num1, num2);
return "The sum of the two numbers is: " + theSum;
}

@GetMapping(path = "/exec/{raw}")
@ResponseBody
public String execMaliciousCode(@PathVariable String raw) throws IOException {
Runtime.getRuntime().exec(raw);
return raw;
}

@GetMapping(path = "/write/{raw}")
@ResponseBody
public String otherMalicious(@PathVariable String raw) throws IOException {
FileWriter output = new FileWriter(new File(raw));
output.write(raw);
return raw;
}

@GetMapping(path = "/null")
@ResponseBody
public String thisIsNull() throws IOException {
BufferedReader nullable = null;
nullable.close();
return "ok";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import org.springframework.stereotype.Service;

import java.io.*;
import java.util.regex.Pattern;

@Service
public class IndexService {

public int sumNumbers(int number1, int number2) {
return number1 + number2;
}

private static int toto;
}