install_msf_apk.sh 886 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. # This script allows you install your msf payload apk to your Android emulator.
  3. # Make sure you have Java and Android SDK.
  4. apk_path=$1
  5. if ! [ -x "$(command -v adb)" ]
  6. then
  7. echo "Android SDK platform-tools not included in \$PATH."
  8. exit
  9. fi
  10. if ! [ -x "$(command -v jarsigner)" ]
  11. then
  12. echo "jarsigner is missing."
  13. exit
  14. fi
  15. if ! [ -e "$HOME/.android/debug.keystore" ]
  16. then
  17. echo "Missing ~/.android/debug.keystore"
  18. exit
  19. fi
  20. if [ -z "$apk_path" ]
  21. then
  22. echo "APK path is required."
  23. exit
  24. fi
  25. if ! [ -a "$apk_path" ]
  26. then
  27. echo "APK not found."
  28. exit
  29. fi
  30. jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -keypass android -digestalg SHA1 -sigalg MD5withRSA $apk_path androiddebugkey
  31. adb uninstall com.metasploit.stage
  32. adb install -r $apk_path
  33. adb shell am start -a android.intent.action.MAIN -n com.metasploit.stage/.MainActivity