In my previous lab, I demonstrated to you, how A Brute-Force Attack works on a server.
Goal: Brute forcing the Metasploitable server and gain SSH session.
Follow the below steps to get a login session:
Step 1: Start the msfconsole
Use the below command to start the Metasploit console in a proper way:
Step 2: Search the Auxiliary module
Next, we load up the scanner module in Metasploit:
Step 3: Configure the ssh_login auxiliary module
Once you set the module to auxiliary mode then set the following configuration:
Note: You need a Wordlist file to manage, the brute force attack. At this place, I use my previous wordlist from the previous chapter.
Step 4: Apply the Run command
Once you configure the setting, execute the run command:
Step 5: Interact with shell
From step 4 you can find out that auxiliary module execution is completed and a command shell session opened. You can find out the session using the sessions command and then connect:
Prevention:
There are many methods to stop or prevent brute force attacks.
The most obvious is a strong password policy. Each web application or public server should enforce the use of strong passwords. For example, standard user accounts should have at least eight letters, a number, uppercase, and lowercase letters, and a special character. Moreover, servers should require frequent password changes.
Let’s investigate other ways to prevent a brute-force attack.
- Limit failed login attempts
- Make the root user inaccessible via SSH by editing the sshd_config file
- Don’t use a default port, edit the port line in your sshd_configfile
- Use Captcha
- Limit logins to a specified IP address or range
- Two-factor authentication
- Unique login URLs
- Monitor server logs