Skip to content

Commit 1464305

Browse files
committed
Maven Project
1 parent 9d9a216 commit 1464305

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3693
-0
lines changed

pom.xml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.cysecurity</groupId>
5+
<artifactId>JavaVulnerableLab</artifactId>
6+
<packaging>war</packaging>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<name>JavaVulnerableLab Maven Webapp</name>
9+
<url>http://maven.apache.org</url>
10+
<dependencies>
11+
<dependency>
12+
<groupId>junit</groupId>
13+
<artifactId>junit</artifactId>
14+
<version>3.8.1</version>
15+
<scope>test</scope>
16+
</dependency>
17+
<dependency>
18+
<groupId>mysql</groupId>
19+
<artifactId>mysql-connector-java</artifactId>
20+
<version>5.1.26</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.json</groupId>
24+
<artifactId>json</artifactId>
25+
<version>20090211</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>javax.servlet</groupId>
29+
<artifactId>jstl</artifactId>
30+
<version>1.2</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.hibernate</groupId>
34+
<artifactId>hibernate-core</artifactId>
35+
<version>4.0.1.Final</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>javax.servlet</groupId>
39+
<artifactId>servlet-api</artifactId>
40+
<version>2.3</version>
41+
<scope>provided</scope>
42+
</dependency>
43+
</dependencies>
44+
<build>
45+
<finalName>JavaVulnerableLab</finalName>
46+
</build>
47+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
7+
package org.cysecurity.cspf.jvl.controller;
8+
9+
import java.io.BufferedWriter;
10+
import java.io.File;
11+
import java.io.FileWriter;
12+
import java.io.IOException;
13+
import java.io.PrintWriter;
14+
import javax.servlet.ServletException;
15+
import javax.servlet.http.HttpServlet;
16+
import javax.servlet.http.HttpServletRequest;
17+
import javax.servlet.http.HttpServletResponse;
18+
19+
/**
20+
*
21+
* @author breakthesec
22+
*/
23+
public class AddPage extends HttpServlet {
24+
25+
/**
26+
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
27+
* methods.
28+
*
29+
* @param request servlet request
30+
* @param response servlet response
31+
* @throws ServletException if a servlet-specific error occurs
32+
* @throws IOException if an I/O error occurs
33+
*/
34+
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
35+
throws ServletException, IOException {
36+
response.setContentType("text/html;charset=UTF-8");
37+
PrintWriter out = response.getWriter();
38+
try {
39+
String fileName=request.getParameter("filename");
40+
String content=request.getParameter("content");
41+
if(fileName!=null && content!=null)
42+
{
43+
String pagesDir=getServletContext().getRealPath("/pages");
44+
String filePath=pagesDir+"/"+fileName;
45+
File f=new File(filePath);
46+
if(f.exists())
47+
{
48+
f.delete();
49+
}
50+
if(f.createNewFile())
51+
{
52+
BufferedWriter bw=new BufferedWriter(new FileWriter(f.getAbsoluteFile()));
53+
bw.write(content);
54+
bw.close();
55+
out.print("Successfully created the file: <a href='../pages/"+fileName+"'>"+fileName+"</a>");
56+
}
57+
else
58+
{
59+
out.print("Failed to create the file");
60+
}
61+
}
62+
else
63+
{
64+
out.print("filename or content Parameter is missing");
65+
}
66+
67+
}
68+
catch(Exception e)
69+
{
70+
out.print(e);
71+
}
72+
finally {
73+
out.close();
74+
}
75+
}
76+
77+
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
78+
/**
79+
* Handles the HTTP <code>GET</code> method.
80+
*
81+
* @param request servlet request
82+
* @param response servlet response
83+
* @throws ServletException if a servlet-specific error occurs
84+
* @throws IOException if an I/O error occurs
85+
*/
86+
@Override
87+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
88+
throws ServletException, IOException {
89+
processRequest(request, response);
90+
}
91+
92+
/**
93+
* Handles the HTTP <code>POST</code> method.
94+
*
95+
* @param request servlet request
96+
* @param response servlet response
97+
* @throws ServletException if a servlet-specific error occurs
98+
* @throws IOException if an I/O error occurs
99+
*/
100+
@Override
101+
protected void doPost(HttpServletRequest request, HttpServletResponse response)
102+
throws ServletException, IOException {
103+
processRequest(request, response);
104+
}
105+
106+
/**
107+
* Returns a short description of the servlet.
108+
*
109+
* @return a String containing servlet description
110+
*/
111+
@Override
112+
public String getServletInfo() {
113+
return "Short description";
114+
}// </editor-fold>
115+
116+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
7+
package org.cysecurity.cspf.jvl.controller;
8+
9+
import java.io.IOException;
10+
import java.io.PrintWriter;
11+
import java.sql.Connection;
12+
import java.sql.ResultSet;
13+
import java.sql.Statement;
14+
import javax.servlet.ServletException;
15+
import javax.servlet.http.HttpServlet;
16+
import javax.servlet.http.HttpServletRequest;
17+
import javax.servlet.http.HttpServletResponse;
18+
import org.cysecurity.cspf.jvl.model.DBConnect;
19+
import org.json.JSONObject;
20+
21+
/**
22+
*
23+
* @author breakthesec
24+
*/
25+
public class EmailCheck extends HttpServlet {
26+
27+
/**
28+
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
29+
* methods.
30+
*
31+
* @param request servlet request
32+
* @param response servlet response
33+
* @throws ServletException if a servlet-specific error occurs
34+
* @throws IOException if an I/O error occurs
35+
*/
36+
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
37+
throws ServletException, IOException {
38+
response.setContentType("application/json");
39+
PrintWriter out = response.getWriter();
40+
try {
41+
Connection con=new DBConnect().connect(getServletContext().getRealPath("/WEB-INF/config.properties"));
42+
String email=request.getParameter("email").trim();
43+
JSONObject json=new JSONObject();
44+
if(con!=null && !con.isClosed())
45+
{
46+
ResultSet rs=null;
47+
Statement stmt = con.createStatement();
48+
rs=stmt.executeQuery("select * from users where email='"+email+"'");
49+
if (rs.next())
50+
{
51+
json.put("available", "1");
52+
}
53+
else
54+
{
55+
json.put("available", new Integer(0));
56+
}
57+
}
58+
out.print(json);
59+
}
60+
catch(Exception e)
61+
{
62+
out.print(e);
63+
}
64+
finally {
65+
out.close();
66+
}
67+
}
68+
69+
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
70+
/**
71+
* Handles the HTTP <code>GET</code> method.
72+
*
73+
* @param request servlet request
74+
* @param response servlet response
75+
* @throws ServletException if a servlet-specific error occurs
76+
* @throws IOException if an I/O error occurs
77+
*/
78+
@Override
79+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
80+
throws ServletException, IOException {
81+
processRequest(request, response);
82+
}
83+
84+
/**
85+
* Handles the HTTP <code>POST</code> method.
86+
*
87+
* @param request servlet request
88+
* @param response servlet response
89+
* @throws ServletException if a servlet-specific error occurs
90+
* @throws IOException if an I/O error occurs
91+
*/
92+
93+
protected void doPost(HttpServletRequest request, HttpServletResponse response)
94+
throws ServletException, IOException {
95+
processRequest(request, response);
96+
}
97+
98+
/**
99+
* Returns a short description of the servlet.
100+
*
101+
* @return a String containing servlet description
102+
*/
103+
@Override
104+
public String getServletInfo() {
105+
return "Short description";
106+
}// </editor-fold>
107+
108+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
7+
package org.cysecurity.cspf.jvl.controller;
8+
9+
import java.io.IOException;
10+
import java.io.PrintWriter;
11+
import javax.servlet.RequestDispatcher;
12+
import javax.servlet.ServletException;
13+
import javax.servlet.http.HttpServlet;
14+
import javax.servlet.http.HttpServletRequest;
15+
import javax.servlet.http.HttpServletResponse;
16+
17+
/**
18+
*
19+
* @author breakthesec
20+
*/
21+
public class ForwardMe extends HttpServlet {
22+
23+
/**
24+
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
25+
* methods.
26+
*
27+
* @param request servlet request
28+
* @param response servlet response
29+
* @throws ServletException if a servlet-specific error occurs
30+
* @throws IOException if an I/O error occurs
31+
*/
32+
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
33+
throws ServletException, IOException {
34+
response.setContentType("text/html;charset=UTF-8");
35+
PrintWriter out = response.getWriter();
36+
try {
37+
if(request.getParameter("location")!=null)
38+
{
39+
String location=request.getParameter("location");
40+
//Forwarding
41+
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(location);
42+
dispatcher.forward(request,response);
43+
}
44+
else
45+
{
46+
out.print("Location Parameter is missing");
47+
}
48+
} finally {
49+
out.close();
50+
}
51+
}
52+
53+
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
54+
/**
55+
* Handles the HTTP <code>GET</code> method.
56+
*
57+
* @param request servlet request
58+
* @param response servlet response
59+
* @throws ServletException if a servlet-specific error occurs
60+
* @throws IOException if an I/O error occurs
61+
*/
62+
@Override
63+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
64+
throws ServletException, IOException {
65+
processRequest(request, response);
66+
}
67+
68+
/**
69+
* Handles the HTTP <code>POST</code> method.
70+
*
71+
* @param request servlet request
72+
* @param response servlet response
73+
* @throws ServletException if a servlet-specific error occurs
74+
* @throws IOException if an I/O error occurs
75+
*/
76+
@Override
77+
protected void doPost(HttpServletRequest request, HttpServletResponse response)
78+
throws ServletException, IOException {
79+
processRequest(request, response);
80+
}
81+
82+
/**
83+
* Returns a short description of the servlet.
84+
*
85+
* @return a String containing servlet description
86+
*/
87+
@Override
88+
public String getServletInfo() {
89+
return "Short description";
90+
}// </editor-fold>
91+
92+
}

0 commit comments

Comments
 (0)