in src/main/java/Main.java [158:189]
public void pathTraversal2(HttpServletRequest request) throws IOException {
javax.servlet.http.Cookie[] theCookies = request.getCookies();
String path = "";
if (theCookies != null) {
for (javax.servlet.http.Cookie theCookie : theCookies) {
if (theCookie.getName().equals("thePath")) {
path = decode(theCookie.getValue(), "UTF-8");
break;
}
}
}
String fileName = "";
if (!path.equals("")) {
if (path.equals(VALID_PATH1)) {
fileName = VALID_PATH1;
} else if (path.equals(VALID_PATH2)) {
fileName = VALID_PATH2;
} else {
fileName = DEFAULT_VALID_PATH;
}
String decStr = new String(org.apache.commons.codec.binary.Base64.decodeBase64(
org.apache.commons.codec.binary.Base64.encodeBase64(fileName.getBytes())));
try(java.io.FileOutputStream fileOutputStream = new java.io.FileOutputStream(decStr))
{
java.io.FileDescriptor fd = fileOutputStream.getFD();
System.out.println(fd.toString());
} catch(Exception exception) {
System.out.println(exception);
}
}
}