Skip to content

Commit da7b5ee

Browse files
author
Matt Yaraskavitch
committed
Added Docker support to ease deployment
Instead of needing to spin up a VM, the vulnerable application can simply be run via Docker using docker-compose. Default MySQL path has been adjusted to point to the MySQL image.
1 parent a780b17 commit da7b5ee

File tree

5 files changed

+121
-12
lines changed

5 files changed

+121
-12
lines changed

.gitignore

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Created by https://www.gitignore.io/api/code-java,java,maven
2+
# Created by https://www.gitignore.io/api/vim,java,maven,eclipse,code-java
33

44
### Code-Java ###
55
# Language Support for Java(TM) by Red Hat extension for Visual Studio Code - https://marketplace.visualstudio.com/items?itemName=redhat.java
@@ -8,9 +8,70 @@
88
.classpath
99
factoryConfiguration.json
1010

11+
### Eclipse ###
12+
13+
.metadata
14+
bin/
15+
tmp/
16+
*.tmp
17+
*.bak
18+
*.swp
19+
*~.nib
20+
local.properties
21+
.settings/
22+
.loadpath
23+
.recommenders
24+
25+
# External tool builders
26+
.externalToolBuilders/
27+
28+
# Locally stored "Eclipse launch configurations"
29+
*.launch
30+
31+
# PyDev specific (Python IDE for Eclipse)
32+
*.pydevproject
33+
34+
# CDT-specific (C/C++ Development Tooling)
35+
.cproject
36+
37+
# Java annotation processor (APT)
38+
.factorypath
39+
40+
# PDT-specific (PHP Development Tools)
41+
.buildpath
42+
43+
# sbteclipse plugin
44+
.target
45+
46+
# Tern plugin
47+
.tern-project
48+
49+
# TeXlipse plugin
50+
.texlipse
51+
52+
# STS (Spring Tool Suite)
53+
.springBeans
54+
55+
# Code Recommenders
56+
.recommenders/
57+
58+
# Scala IDE specific (Scala & Java development for Eclipse)
59+
.cache-main
60+
.scala_dependencies
61+
.worksheet
62+
63+
### Eclipse Patch ###
64+
# Eclipse Core
65+
66+
# JDT-specific (Eclipse Java Development Tools)
67+
1168
### Java ###
69+
# Compiled class file
1270
*.class
1371

72+
# Log file
73+
*.log
74+
1475
# BlueJ files
1576
*.ctxt
1677

@@ -21,6 +82,9 @@ factoryConfiguration.json
2182
*.jar
2283
*.war
2384
*.ear
85+
*.zip
86+
*.tar.gz
87+
*.rar
2488

2589
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2690
hs_err_pid*
@@ -36,8 +100,21 @@ dependency-reduced-pom.xml
36100
buildNumber.properties
37101
.mvn/timing.properties
38102

39-
# Exclude maven wrapper
103+
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
40104
!/.mvn/wrapper/maven-wrapper.jar
41105

42-
# End of https://www.gitignore.io/api/code-java,java,maven
43-
0
106+
### Vim ###
107+
# swap
108+
[._]*.s[a-v][a-z]
109+
[._]*.sw[a-p]
110+
[._]s[a-v][a-z]
111+
[._]sw[a-p]
112+
# session
113+
Session.vim
114+
# temporary
115+
.netrwhist
116+
*~
117+
# auto-generated tag files
118+
tags
119+
120+
# End of https://www.gitignore.io/api/vim,java,maven,eclipse,code-java

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM tomcat:8.5.20-jre8
2+
3+
RUN pwd
4+
RUN ls
5+
6+
COPY . /code
7+
WORKDIR /code
8+
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
maven \
11+
openjdk-8-jdk
12+
13+
RUN mvn clean
14+
RUN mvn package
15+
16+
RUN cp target/JavaVulnerableLab.war /usr/local/tomcat/webapps/
17+
18+
CMD ["catalina.sh", "run"]

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
image: mysql:5.7
6+
environment:
7+
MYSQL_ROOT_PASSWORD: root
8+
tomcat:
9+
build: .
10+
ports:
11+
- 8080:8080
12+
- 3306:3306
13+
depends_on:
14+
- db

src/main/webapp/WEB-INF/config.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
dbuser=root
66
dbpass=root
77
dbname=abc
8-
dburl=jdbc:mysql://localhost:3306/
8+
dburl=jdbc:mysql://db:3306/
99
jdbcdriver=com.mysql.jdbc.Driver
1010
siteTitle=Java Vulnerable Lab

src/main/webapp/install.jsp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
<%@ include file="/header.jsp" %>
44

5-
5+
66
<form action="Install" method="POST">
7-
<table>
7+
<table>
88
<tr><td>Website Title:</td> <td><input type="text" name="siteTitle" value="Java Vulnerable Lab"/></td></tr>
99
<tr><td>Database Name:</td> <td><input type="text" name="dbname" value="abc"/></td></tr>
1010
<tr><td>Database User:</td> <td><input type="text" name="dbuser" value="root"/></td></tr>
1111
<tr><td>Database Password:</td> <td><input type="text" name="dbpass" value="root"/></td></tr>
1212
<tr><td>JDBC Driver:</td> <td><input type="text" name="jdbcdriver" value="com.mysql.jdbc.Driver"/></td></tr>
13-
<tr><td>JDBC URL:</td> <td><input type="text" name="dburl" value="jdbc:mysql://localhost:3306/"/></td></tr>
13+
<tr><td>JDBC URL:</td> <td><input type="text" name="dburl" value="jdbc:mysql://db:3306/"/></td></tr>
1414
<tr><td>Admin Login Credential:</td></tr>
1515
<tr><td>Username(Default):</td> <td><input type="text" name="adminuser" value="admin"/></td></tr>
1616
<tr><td>Password(Default):</td> <td><input type="text" name="adminpass" value="admin"/></td></tr>
17-
17+
1818
<tr><td></td></tr>
1919
<input type="hidden" value="1" name="setup"/>
2020
<tr><td></td> <td><input type="submit" value="Install" name="Install"/></td></tr>
21-
</table>
21+
</table>
2222
</form>
23-
<br/>
23+
<br/>
2424
Note:<b style="color:red">If a database already exits, it will be dropped </b>
25-
25+
2626

2727

2828
<%@ include file="/footer.jsp" %>

0 commit comments

Comments
 (0)