mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-01-02 11:36:22 +01:00
Convert JavaPayload project to use Maven
Functionality and build result is 1:1 the same as before. Auxiliary ant targets have been converted to Maven profiles.
This commit is contained in:
parent
b1da5a6a13
commit
b58215ff3b
37
java/COMPILING.txt
Normal file
37
java/COMPILING.txt
Normal file
@ -0,0 +1,37 @@
|
||||
To compile JavaPayload for Metasploit (including Java Meterpreter), you need
|
||||
Maven 3.0 or above. Just run
|
||||
|
||||
mvn package
|
||||
|
||||
to package all the files, or
|
||||
|
||||
mvn -P deploy package
|
||||
|
||||
to package all the files and copy them into the correct place for Metasploit
|
||||
(/data/java).
|
||||
|
||||
In case you want to edit/debug JavaPayload for Metasploit or Java Meterpreter,
|
||||
Maven provides plugins to auto-generate project files for your favourite IDE
|
||||
(at least for Eclipse, Netbeans or IntelliJ). I use Eclipse, so to generate
|
||||
project files I use
|
||||
|
||||
mvn eclipse:eclipse
|
||||
|
||||
This will generate project files that can be imported via
|
||||
|
||||
File->Import->Existing Projects into Workspace
|
||||
|
||||
into your Eclipse workspace.
|
||||
|
||||
(Note that if this is your first Maven project you want to use in Eclipse, you
|
||||
also have to run
|
||||
|
||||
mvn -Declipse.workspace=/path/to/your/workspace eclipse:configure-workspace
|
||||
|
||||
to set up path variables like M2_REPO to point to the correct location.)
|
||||
|
||||
For NetBeans or IntelliJ IDEA, refer to the documentation at
|
||||
|
||||
http://maven.apache.org/netbeans-module.html
|
||||
http://maven.apache.org/plugins/maven-idea-plugin/
|
||||
|
7
java/_root/.gitignore
vendored
7
java/_root/.gitignore
vendored
@ -14,8 +14,11 @@ doc
|
||||
external/source/meterpreter/java/bin
|
||||
external/source/meterpreter/java/build
|
||||
external/source/meterpreter/java/extensions
|
||||
external/source/javapayload/bin
|
||||
external/source/javapayload/build
|
||||
external/source/javapayload/*/.classpath
|
||||
external/source/javapayload/*/.project
|
||||
external/source/javapayload/*/.settings
|
||||
external/source/javapayload/*/bin
|
||||
external/source/javapayload/*/target
|
||||
# Packaging directory
|
||||
pkg
|
||||
tags
|
||||
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
|
||||
<classpathentry kind="lib" path="lib/servlet-api-2.2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JavaPayload4Meterpreter</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -1,12 +0,0 @@
|
||||
#Tue Aug 17 23:14:37 CEST 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.3
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
|
||||
org.eclipse.jdt.core.compiler.source=1.3
|
@ -1,68 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="JavaPayload4Meterpreter" default="deploy">
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="build" />
|
||||
</target>
|
||||
|
||||
<target name="compile">
|
||||
<mkdir dir="build" />
|
||||
<javac srcdir="src" destdir="build" source="1.1" target="1.1" classpath="lib/servlet-api-2.2.jar" debug="no" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile">
|
||||
<!-- example: spawning bind -->
|
||||
<propertyfile file="build/metasploit.dat">
|
||||
<entry key="Spawn" value="2"/>
|
||||
<entry key="LPORT" value="5555" />
|
||||
</propertyfile>
|
||||
<jar destfile="example-spawn-bind.jar">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="metasploit.Payload"/>
|
||||
</manifest>
|
||||
<fileset dir="build">
|
||||
<include name="metasploit/Payload.class"/>
|
||||
<include name="metasploit.dat"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<delete file="build/metasploit.dat"/>
|
||||
</target>
|
||||
|
||||
<target name="buildrmi" depends="compile">
|
||||
<!-- build dummy jar used for capturing communication and for testing -->
|
||||
<propertyfile file="build/metasploit.dat">
|
||||
<entry key="LPORT" value="4444" />
|
||||
<entry key="LHOST" value="127.0.0.1" />
|
||||
</propertyfile>
|
||||
<jar destfile="rmidummy.jar">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="metasploit.Payload"/>
|
||||
</manifest>
|
||||
<fileset dir="build">
|
||||
<include name="metasploit/RMILoader.class"/>
|
||||
<include name="metasploit/RMIPayload.class"/>
|
||||
<include name="metasploit/Payload.class"/>
|
||||
<include name="metasploit.dat"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
|
||||
<!-- rename local metasploit/RMILoader.class to ensure a classloader URL will be serialized -->
|
||||
<move file="build/metasploit/RMILoader.class" tofile="build/metasploit/RMILoader.class.tmp" />
|
||||
|
||||
<!-- run the capture server -->
|
||||
<java classpath="build" classname="rmi.RMICaptureServer" />
|
||||
|
||||
<!-- rename back -->
|
||||
<move file="build/metasploit/RMILoader.class.tmp" tofile="build/metasploit/RMILoader.class" />
|
||||
</target>
|
||||
|
||||
<target name="deploy" depends="compile">
|
||||
<copy todir="../../../data/java">
|
||||
<fileset dir="build">
|
||||
<exclude name="metasploit/PayloadApplet.class" />
|
||||
<exclude name="rmi/**" />
|
||||
<exclude name="metasploit.dat" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
</project>
|
Binary file not shown.
147
java/javapayload/pom.xml
Normal file
147
java/javapayload/pom.xml
Normal file
@ -0,0 +1,147 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.metasploit</groupId>
|
||||
<artifactId>Metasploit-JavaPayload</artifactId>
|
||||
<parent>
|
||||
<groupId>com.metasploit</groupId>
|
||||
<artifactId>Metasploit-JavaPayload-parent</artifactId>
|
||||
<version>1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
<name>JavaPayload for Metasploit</name>
|
||||
<url>http://www.metasploit.com/</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<!-- deploy built files to Metasploit data directory -->
|
||||
<id>deploy</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<copy todir="${project.basedir}/../../../../data/java">
|
||||
<fileset dir="${project.basedir}/target/classes">
|
||||
<exclude name="metasploit/PayloadApplet.class" />
|
||||
<exclude name="rmi/**" />
|
||||
<exclude name="metasploit.dat" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<!-- build example JARs -->
|
||||
<id>examples</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<!-- example: spawning bind -->
|
||||
<propertyfile file="${project.basedir}/target/classes/metasploit.dat">
|
||||
<entry key="Spawn" value="2" />
|
||||
<entry key="LPORT" value="5555" />
|
||||
</propertyfile>
|
||||
<jar destfile="${project.basedir}/example-spawn-bind.jar">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="metasploit.Payload" />
|
||||
</manifest>
|
||||
<fileset dir="${project.basedir}/target/classes">
|
||||
<include name="metasploit/Payload.class" />
|
||||
<include name="metasploit.dat" />
|
||||
</fileset>
|
||||
</jar>
|
||||
<delete file="${project.basedir}/target/classes/metasploit.dat" />
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<!-- build dummy jar used for capturing communication and for testing RMI injection -->
|
||||
<id>buildrmi</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<propertyfile file="${project.basedir}/target/classes/metasploit.dat">
|
||||
<entry key="LPORT" value="4444" />
|
||||
<entry key="LHOST" value="127.0.0.1" />
|
||||
</propertyfile>
|
||||
<mkdir dir="${project.basedir}/target/rmi/build" />
|
||||
<jar destfile="${project.basedir}/target/rmi/rmidummy.jar">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="metasploit.Payload" />
|
||||
</manifest>
|
||||
<fileset dir="${project.basedir}/target/classes">
|
||||
<include name="metasploit/RMILoader.class" />
|
||||
<include name="metasploit/RMIPayload.class" />
|
||||
<include name="metasploit/Payload.class" />
|
||||
<include name="metasploit.dat" />
|
||||
</fileset>
|
||||
</jar>
|
||||
<delete file="${project.basedir}/target/classes/metasploit.dat" />
|
||||
|
||||
<!-- rename local metasploit/RMILoader.class to ensure a classloader
|
||||
URL will be serialized -->
|
||||
<move file="${project.basedir}/target/classes/metasploit/RMILoader.class" tofile="${project.basedir}/target/classes/metasploit/RMILoader.class.tmp" />
|
||||
|
||||
<!-- run the capture server -->
|
||||
<java classpath="${project.basedir}/target/classes" classname="rmi.RMICaptureServer" dir="${project.basedir}/target/rmi" fork="true" />
|
||||
|
||||
<!-- rename back -->
|
||||
<move file="${project.basedir}/target/classes/metasploit/RMILoader.class.tmp" tofile="${project.basedir}/target/classes/metasploit/RMILoader.class" />
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
52
java/pom.xml
Normal file
52
java/pom.xml
Normal file
@ -0,0 +1,52 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.metasploit</groupId>
|
||||
<artifactId>Metasploit-JavaPayload-parent</artifactId>
|
||||
<version>1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>JavaPayload for Metasploit (Parent project)</name>
|
||||
<url>http://www.metasploit.com/</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.3</source>
|
||||
<target>1.1</target>
|
||||
<debug>true</debug> <!-- http://stackoverflow.com/q/4220083/90203 -->
|
||||
<debuglevel>none</debuglevel>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<configuration>
|
||||
<buildOutputDirectory>bin</buildOutputDirectory>
|
||||
<downloadSources>true</downloadSources>
|
||||
<testSourcesLast>true</testSourcesLast>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<modules>
|
||||
<module>javapayload</module>
|
||||
<!-- <module>meterpreter</module> -->
|
||||
</modules>
|
||||
<prerequisites>
|
||||
<maven>3.0</maven>
|
||||
</prerequisites>
|
||||
</project>
|
Loading…
Reference in New Issue
Block a user