Browse Source

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.
Michael Schierl 7 years ago
parent
commit
2d03b747c0
25 changed files with 241 additions and 106 deletions
  1. 5
    2
      .gitignore
  2. 37
    0
      external/source/javapayload/COMPILING.txt
  3. 0
    7
      external/source/javapayload/javapayload/.classpath
  4. 0
    17
      external/source/javapayload/javapayload/.project
  5. 0
    12
      external/source/javapayload/javapayload/.settings/org.eclipse.jdt.core.prefs
  6. 0
    68
      external/source/javapayload/javapayload/build.xml
  7. BIN
      external/source/javapayload/javapayload/lib/servlet-api-2.2.jar
  8. 147
    0
      external/source/javapayload/javapayload/pom.xml
  9. 0
    0
      external/source/javapayload/javapayload/src/main/java/com/metasploit/meterpreter/MemoryBufferURLConnection.java
  10. 0
    0
      external/source/javapayload/javapayload/src/main/java/com/metasploit/meterpreter/MemoryBufferURLStreamHandler.java
  11. 0
    0
      external/source/javapayload/javapayload/src/main/java/javapayload/stage/Meterpreter.java
  12. 0
    0
      external/source/javapayload/javapayload/src/main/java/javapayload/stage/Shell.java
  13. 0
    0
      external/source/javapayload/javapayload/src/main/java/javapayload/stage/Stage.java
  14. 0
    0
      external/source/javapayload/javapayload/src/main/java/javapayload/stage/StreamForwarder.java
  15. 0
    0
      external/source/javapayload/javapayload/src/main/java/metasploit/AESEncryption.java
  16. 0
    0
      external/source/javapayload/javapayload/src/main/java/metasploit/Payload.java
  17. 0
    0
      external/source/javapayload/javapayload/src/main/java/metasploit/PayloadApplet.java
  18. 0
    0
      external/source/javapayload/javapayload/src/main/java/metasploit/PayloadServlet.java
  19. 0
    0
      external/source/javapayload/javapayload/src/main/java/metasploit/PayloadTrustManager.java
  20. 0
    0
      external/source/javapayload/javapayload/src/main/java/metasploit/RMILoader.java
  21. 0
    0
      external/source/javapayload/javapayload/src/main/java/metasploit/RMIPayload.java
  22. 0
    0
      external/source/javapayload/javapayload/src/main/java/rmi/RMICaptureServer.java
  23. 0
    0
      external/source/javapayload/javapayload/src/main/java/rmi/RMIReplaySender.java
  24. 0
    0
      external/source/javapayload/javapayload/src/main/java/rmi/RMISender.java
  25. 52
    0
      external/source/javapayload/pom.xml

+ 5
- 2
.gitignore View File

@@ -14,8 +14,11 @@ doc
14 14
 external/source/meterpreter/java/bin
15 15
 external/source/meterpreter/java/build
16 16
 external/source/meterpreter/java/extensions
