SMTP
A poorly configured or vulnerable mail server can give an initial foothold into a network. Before attacking, fingerprint the server to make targeting as precise as possible.
Enumerating Server Details
We use the smtp_version module in Metasploit for this. As the name implies, it scans a range of IP addresses and reports the version of any mail servers it finds.
Enumerating Users from SMTP
The SMTP service has two internal commands useful for enumerating users: VRFY (confirms valid usernames) and EXPN (reveals the actual address behind a user's alias and lists the members of mailing lists). With these we can reveal a list of valid users.
This can be done manually over a telnet connection, but Metasploit again has a handy module, appropriately named smtp_enum, that does the legwork. Feed it a host or range of hosts to scan and a wordlist of usernames to enumerate.
Requirements
Since we are using Metasploit, you need it installed. It is present by default on both Kali Linux and Parrot OS, but it is worth a quick update to be on the latest version before attacking. A simple "sudo apt update", with the accompanying upgrade if required, handles that.
Alternatives
This enumeration technique works for most SMTP configurations, but there are other, non-Metasploit tools such as smtp-user-enum that work even better for enumerating OS-level user accounts on Solaris via the SMTP service. It enumerates by inspecting the responses to VRFY, EXPN, and RCPT TO commands.
The technique could be adapted in future to work against other vulnerable SMTP daemons, but that has not been done as of the time of writing. It is an alternative worth keeping in mind if you are trying to distance yourself from Metasploit, for example in preparation for OSCP.
Now the theory is covered. Let's get going.
We will use the "top-usernames-shortlist.txt" wordlist from the Usernames subsection of seclists (/usr/share/wordlists/SecLists/Usernames if you have it installed).