I am going to set up a mail server that will be later used as an SMTP relay server. First off, a new Ubuntu droplet was created in Digital Ocean:
Postfix MTA was installed on the droplet with:
During postfix installation, I set nodspot.com as the mail name. After the installation, this can be checked/changed here:
DNS Records
DNS records for nodspot.com has to be updated like so:
A record pointing to the droplet IP
Testing Mail Server
Once postfix is installed and the DNS records are configured, we can test if the mail server is running by:
If successful, you should see something like this:
We can further test if the mail server works by trying to send an actual email like so:
Soon enough, the email comes to my gmail:
...with the following headers - all as expected. Note that at this point the originating IP seen in headers is my droplet IP 206.189.221.162:
Setting up Originating Mail Server
We need to set up the originating mail server that will use the server we set up earlier as a relay server. To achieve this, on my attacking machine, I installed postfix mail server.
The next thing to do is to amend the /etc/postfix/main.cf and set the relayhost=nodspot.comwhich will make the outgoing emails from the attacking system travel to the nodspot.com mail server (the server we set up above) first:
Once the change is made and the postfix server is rebooted, we can try sending a test email from the attacking server:
If you do not receive the email, make sure that the relay server is not denying access for the attacking machine. If you see your emails getting deferred (on your attacking machine) with the below message, it is exactly what is happening:
Once the relay issue is solved, we can repeat the test and see a successful relay:
This time the headers look like so:
Note how this time we are observing the originating host's details such as a host name and an IP address - this is unwanted and we want to redact that information out.
This lab is not going to deal with the emails being marked as phishing by gmail. This, however, is related to setting up DKIM, PTR records and the likes, see below for more references.