Skip to content

Commit 4a230a9

Browse files
committed
add portable fat jar support
1 parent 993385b commit 4a230a9

File tree

4 files changed

+56
-12
lines changed

4 files changed

+56
-12
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Gradle wrapper should solve everything. Simply git clone the repo:
1414
git clone https://github.com/tothi/log4shell-vulnerable-app
1515
```
1616

17+
### running with gradle wrapper
18+
1719
And in the project dir with the file [build.gradle](./build.gradle),
1820
simply run:
1921

@@ -27,7 +29,37 @@ or on Windows platform:
2729
.\gradlew.bat appRun
2830
```
2931

30-
(JDK is needed.)
32+
JDK is needed. Versions 8 and 11 were tested and are working, 17 seems to
33+
have issues.
34+
35+
### building a portable fat jar
36+
37+
This method builds a one-file portable fat JAR including an embedded
38+
Tomcat server.
39+
40+
Simply run the gradle wrapper with the configured `shadowJar' task:
41+
42+
```
43+
./gradlew shadowJar
44+
```
45+
46+
or on Windows platform:
47+
48+
```
49+
.\gradlew.bat shadowJar
50+
```
51+
52+
The compiled and packages JAR file will be built in the folder `./build/libs`.
53+
54+
It is portable and can be launched using JRE:
55+
56+
```
57+
java -jar ./build/libs/log4shell-vulnerable-app-all.jar
58+
```
59+
60+
The all-in-one portable JAR is available on the [releases page](https://github.com/tothi/log4shell-vulnerable-app/releases) here in the repo.
61+
62+
### interacting with the vulnerable application
3163

3264
The vulnerable application should listen on _all_ interfaces by
3365
default (DANGEROUS behavior if you run it on a production box).

build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id "war"
33
id "org.gretty" version "3.0.5"
4+
id "com.github.johnrengelman.shadow" version "7.1.2"
5+
id "java"
46
}
57

68
sourceCompatibility = "1.8"
@@ -12,9 +14,29 @@ repositories {
1214

1315
dependencies {
1416
implementation 'org.apache.logging.log4j:log4j-core:2.14.1'
17+
if (project.gradle.startParameter.taskNames.first().contains("shadow")) {
18+
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper:8.5.75'
19+
}
1520
}
1621

1722
gretty {
1823
contextPath = 'app'
1924
servletContainer = 'tomcat85'
2025
}
26+
27+
sourceSets {
28+
main {
29+
java {
30+
srcDir 'src'
31+
if (!project.gradle.startParameter.taskNames.first().contains("shadow")) {
32+
exclude '**/launch/**'
33+
}
34+
}
35+
}
36+
}
37+
38+
jar {
39+
manifest {
40+
attributes('Main-Class': 'launch.Main')
41+
}
42+
}

src/main/java/dvl4wa/VulnServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class VulnServlet extends HttpServlet {
1414
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException {
15-
Logger logger = LogManager.getLogger();
15+
Logger logger = LogManager.getLogger(VulnServlet.class);
1616
try {
1717
Map<String, String> headers = Collections.list(req.getHeaderNames()).stream().collect(Collectors.toMap(h -> h, req::getHeader));
1818
res.setContentType("text/plain; charset=utf-8");

tomcat.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)