17
-external/source/javapayload/bin
18
-external/source/javapayload/build
17
+external/source/javapayload/*/.classpath
18
+external/source/javapayload/*/.project
19
+external/source/javapayload/*/.settings
20
+external/source/javapayload/*/bin
21
+external/source/javapayload/*/target
19 22
 # Packaging directory
20 23
 pkg
21 24
 tags

+ 37
- 0
external/source/javapayload/COMPILING.txt View File

@@ -0,0 +1,37 @@
1
+To compile JavaPayload for Metasploit (including Java Meterpreter), you need
2
+Maven 3.0 or above. Just run
3
+
4
+mvn package
5
+
6
+to package all the files, or
7
+
8
+mvn -P deploy package
9
+
10
+to package all the files and copy them into the correct place for Metasploit
11
+(/data/java).
12
+
13
+In case you want to edit/debug JavaPayload for Metasploit or Java Meterpreter,
14
+Maven provides plugins to auto-generate project files for your favourite IDE
15
+(at least for Eclipse, Netbeans or IntelliJ). I use Eclipse, so to generate
16
+project files I use
17
+
18
+mvn eclipse:eclipse
19
+
20
+This will generate project files that can be imported via 
21
+
22
+File->Import->Existing Projects into Workspace
23
+
24
+into your Eclipse workspace.
25
+
26
+(Note that if this is your first Maven project you want to use in Eclipse, you
27
+also have to run 
28
+
29
+mvn -Declipse.workspace=/path/to/your/workspace eclipse:configure-workspace
30
+
31
+to set up path variables like M2_REPO to point to the correct location.)
32
+
33
+For NetBeans or IntelliJ IDEA, refer to the documentation at
34
+
35
+http://maven.apache.org/netbeans-module.html
36
+http://maven.apache.org/plugins/maven-idea-plugin/
37
+

+ 0
- 7
external/source/javapayload/javapayload/.classpath View File

@@ -1,7 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<classpath>
3
-	<classpathentry kind="src" path="src"/>
4
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
5
-	<classpathentry kind="lib" path="lib/servlet-api-2.2.jar"/>
6
-	<classpathentry kind="output" path="bin"/>
7
-</classpath>

+ 0
- 17
external/source/javapayload/javapayload/.project View File

@@ -1,17 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<projectDescription>
3
-	<name>JavaPayload4Meterpreter</name>
4
-	<comment></comment>
5
-	<projects>
6
-	</projects>
7
-	<buildSpec>
8
-		<buildCommand>
9
-			<name>org.eclipse.jdt.core.javabuilder</name>
10
-			<arguments>
11
-			</arguments>
12
-		</buildCommand>
13
-	</buildSpec>
14
-	<natures>
15
-		<nature>org.eclipse.jdt.core.javanature</nature>
16
-	</natures>
17
-</projectDescription>

+ 0
- 12
external/source/javapayload/javapayload/.settings/org.eclipse.jdt.core.prefs View File

@@ -1,12 +0,0 @@
1
-#Tue Aug 17 23:14:37 CEST 2010
2
-eclipse.preferences.version=1
3
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
-org.eclipse.jdt.core.compiler.compliance=1.3
7
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
9
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
11
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
12
-org.eclipse.jdt.core.compiler.source=1.3

+ 0
- 68
external/source/javapayload/javapayload/build.xml View File

@@ -1,68 +0,0 @@
1
-<?xml version="1.0"?>
2
-<project name="JavaPayload4Meterpreter" default="deploy">
3
-
4
-	<target name="clean">
5
-		<delete dir="build" />
6
-	</target>
7
-
8
-	<target name="compile">
9
-		<mkdir dir="build" />
10
-		<javac srcdir="src" destdir="build" source="1.1" target="1.1" classpath="lib/servlet-api-2.2.jar" debug="no" />
11
-	</target>
12
-
13
-	<target name="jar" depends="compile">
14
-		<!-- example: spawning bind -->
15
-		<propertyfile file="build/metasploit.dat">
16
-			<entry key="Spawn" value="2"/>
17
-			<entry key="LPORT" value="5555" />
18
-		</propertyfile>
19
-		<jar destfile="example-spawn-bind.jar">
20
-			<manifest>
21
-				<attribute name="Main-Class" value="metasploit.Payload"/>
22
-			</manifest>
23
-			<fileset dir="build">
24
-    			<include name="metasploit/Payload.class"/>
25
-				<include name="metasploit.dat"/>
26
-			</fileset>
27
-		</jar>
28
-		<delete file="build/metasploit.dat"/>
29
-	</target>
30
-	
31
-	<target name="buildrmi" depends="compile">
32
-		<!-- build dummy jar used for capturing communication and for testing -->
33
-		<propertyfile file="build/metasploit.dat">
34
-			<entry key="LPORT" value="4444" />
35
-			<entry key="LHOST" value="127.0.0.1" />
36
-		</propertyfile>
37
-		<jar destfile="rmidummy.jar">
38
-			<manifest>
39
-				<attribute name="Main-Class" value="metasploit.Payload"/>
40
-			</manifest>
41
-			<fileset dir="build">
42
-    			<include name="metasploit/RMILoader.class"/>
43
-    			<include name="metasploit/RMIPayload.class"/>
44
-    			<include name="metasploit/Payload.class"/>
45
-				<include name="metasploit.dat"/>
46
-			</fileset>
47
-		</jar>
48
-		
49
-		<!-- rename local metasploit/RMILoader.class to ensure a classloader URL will be serialized -->
50
-		<move file="build/metasploit/RMILoader.class" tofile="build/metasploit/RMILoader.class.tmp" />
51
-		
52
-		<!-- run the capture server -->
53
-		<java classpath="build" classname="rmi.RMICaptureServer" />
54
-
55
-		<!-- rename back -->
56
-		<move file="build/metasploit/RMILoader.class.tmp" tofile="build/metasploit/RMILoader.class" />
57
-	</target>
58
-	
59
-	<target name="deploy" depends="compile">
60
-		<copy todir="../../../data/java">
61
-			<fileset dir="build">
62
-				<exclude name="metasploit/PayloadApplet.class" />
63
-				<exclude name="rmi/**" />
64
-				<exclude name="metasploit.dat" />
65
-			</fileset>
66
-		</copy>
67
-	</target>
68
-</project>

BIN
external/source/javapayload/javapayload/lib/servlet-api-2.2.jar View File


+ 147
- 0
external/source/javapayload/javapayload/pom.xml View File

@@ -0,0 +1,147 @@
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/xsd/maven-4.0.0.xsd">
3
+	<modelVersion>4.0.0</modelVersion>
4
+	<groupId>com.metasploit</groupId>
5
+	<artifactId>Metasploit-JavaPayload</artifactId>
6
+	<parent>
7
+		<groupId>com.metasploit</groupId>
8
+		<artifactId>Metasploit-JavaPayload-parent</artifactId>
9
+		<version>1-SNAPSHOT</version>
10
+	</parent>
11
+	<packaging>jar</packaging>
12
+	<name>JavaPayload for Metasploit</name>
13
+	<url>http://www.metasploit.com/</url>
14
+	<properties>
15
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16
+	</properties>
17
+	<dependencies>
18
+		<dependency>
19
+			<groupId>javax.servlet</groupId>
20
+			<artifactId>servlet-api</artifactId>
21
+			<version>2.2</version>
22
+		</dependency>
23
+	</dependencies>
24
+	<profiles>
25
+		<profile>
26
+			<!-- deploy built files to Metasploit data directory -->
27
+			<id>deploy</id>
28
+			<build>
29
+				<plugins>
30
+					<plugin>
31
+						<artifactId>maven-antrun-plugin</artifactId>
32
+						<version>1.7</version>
33
+						<executions>
34
+							<execution>
35
+								<phase>package</phase>
36
+								<goals>
37
+									<goal>run</goal>
38
+								</goals>
39
+								<configuration>
40
+									<target>
41
+										<copy todir="${project.basedir}/../../../../data/java">
42
+											<fileset dir="${project.basedir}/target/classes">
43
+												<exclude name="metasploit/PayloadApplet.class" />
44
+												<exclude name="rmi/**" />
45
+												<exclude name="metasploit.dat" />
46
+											</fileset>
47
+										</copy>
48
+									</target>
49
+								</configuration>
50
+							</execution>
51
+						</executions>
52
+					</plugin>
53
+				</plugins>
54
+			</build>
55
+		</profile>
56
+		<profile>
57
+			<!-- build example JARs -->
58
+			<id>examples</id>
59
+			<build>
60
+				<plugins>
61
+					<plugin>
62
+						<artifactId>maven-antrun-plugin</artifactId>
63
+						<version>1.7</version>
64
+						<executions>
65
+							<execution>
66
+								<phase>package</phase>
67
+								<goals>
68
+									<goal>run</goal>
69
+								</goals>
70
+								<configuration>
71
+									<target>
72
+										<!-- example: spawning bind -->
73
+										<propertyfile file="${project.basedir}/target/classes/metasploit.dat">
74
+											<entry key="Spawn" value="2" />
75
+											<entry key="LPORT" value="5555" />
76
+										</propertyfile>
77
+										<jar destfile="${project.basedir}/example-spawn-bind.jar">
78
+											<manifest>
79
+												<attribute name="Main-Class" value="metasploit.Payload" />
80
+											</manifest>
81
+											<fileset dir="${project.basedir}/target/classes">
82
+												<include name="metasploit/Payload.class" />
83
+												<include name="metasploit.dat" />
84
+											</fileset>
85
+										</jar>
86
+										<delete file="${project.basedir}/target/classes/metasploit.dat" />
87
+									</target>
88
+								</configuration>
89
+							</execution>
90
+						</executions>
91
+					</plugin>
92
+				</plugins>
93
+			</build>
94
+		</profile>
95
+		<profile>
96
+			<!-- build dummy jar used for capturing communication and for testing RMI injection -->
97
+			<id>buildrmi</id>
98
+			<build>
99
+				<plugins>
100
+					<plugin>
101
+						<artifactId>maven-antrun-plugin</artifactId>
102
+						<version>1.7</version>
103
+						<executions>
104
+							<execution>
105
+								<phase>package</phase>
106
+								<goals>
107
+									<goal>run</goal>
108
+								</goals>
109
+								<configuration>
110
+									<target>
111
+										<propertyfile file="${project.basedir}/target/classes/metasploit.dat">
112
+											<entry key="LPORT" value="4444" />
113
+											<entry key="LHOST" value="127.0.0.1" />
114
+										</propertyfile>
115
+										<mkdir dir="${project.basedir}/target/rmi/build" />
116
+										<jar destfile="${project.basedir}/target/rmi/rmidummy.jar">
117
+											<manifest>
118
+												<attribute name="Main-Class" value="metasploit.Payload" />
119
+											</manifest>
120
+											<fileset dir="${project.basedir}/target/classes">
121
+												<include name="metasploit/RMILoader.class" />
122
+												<include name="metasploit/RMIPayload.class" />
123
+												<include name="metasploit/Payload.class" />
124
+												<include name="metasploit.dat" />
125
+											</fileset>
126
+										</jar>
127
+										<delete file="${project.basedir}/target/classes/metasploit.dat" />
128
+
129
+										<!-- rename local metasploit/RMILoader.class to ensure a classloader 
130
+											URL will be serialized -->
131
+										<move file="${project.basedir}/target/classes/metasploit/RMILoader.class" tofile="${project.basedir}/target/classes/metasploit/RMILoader.class.tmp" />
132
+
133
+										<!-- run the capture server -->
134
+										<java classpath="${project.basedir}/target/classes" classname="rmi.RMICaptureServer" dir="${project.basedir}/target/rmi" fork="true" />
135
+
136
+										<!-- rename back -->
137
+										<move file="${project.basedir}/target/classes/metasploit/RMILoader.class.tmp" tofile="${project.basedir}/target/classes/metasploit/RMILoader.class" />
138
+									</target>
139
+								</configuration>
140
+							</execution>
141
+						</executions>
142
+					</plugin>
143
+				</plugins>
144
+			</build>
145
+		</profile>
146
+	</profiles>
147
+</project>

external/source/javapayload/javapayload/src/com/metasploit/meterpreter/MemoryBufferURLConnection.java → external/source/javapayload/javapayload/src/main/java/com/metasploit/meterpreter/MemoryBufferURLConnection.java View File


external/source/javapayload/javapayload/src/com/metasploit/meterpreter/MemoryBufferURLStreamHandler.java → external/source/javapayload/javapayload/src/main/java/com/metasploit/meterpreter/MemoryBufferURLStreamHandler.java View File


external/source/javapayload/javapayload/src/javapayload/stage/Meterpreter.java → external/source/javapayload/javapayload/src/main/java/javapayload/stage/Meterpreter.java View File


external/source/javapayload/javapayload/src/javapayload/stage/Shell.java → external/source/javapayload/javapayload/src/main/java/javapayload/stage/Shell.java View File


external/source/javapayload/javapayload/src/javapayload/stage/Stage.java → external/source/javapayload/javapayload/src/main/java/javapayload/stage/Stage.java View File


external/source/javapayload/javapayload/src/javapayload/stage/StreamForwarder.java → external/source/javapayload/javapayload/src/main/java/javapayload/stage/StreamForwarder.java View File


external/source/javapayload/javapayload/src/metasploit/AESEncryption.java → external/source/javapayload/javapayload/src/main/java/metasploit/AESEncryption.java View File


external/source/javapayload/javapayload/src/metasploit/Payload.java → external/source/javapayload/javapayload/src/main/java/metasploit/Payload.java View File


external/source/javapayload/javapayload/src/metasploit/PayloadApplet.java → external/source/javapayload/javapayload/src/main/java/metasploit/PayloadApplet.java View File


external/source/javapayload/javapayload/src/metasploit/PayloadServlet.java → external/source/javapayload/javapayload/src/main/java/metasploit/PayloadServlet.java View File


external/source/javapayload/javapayload/src/metasploit/PayloadTrustManager.java → external/source/javapayload/javapayload/src/main/java/metasploit/PayloadTrustManager.java View File


external/source/javapayload/javapayload/src/metasploit/RMILoader.java → external/source/javapayload/javapayload/src/main/java/metasploit/RMILoader.java View File


external/source/javapayload/javapayload/src/metasploit/RMIPayload.java → external/source/javapayload/javapayload/src/main/java/metasploit/RMIPayload.java View File


external/source/javapayload/javapayload/src/rmi/RMICaptureServer.java → external/source/javapayload/javapayload/src/main/java/rmi/RMICaptureServer.java View File


external/source/javapayload/javapayload/src/rmi/RMIReplaySender.java → external/source/javapayload/javapayload/src/main/java/rmi/RMIReplaySender.java View File


external/source/javapayload/javapayload/src/rmi/RMISender.java → external/source/javapayload/javapayload/src/main/java/rmi/RMISender.java View File


+ 52
- 0
external/source/javapayload/pom.xml View File

@@ -0,0 +1,52 @@
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/xsd/maven-4.0.0.xsd">
3
+	<modelVersion>4.0.0</modelVersion>
4
+	<groupId>com.metasploit</groupId>
5
+	<artifactId>Metasploit-JavaPayload-parent</artifactId>
6
+	<version>1-SNAPSHOT</version>
7
+	<packaging>pom</packaging>
8
+	<name>JavaPayload for Metasploit (Parent project)</name>
9
+	<url>http://www.metasploit.com/</url>
10
+	<properties>
11
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12
+	</properties>
13
+	<dependencies>
14
+		<dependency>
15
+			<groupId>junit</groupId>
16
+			<artifactId>junit</artifactId>
17
+			<version>4.11</version>
18
+			<scope>test</scope>
19
+		</dependency>
20
+	</dependencies>
21
+	<build>
22
+		<plugins>
23
+			<plugin>
24
+				<groupId>org.apache.maven.plugins</groupId>
25
+				<artifactId>maven-compiler-plugin</artifactId>
26
+				<version>3.0</version>
27
+				<configuration>
28
+					<source>1.3</source>
29
+					<target>1.1</target>
30
+					<debug>true</debug> <!-- http://stackoverflow.com/q/4220083/90203 -->
31
+					<debuglevel>none</debuglevel>
32
+				</configuration>
33
+			</plugin>
34
+			<plugin>
35
+				<artifactId>maven-eclipse-plugin</artifactId>
36
+				<version>2.9</version>
37
+				<configuration>
38
+					<buildOutputDirectory>bin</buildOutputDirectory>
39
+					<downloadSources>true</downloadSources>
40
+					<testSourcesLast>true</testSourcesLast>
41
+				</configuration>
42
+			</plugin>
43
+		</plugins>
44
+	</build>
45
+	<modules>
46
+		<module>javapayload</module>
47
+		<!-- <module>meterpreter</module> -->
48
+	</modules>
49
+	<prerequisites>
50
+		<maven>3.0</maven>
51
+	</prerequisites>
52
+</project>

Loading…
Cancel
Save