diff --git a/src/main/java/org/t246osslab/easybuggy4sb/vulnerabilities/UnintendedFileDisclosureController.java b/src/main/java/org/t246osslab/easybuggy4sb/vulnerabilities/UnintendedFileDisclosureController.java index f30e220..8e77c18 100644 --- a/src/main/java/org/t246osslab/easybuggy4sb/vulnerabilities/UnintendedFileDisclosureController.java +++ b/src/main/java/org/t246osslab/easybuggy4sb/vulnerabilities/UnintendedFileDisclosureController.java @@ -1,76 +1,33 @@ package org.t246osslab.easybuggy4sb.vulnerabilities; -import java.io.IOException; import java.util.Locale; -import java.util.Properties; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; -import org.springframework.context.NoSuchMessageException; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; @Controller public class UnintendedFileDisclosureController { - private static final Logger log = LoggerFactory.getLogger(UnintendedFileDisclosureController.class); - @Autowired MessageSource msg; @RequestMapping(value = "/clientinfo") - public void clientinfo(HttpServletResponse res, Locale locale) throws IOException { - Resource resource = new ClassPathResource("/templates/clientinfo.html"); - String htmlString = IOUtils.toString(resource.getInputStream()); - htmlString = repacLocalizedString(htmlString, locale); - res.getWriter().write(htmlString); + public ModelAndView process(ModelAndView mav, Locale locale) { + mav.setViewName("clientinfo"); + mav.addObject("title", msg.getMessage("section.client.info", null, locale)); + return mav; } - + @RequestMapping(value = "/serverinfo") - public void serverinfo(HttpSession ses, HttpServletResponse res, Locale locale) throws IOException { - StringBuilder sb = new StringBuilder(); - Properties properties = System.getProperties(); - for (Object key : properties.keySet()) { - Object value = properties.get(key); - sb.append("" + key + "" + value + ""); - } - Resource resource = new ClassPathResource("/templates/serverinfo.html"); - String htmlString = IOUtils.toString(resource.getInputStream()); - String userid = (String) ses.getAttribute("userid"); - if(userid == null){ - res.sendRedirect("/"); - return; - } - htmlString = htmlString.replace("", userid); - htmlString = htmlString.replace("", sb.toString()); - htmlString = repacLocalizedString(htmlString, locale); - res.getWriter().write(htmlString); - } - - private String repacLocalizedString(String htmlString, Locale locale) { - while (true) { - int startIndex = htmlString.indexOf(""); - if (startIndex < 0 || endIndex < 0) { - break; - } - String keyString = htmlString.substring(startIndex + 14, endIndex); - try { - htmlString = htmlString.replace("", - msg.getMessage(keyString, null, locale)); - } catch (NoSuchMessageException e) { - log.warn("{} is not defined in message.properties", keyString, e); - break; - } - } - return htmlString; + public ModelAndView process(@RequestParam(value = "string", required = false) String string, ModelAndView mav, + Locale locale) { + mav.setViewName("serverinfo"); + mav.addObject("title", msg.getMessage("section.server.info", null, locale)); + mav.addObject("properties", System.getProperties()); + return mav; } } \ No newline at end of file diff --git a/src/main/resources/templates/clientinfo.html b/src/main/resources/templates/clientinfo.html index 041d8ff..b80cf61 100644 --- a/src/main/resources/templates/clientinfo.html +++ b/src/main/resources/templates/clientinfo.html @@ -1,49 +1,36 @@ - - - - -<!-- [REPLACE:section.client.info] --> - - - - - - + + +
- - - - - +
+
-

-   -

-
-
-
+ + + + + + +

-
-
+ - \ No newline at end of file + diff --git a/src/main/resources/templates/serverinfo.html b/src/main/resources/templates/serverinfo.html index ede07e7..606d500 100644 --- a/src/main/resources/templates/serverinfo.html +++ b/src/main/resources/templates/serverinfo.html @@ -1,34 +1,14 @@ - - - - -<!-- [REPLACE:section.server.info] --> - - - - - - + + +
- - - - - -
-

-   -

-
: -
-
-
- - - - - - -
+
+ + + + + + +

\ No newline at end of file diff --git a/src/main/webapp/uid/clientinfo.html b/src/main/webapp/uid/clientinfo.html index 64d0a4c..0bc7e7c 100644 --- a/src/main/webapp/uid/clientinfo.html +++ b/src/main/webapp/uid/clientinfo.html @@ -1,3 +1,4 @@ +