Skip to content

Commit

Permalink
Merge pull request #375 from snyk-labs/optimise_mvn_exec
Browse files Browse the repository at this point in the history
specified exec plugin in pom file with startup class
  • Loading branch information
dogeared authored Jan 4, 2022
2 parents cbdcf59 + 02864c9 commit 4e4ca88
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
6 changes: 3 additions & 3 deletions log4shell-goof/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Java class that will be deserialized and executed.

The HTTP server listens on port `8000` and responds to any request with a byte array that is the `Evil.class`.

`Evil` implements `ObjecFactory` which the JNDI mechanism hooks into to execute its `getObjectInstance` method. While
`Evil` implements `ObjectFactory` which the JNDI mechanism hooks into to execute its `getObjectInstance` method. While
the method simply returns `null`, it uses `Runtime` to execute arbitrary code on the host machine. In this case, it
writes to a file called: `/tmp/pwned` to prove that it _could_ execute basically anything available on the machine.

Expand All @@ -51,7 +51,7 @@ Open a terminal window and run the following:

```
cd log4shell-server
mvn exec:java -Dexec.mainClass="Server"
mvn exec:java
```

You should see output that looks like the following:
Expand All @@ -67,7 +67,7 @@ In another terminal window, run the following:
```
cd log4shell-client
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home \
mvn exec:java -Dexec.mainClass="Main"
mvn exec:java
```

**NOTE:** Referencing `JAVA_HOME` is important as the exploit only fully works with older JDK versions.
Expand Down
14 changes: 14 additions & 0 deletions log4shell-goof/log4shell-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,18 @@
<version>2.14.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<mainClass>Main</mainClass>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
</plugin>
</plugins>
</build>
</project>
9 changes: 9 additions & 0 deletions log4shell-goof/log4shell-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<mainClass>Server</mainClass>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 4e4ca88

Please sign in to comment.