SMTP Pentest Lab Setup in Ubuntu (Port 25)

From Wikipedia

Hello friends! Today we are discussing “configuration of SMTP mail server” for sending mail in your LAN network.  

SMTP stands for simple mail transfer protocol communication between mail servers uses TCP port 25 Mail clients. For retrieving messages, client applications usually use either IMAP or POP3.

POP3 stands for Post Office Protocol (POP) is an application-layer Internet standard protocol used by local e-mail clients to retrieve e-mail from a remote server over a TCP/IP connection. It uses port 110 for receiving mail.

IMAP stands for Internet Message Access Protocol (IMAP) is also an Internet standard protocol used by e-mail clients to retrieve e-mail messages from a mail server over a TCP/IP connection. It uses port 143 for receiving mail.

Let’s start!!

Add Hostname and domain

With root privilege open hosts file for adding hostname and Domain name through the following command:

Now add given below line in the host file and then save it.

127.0.0.1 mail.ignite.lab ignite

Open hostname file with root privilege for changing the default hostname.

 Now re-write the default hostname as “ignite” which we have mentioned in host file also, as shown in the given image and save it.

Now restart the machine after making changes in the hosts’ file and hostname.

Now check hostname and domain by typing following command and assured the changes you had made.

Install Postfix

Postfix is the default Mail Transfer Agent (MTA) for Ubuntu. It is in Ubuntu’s main repository, which means that it receives security updates. This guide explains how to install and configure postfix and set it up as an SMTP server using a secure connection.

A dialog box will pop for Postfix Configuration where you have to select Internet site as a general type of mail configuration as shown in the given image.

Enter Domain name (mail.ignite.lab) which you have to save inside the host file for system mail name and click on OK.

Postfix Configuration Setting

Open main.cf file and make the following changes in this then save it.

  • Add subnet IP my networks = 127.0.0.0/8 192.168.1.0/24
  • Enter inet_protocols = ipv4
  • Add new line home_mailbox = Maildir/

Execute given below command after making changes in the configuration file.

Now Type the following command to view the list of the open port to listen for incoming connections.

From the given image you can observe that STATE of port 25.

Install Dovecot

Dovecot is a Mail Delivery Agent, written with security primarily in mind. It supports the major mailbox formats: mbox or Maildir. This section explains how to set it up as an IMAP or pop3 server.

A dialog box will pop for configuring dovecot-core where you can select yes for creating a self –signed SSL certificate.

Another POP up will ask hostname that will be used in SSL certificates. Enter your domain name as shown in the given image and click on OK.

Dovecot configuration setting

Open 10-auth.conf file through given below path:

Now make the following changes in this as shown in the given image then save it.

change auth mechanisms = plain login

Open 10-mail.conf file through given below path:

Now make the following changes in this as shown in the given image then save it.

Open 10-master.conf file through given below path:

Give permission for unix_listener auth-user DB

Check service using netstat –tnl to view the list of the open port to listen for incoming connections

From the given image you can observe STATE LISTEN for port 110 and 143.

Configure Mail Account in Thunderbird

We have already a user: sr let’s configure a mail account for him by adding following information in the given text field

Now click on continue then choose manual config tab.

Enter your network IP as server hostname (192.168.1.107) for incoming mail on port 143 and outgoing mail via port 25. Then click on done.

A new window will come up for security Exception click on tab Confirm security Exception given at the bottom.

For sending mail we always need two users to account one as sender another for the receiver. Now type the following command to add a new user.

adduser raj

 Since we had already configure an account for user:sr in thunderbird , now create another mail account for usre:raj in thunderbird as created above.

Hence we are having two accounts in a mail server for sending the message

Send mail using Thunderbird

Now write an Email from: [email protected] to [email protected] for testing mail server service as shown in the given image. Click on send after typing message.

Open the inbox of receiver account where you will get a mail from [email protected] as shown in the given image.

In this way, you can configure your own mail server for the local network.

Author: Sanjeet Kumar is an Information Security Analyst | Pentester | Researcher  Contact Here

Leave a Reply

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