PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/webgoat/src/main/webapp/main.jsp

http://webgoat.googlecode.com/
JavaServer Pages | 300 lines | 279 code | 19 blank | 2 comment | 26 complexity | 20028447337d1a1d0e9de959efe4d9fc MD5 | raw file
  1. <%@ page contentType="text/html; charset=ISO-8859-1" language="java"
  2. import="org.owasp.webgoat.session.*, org.owasp.webgoat.lessons.Category, org.owasp.webgoat.lessons.AbstractLesson, org.owasp.webgoat.util.*, java.util.*"
  3. errorPage="" %>
  4. <%
  5. Course course = ((Course)session.getAttribute("course"));
  6. WebSession webSession = ((WebSession)session.getAttribute("websession"));
  7. AbstractLesson currentLesson = webSession.getCurrentLesson();
  8. %>
  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  10. <%@page import="org.owasp.webgoat.lessons.RandomLessonAdapter"%>
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  14. <title><%=currentLesson.getTitle()%></title>
  15. <link rel="stylesheet" href="css/webgoat.css" type="text/css" />
  16. <link rel="stylesheet" href="css/lesson.css" type="text/css" />
  17. <link rel="stylesheet" href="css/menu.css" type="text/css" />
  18. <link rel="stylesheet" href="css/layers.css" type="text/css" />
  19. <script language="JavaScript1.2" src="javascript/javascript.js" type="text/javascript"></script>
  20. <script language="JavaScript1.2" src="javascript/menu_system.js" type="text/javascript"></script>
  21. <script language="JavaScript1.2" src="javascript/lessonNav.js" type="text/javascript"></script>
  22. <script language="JavaScript1.2" src="javascript/makeWindow.js" type="text/javascript"></script>
  23. <script language="JavaScript1.2" src="javascript/toggle.js" type="text/javascript"></script>
  24. </head>
  25. <%
  26. final String menuPrefix = WebSession.MENU;
  27. final String submenuPrefix = "submenu";
  28. final String mbutPrefix = "mbut";
  29. String printHint = "";
  30. String printParameters = "";
  31. String printCookies = "";
  32. String lessonComplete = "<img src=\"images/buttons/lessonComplete.jpg\">";
  33. List categories = course.getCategories();
  34. StringBuffer buildList = new StringBuffer();
  35. Iterator iter1 = categories.iterator();
  36. while(iter1.hasNext())
  37. {
  38. Category category = (Category)iter1.next();
  39. buildList.append("'");
  40. buildList.append(menuPrefix);
  41. buildList.append(category.getRanking());
  42. buildList.append("','");
  43. buildList.append(submenuPrefix);
  44. buildList.append(category.getRanking());
  45. buildList.append("','");
  46. buildList.append(mbutPrefix);
  47. buildList.append(category.getRanking());
  48. buildList.append("'");
  49. if (iter1.hasNext())
  50. buildList.append(",");
  51. }%>
  52. <body class="page" onload="setMenuMagic1(10,40,10,'menubottom',<%=buildList%>);trigMM1url('<%= menuPrefix %>',1);MM_preloadImages('images/buttons/hintLeftOver.jpg','images/buttons/hintOver.jpg','images/buttons/hintRightOver.jpg','images/buttons/paramsOver.jpg','images/buttons/htmlOver.jpg','images/buttons/cookiesOver.jpg','images/buttons/javaOver.jpg','images/buttons/plansOver.jpg','images/buttons/logout.jpg','images/buttons/helpOver.jpg'); initIframe();">
  53. <div id="wrap">
  54. <%
  55. int topCord = 140;
  56. int zIndex = 105;
  57. Iterator iter2 = categories.iterator();
  58. while(iter2.hasNext())
  59. {
  60. Category category = (Category)iter2.next();
  61. %>
  62. <div id="<%=menuPrefix + category.getRanking()%>" style="position:absolute; left:30px; top:<%=topCord%>px; width:160px; z-index:<%=zIndex%>"><a href="javascript:;" onclick="trigMenuMagic1('<%=menuPrefix + category.getRanking()%>',1);return false" onfocus="if(this.blur)this.blur()"><img src="images/menu_images/1x1.gif" width="1" height=1"20" name="mbut<%=category.getRanking()%>" border="0" alt=""/><%=category.getName()%></a></div>
  63. <%
  64. topCord=topCord + 30;
  65. zIndex=zIndex + 1;
  66. }
  67. int topSubMenu = 72;
  68. Iterator iter3 = categories.iterator();
  69. while(iter3.hasNext())
  70. {
  71. Category category = (Category)iter3.next();
  72. List lessons = webSession.getLessons(category);
  73. Iterator iter4 = lessons.iterator();
  74. %>
  75. <div id="submenu<%=category.getRanking()%>" class="pviimenudiv" style="position:absolute; left:200px; top:<%=topSubMenu%>px; width:150px; visibility: hidden; z-index:<%=zIndex%>">
  76. <table width="150" border="0" cellspacing="6" cellpadding="0"><%
  77. topSubMenu=topSubMenu+30;
  78. zIndex=zIndex + 1;
  79. while(iter4.hasNext())
  80. {
  81. AbstractLesson lesson = (AbstractLesson)iter4.next();
  82. %><tr>
  83. <td><%=(lesson.isCompleted(webSession) ? lessonComplete : "")%><a href="<%=lesson.getLink()%>"><%=lesson.getTitle()%></a></td>
  84. </tr>
  85. <% if (lesson instanceof RandomLessonAdapter) {
  86. RandomLessonAdapter rla = (RandomLessonAdapter) lesson;
  87. String[] stages = rla.getStages();
  88. if (stages != null)
  89. for (int i=0; i<stages.length; i++) {
  90. %>
  91. <tr><td class="pviimenudivstage"><%=(rla.isStageComplete(webSession, stages[i]) ? lessonComplete : "")%><a href="<%=lesson.getLink() + "&stage=" + (i+1) %>">Stage <%=i+1%>: <%=stages[i] %></a>
  92. </td></tr>
  93. <%
  94. }
  95. }
  96. %>
  97. <%
  98. }
  99. %>
  100. </table>
  101. </div><%
  102. }%>
  103. <div id="top"></div>
  104. <div id="topLeft">
  105. <div align="left">
  106. <% if (currentLesson.getAvailableLanguages().size() != 0 )
  107. {
  108. %>
  109. <form method="get" action="attack" style="display: inline;">
  110. Choose another language: <select name="language" size="1"
  111. onChange="changeLanguage();">
  112. <%
  113. for(String lang: currentLesson.getAvailableLanguages()){
  114. %>
  115. <option value="<%=lang%>"
  116. <% if(webSession.getCurrrentLanguage().equals(lang)) out.println("selected" );%>><%=lang%>
  117. </option>
  118. <%
  119. }
  120. %>
  121. </select></form>
  122. <%
  123. } else {
  124. %>
  125. Internationalization is not available for this lesson
  126. <%
  127. }
  128. %>
  129. </div></div>
  130. <div align="right" id="topRight">
  131. <a href="attack?action=Logout" onmouseout="MM_swapImgRestore()"
  132. onmouseover="MM_swapImage('logout','','images/buttons/logoutOver.jpg',1)"><img
  133. src="images/buttons/logout.jpg" alt="LogOut" name="logout" width="45"
  134. height="22" border="0" id="logout" /></a> <a href="#getFAQ()"
  135. onmouseout="MM_swapImgRestore()"
  136. onmouseover="MM_swapImage('help','','images/buttons/helpOver.jpg',1)"><img
  137. src="images/buttons/help.jpg" alt="Help" name="help" width="22"
  138. height="22" border="0" id="help" /></a>
  139. </div>
  140. <div id="lessonTitle" align="right"><%=currentLesson.getTitle()%></div>
  141. <div id="hMenuBar">
  142. <%
  143. if (webSession.isAuthorizedInLesson(webSession.getRole(), WebSession.SHOWHINTS))
  144. {
  145. %>
  146. <a href="<%= webSession.getCurrentLesson().getLink() %>&show=PreviousHint" target="_top" onclick="MM_nbGroup('down','group1','hintLeft','',1)"
  147. onmouseover="MM_nbGroup('over','hintLeft','images/buttons/hintLeftOver.jpg','',1)"
  148. onmouseout="MM_nbGroup('out')">
  149. <img src="images/buttons/hintLeft.jpg" alt="Previous Hint" name="hintLeft" width="20" height="20" border="0" id="hintLeft"/>
  150. </a>
  151. <a href="<%= webSession.getCurrentLesson().getLink() %>&show=NextHint" target="_top" onclick="MM_nbGroup('down','group1','hint','',1)"
  152. onmouseover="MM_nbGroup('over','hint','images/buttons/hintOver.jpg','',1)"
  153. onmouseout="MM_nbGroup('out')">
  154. <img src="images/buttons/hint.jpg" alt="Hints" name="hint" width="35" height="20" border="0" id="hint"/>
  155. </a>
  156. <a href="<%= webSession.getCurrentLesson().getLink() %>&show=NextHint" target="_top" onclick="MM_nbGroup('down','group1','hintRight','',1)"
  157. onmouseover="MM_nbGroup('over','hintRight','images/buttons/hintRightOver.jpg','',1)"
  158. onmouseout="MM_nbGroup('out')">
  159. <img src="images/buttons/hintRight.jpg" alt="Next Hint" name="hintRight" width="20" height="20" border="0" id="hintRight"/>
  160. </a>
  161. <%}%>
  162. <a href="<%= webSession.getCurrentLesson().getLink() %>&show=Params" target="_top" onclick="MM_nbGroup('down','group1','params','',1)"
  163. onmouseover="MM_nbGroup('over','params','images/buttons/paramsOver.jpg','',1)"
  164. onmouseout="MM_nbGroup('out')">
  165. <img src="images/buttons/params.jpg" alt="Show Params" name="<%= webSession.getCurrentLesson().getLink() %>&show=Params" width="87" height="20" border="0" id="params"/>
  166. </a>
  167. <a href="<%= webSession.getCurrentLesson().getLink() %>&show=Cookies" target="_top" onclick="MM_nbGroup('down','group1','cookies','',1)"
  168. onmouseover="MM_nbGroup('over','cookies','images/buttons/cookiesOver.jpg','',1)"
  169. onmouseout="MM_nbGroup('out')">
  170. <img src="images/buttons/cookies.jpg" alt="Show Cookies" name="cookies" width="99" height="20" border="0" id="cookies"/>
  171. </a>
  172. <a href="javascript:toggle('lessonPlans')" target="_top" onclick="MM_nbGroup('down','group1','plans','',1)"
  173. onmouseover="MM_nbGroup('over','plans','images/buttons/plansOver.jpg','',1)"
  174. onmouseout="MM_nbGroup('out')">
  175. <img src="images/buttons/plans.jpg" alt="Lesson Plans" width="89" height="20" border="0" id="plans"/>
  176. </a>
  177. <%
  178. if (webSession.isAuthorizedInLesson(webSession.getRole(), WebSession.SHOWSOURCE))
  179. {
  180. %>
  181. <a href="source" onclick="makeWindow(this.href+ '?source=true', 'Java Source');return false;" target="javaWin"
  182. onmouseover="MM_nbGroup('over','java','images/buttons/javaOver.jpg','',1)"
  183. onmouseout="MM_nbGroup('out')">
  184. <img src="images/buttons/java.jpg" alt="Show Java" name="java" width="75" height="20" border="0" id="java"/>
  185. </a>
  186. <a href="source" onclick="makeWindow(this.href + '?solution=true', 'Java Solution');return false;" target="javaWin"
  187. onmouseover="MM_nbGroup('over','solutions','images/buttons/solutionsOver.jpg','',1)"
  188. onmouseout="MM_nbGroup('out')">
  189. <img src="images/buttons/solutions.jpg" alt="Show Solution" name="solutions" width="73" height="20" border="0" id="solutions"/>
  190. </a>
  191. <%}%>
  192. </div>
  193. <div id="twoCol">
  194. <div id="menuSpacer"></div>
  195. <div id="lessonAreaTop">
  196. <%
  197. if (currentLesson != null)
  198. {
  199. %>
  200. <div id="training_wrap">
  201. <div id="training" class="info"><a href="http://yehg.net/lab/pr0js/training/webgoat.php" target="_blank"><%=WebGoatI18N.get("SolutionVideos")%></a></div>
  202. <div id="reset" class="info"><a href="<%=webSession.getRestartLink()%>"><%=WebGoatI18N.get("RestartLesson")%></a></div>
  203. </div>
  204. <%
  205. }
  206. %>
  207. </div>
  208. <div id="lessonArea">
  209. <%
  210. if (webSession.getHint() != null)
  211. {
  212. printHint = "<div id=\"hint\" class=\"info\">" + webSession.getHint() + "</div><br>";
  213. out.println(printHint);
  214. }
  215. if (webSession.getParams() != null)
  216. {
  217. Iterator i = webSession.getParams().iterator();
  218. while (i.hasNext())
  219. {
  220. Parameter p = (Parameter) i.next();
  221. printParameters = "<div id=\"parameter\" class=\"info\">" + p.getName() + "=" + p.getValue() + "</div><br>";
  222. out.println(printParameters);
  223. }
  224. }
  225. if (webSession.getCookies() != null)
  226. {
  227. Iterator i = webSession.getCookies().iterator();
  228. while (i.hasNext())
  229. {
  230. Cookie c = (Cookie) i.next();
  231. printCookies = "<div id=\"cookie\" class=\"info\">" + c.getName() + " <img src=\"images/icons/rightArrow.jpg\" alt=\"\"> " + c.getValue() + "</div><br>";
  232. out.println(printCookies);
  233. }
  234. }%>
  235. <div id="lessonPlans" style="visibility:hidden; height:1px; position:absolute; left:260px; top:130px; width:425px; z-index:105;"><%=currentLesson.getLessonPlan(webSession) %>
  236. <br/>
  237. <br/>
  238. <a href="javascript:toggle('lessonPlans')" target="_top" onclick="MM_nbGroup('down','group1','plans','',1)">Close this Window</a>
  239. </div>
  240. <div id="lessonContent">
  241. <%
  242. AbstractLesson lesson = webSession.getCurrentLesson();
  243. if (lesson instanceof RandomLessonAdapter) {
  244. RandomLessonAdapter rla = (RandomLessonAdapter) lesson;
  245. %>
  246. <div class="info">Stage <%= rla.getLessonTracker(webSession).getStageNumber(rla.getStage(webSession)) + 1 %></div>
  247. <%
  248. }
  249. %>
  250. <%=webSession.getInstructions()%></div>
  251. <div id="message" class="info"><%=webSession.getMessage()%></div>
  252. <%
  253. if (currentLesson.getTemplatePage(webSession) != null)
  254. {
  255. //System.out.println("Main.jsp - current lesson: " + currentLesson.getName() );
  256. //System.out.println(" - template Page: " + currentLesson.getTemplatePage(webSession));
  257. %>
  258. <jsp:include page="<%=currentLesson.getTemplatePage(webSession)%>" />
  259. <%
  260. }
  261. else
  262. {
  263. %>
  264. <div id="lessonContent"><%=currentLesson.getContent()%></div>
  265. <%
  266. }
  267. %>
  268. <div id="credits">
  269. <% out.println(currentLesson.getCredits());%>
  270. </div>
  271. </div>
  272. </div>
  273. <div id="bottom">
  274. <div align="center"><a href="http://www.owasp.org">OWASP Foundation</a> |
  275. <a href="http://www.owasp.org/index.php/OWASP_WebGoat_Project">Project WebGoat</a> |
  276. <a href="reportBug.jsp">Report Bug</a>
  277. </div>
  278. </div>
  279. </div>
  280. </body>
  281. </html>