Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make android payload buildable on Windows 11 #739

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RUN wget http://dl.google.com/android/android-sdk_r24-linux.tgz && \
mv android-sdk-linux /usr/local/android-sdk
RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter tools --no-ui -a
RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter platform-tools --no-ui -a
RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter build-tools-23.0.0 --no-ui -a
RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter build-tools-23.0.3 --no-ui -a
RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter android-10 --no-ui -a
RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter android-19 --no-ui -a
RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter android-3 --no-ui -a
Expand Down
10 changes: 9 additions & 1 deletion java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

1. Install Maven and Java 1.8, this will depend on your OS
1. Download the [Android SDK](https://developer.android.com/sdk/index.html)
1. Install Android SDK Platforms 3, 10 and 19, and update the "Android SDK Tools" and "Android SDK Platform-tools"
1. Install Android SDK Platforms 3, 10, 19 and 29, and update the "Android SDK Tools" and "Android SDK Platform-tools" (if you does not find android sdk tools, you must uncheck `Hide Obsolete Packages` in Android SDK Manager)
1. Install Android SDK Build-Tools 23.0.3
1. Compile the Android and Java Meterpreter, which deploys to the `../metasploit-framework` folder
```
mvn package -Dandroid.sdk.path=/path/to/android-sdk -Dandroid.release=true -P deploy
Expand Down Expand Up @@ -43,6 +44,13 @@ make clean
make android
```

## Building on Windows

```powershell
# Important: Ensure Java 1.8 is used when compiling
$env:JAVA_HOME="C:\Program Files\Java\jdk-1.8"
```

## Building on OSX

```
Expand Down
12 changes: 11 additions & 1 deletion java/androidpayload/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,23 @@
<sdk>
<!-- platform or api level (api level 10 = platform 2.3)-->
<platform>10</platform>
<buildTools>23.0.3</buildTools>
</sdk>
<proguard>
<skip>false</skip>
<config>proguard.cfg</config>
</proguard>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand All @@ -81,7 +91,7 @@
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 2 additions & 0 deletions java/androidpayload/app/proguard.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Preserve all classes from the Java standard library
-keep class java.lang.** { *; }

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Service
Expand Down
28 changes: 20 additions & 8 deletions java/androidpayload/library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<sdk>
<!-- platform or api level (api level 19 = platform 4.4 (kitkat))-->
<platform>19</platform>
<buildTools>23.0.3</buildTools>
</sdk>
</configuration>
</plugin>
Expand Down Expand Up @@ -112,10 +113,7 @@
</goals>
<configuration>
<target>
<condition property="dx.filename" value="dx.bat">
<os family="windows" />
</condition>
<property name="dx.filename" value="dx" />
<property name="dx.filepath" value="build-tools/23.0.3/lib/dx.jar" />

<echo>Building shell</echo>
<delete dir="${project.basedir}/target/dx" />
Expand All @@ -127,7 +125,10 @@
<zipfileset src="${com.metasploit:Metasploit-JavaPayload:jar}" includes="javapayload/stage/StreamForwarder.class" />
<zipfileset src="${com.metasploit:Metasploit-JavaPayload:jar}" includes="javapayload/stage/Stage.class" />
</copy>
<exec executable="${android.sdk.path}/platforms/android-3/tools/${dx.filename}" failonerror="true">
<exec executable="java" failonerror="true">
<arg value="-Xmx1024M" />
<arg value="-jar" />
<arg value="${android.sdk.path}/${dx.filepath}" />
<arg value="--verbose" />
<arg value="--dex" />
<arg value="--output=${project.basedir}/../../${deploy.path}/data/android/shell.jar" />
Expand All @@ -142,7 +143,10 @@
</fileset>
<zipfileset src="${com.metasploit:Metasploit-JavaPayload:jar}" includes="javapayload/stage/Stage.class" />
</copy>
<exec executable="${android.sdk.path}/platforms/android-3/tools/${dx.filename}" failonerror="true">
<exec executable="java" failonerror="true">
<arg value="-Xmx1024M" />
<arg value="-jar" />
<arg value="${android.sdk.path}/${dx.filepath}" />
<arg value="--verbose" />
<arg value="--dex" />
<arg value="--output=${project.basedir}/../../${deploy.path}/data/android/metstage.jar" />
Expand All @@ -156,7 +160,11 @@
<include name="com/metasploit/meterpreter/**/*.class" />
</fileset>
</copy>
<exec executable="${android.sdk.path}/platforms/android-3/tools/${dx.filename}" failonerror="true">

<exec executable="java" failonerror="true">
<arg value="-Xmx1024M" />
<arg value="-jar" />
<arg value="${android.sdk.path}/${dx.filepath}" />
<arg value="--verbose" />
<arg value="--dex" />
<arg value="--output=${project.basedir}/../../${deploy.path}/data/android/meterpreter.jar" />
Expand All @@ -167,7 +175,11 @@
</exec>

<echo>Building stageless meterpreter</echo>
<exec executable="${android.sdk.path}/platforms/android-3/tools/${dx.filename}" failonerror="true">

<exec executable="java" failonerror="true">
<arg value="-Xmx1024M" />
<arg value="-jar" />
<arg value="${android.sdk.path}/${dx.filepath}" />
<arg value="--verbose" />
<arg value="--dex" />
<arg value="--output=${project.basedir}/../../${deploy.path}/data/android/meterpreter.dex" />
Expand Down
4 changes: 2 additions & 2 deletions java/meterpreter/meterpreter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -68,7 +68,7 @@
<target>
<mkdir dir="${project.basedir}/target/tmp" />
<unzip src="${project.basedir}/target/${project.build.finalName}.jar" dest="${project.basedir}/target/tmp" />
<touch datetime="01/01/2000 00:00 AM">
<touch datetime="01/01/2000 00:00:00 AM" pattern="MM/dd/YYYY hh:mm:ss a">
<fileset dir="${project.basedir}/target/tmp" includes="**/*" />
</touch>
<delete file="${project.basedir}/../../${deploy.path}/data/meterpreter/${project.build.finalName}.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion java/meterpreter/stdapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<target>
<mkdir dir="${project.basedir}/target/tmp" />
<unzip src="${project.basedir}/target/${project.build.finalName}.jar" dest="${project.basedir}/target/tmp" />
<touch datetime="01/01/2000 00:00 AM">
<touch datetime="01/01/2000 00:00:00 AM" pattern="MM/dd/YYYY hh:mm:ss a">
<fileset dir="${project.basedir}/target/tmp" includes="**/*" />
</touch>
<delete file="${project.basedir}/../../${deploy.path}/data/meterpreter/${project.build.finalName}.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion java/version-compatibility-check/android-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<version>1.8</version>
<executions>
<execution>
<id>copy-source</id>
Expand Down
Loading