msgrouting and emailgw - wb8tyw/D-Rats GitHub Wiki

The msgrouting module has a feature for routing messages from d-rats to internet email.

The emailgw is a feature for d-rats for connecting to internet email to get messages.

Msgrouting internet e-mail sending

To test msgrouting, you need a local mail server setup, as while it being tested, you do not want test e-mails to leak out on to the public internet.

For actual use, you would use an actual e-mail server. Many ISPs require you to connect on port 587 or port 465 to e-mail servers that are not inside their network. This is a measure design make it harder to for criminals to send spam through malware on systems inside their network.

A network owner should be monitoring if someone attempts to connect to port 25 on a server outside their network that has not made prior arrangements with them to whitelist it. This is one of the most reliable and fastest ways that a network owner can detect and isolate an infected system.

So if you can connect to port 25 to a mail server outside your ISP network, as above, it means that your ISP does not have proper security monitoring set up.

This should be standard practice for all corporate internal networks for the same reason.

Step one, it is documented that you need a fully qualified hostname on your test system. I use "example.com" one for testing on my internal network as that is guaranteed to not exist on the public internet. However a there is a DNS entry for localhost.com, but no MX entry for it, so unless we tamper more with the /etc/hosts file, we will need to test with "username@locahost" where username is your user.

# Anti-x Linux, a Debian variant so most Ubuntu commands also work
sudo apt-get update
sudo apt-get install postfix
# Dialog screen pops up.
# select local e-mail only
# system mail name: your_hostname.example.com

postconf mail_version
mail_version = 3.4.14
sudo ss -lnpt | grep master
LISTEN    0         100              127.0.0.1:25               0.0.0.0:*        users:(("master",pid=9001,fd=12))                                              
LISTEN    0         100                  [::1]:25                  [::]:*        users:(("master",pid=9001,fd=13))                                              
sudo apt-get install mailutils

mail
Cannot open mailbox /var/mail/malmberg: Permission denied
No mail for malmberg

sudo ls -l /var/mail
total 16
-rw-r--r-- 1 root mail     0 Aug 26  2020 malmberg
-rw------- 1 root mail 14784 Apr 10 08:09 root

sudo chown malmberg:malmberg /var/mail/malmberg

mail
No mail for malmberg

mail -a FROM:malmberg@localhost malmberg@localhost
Cc: 
Subject: Test of e-mail
Test using the e-mail program

mail
"/var/mail/malmberg": 1 message 1 new
>N   1 malmberg@localhost Sun Apr 10 09:00  13/460   Test of e-mail
? 1
Return-Path: <malmberg@localhost>
X-Original-To: malmberg@localhost
Delivered-To: malmberg@localhost
Received: by coyote.example.com (Postfix, from userid 1000)
	id 7BC1A2804C5; Sun, 10 Apr 2022 09:00:04 -0500 (CDT)
FROM: malmberg@localhost
To: <malmberg@localhost>
Subject: Test of e-mail
X-Mailer: mail (GNU Mailutils 3.5)
Message-Id: <[email protected]>
Date: Sun, 10 Apr 2022 09:00:04 -0500 (CDT)

Test using the e-mail program
? d 1
? q
Held 0 messages in /var/mail/malmberg

At this point we have a functional mail server

In d-rats Preferences, Network, Email Access add your call for e-mail access for both directions. Your call must currently include the ID suffix.

In d-rats,Preferences, Network, Outgoing Email, Enable SMTP gateway, server localhost, and source address your username@localhost, no username or password. TLS not enabled.

The source address is one that if this were a real e-mail gateway, an account where you want replies to your e-mail message to go.

TODO: Ideally we may want to have an option to have "[email protected]" format, where the username is the one that is used for sending e-mail in to d-rats, and the callsign is the callsign of the actual sender or for incoming the recipient. This + notation is part of the e-mail specification and mail servers and clients are suppose to ignore contents between the + and the @ characters, including the +. Tests in the past have shown that many mail servers and clients are not compliant with this though.

emailgw internet e-mail fetching

Fetching e-mail with d-rats requires a pop3 server to be setup, which usually requires an smtp server associated with it.

To test emailgw, you will want an isolated pop3 server and associated smtp server to prevent accidents.

Anti-x linux, as stated before is a Debian variant, so Ubuntu commands generally work.

sudo apt-get update
sudo apt-get install dovecot-core dovecot-pop3d
# dovecot configuration options are now in /etc/dovecot/conf.d/ or /etc/dovecot/local.conf
# The /etc/dovecot/conf.d files are generally processed in alphabetical order and the
# /etc/dovecot/local.conf is processed last.
# in general you can add files in the /etc/dovecot/conf.d or add a /etc/dovecot/local.conf file.
# if you edit an existing file, then on upgrades, it will cause conflicts with upgrades to the
# dovecot packages.  Debian installers will then stop and prompt you for what action to take for
# each modified file.
# This is a convention that Linux distributions have been moving to in order keep local
# configuration changes from being in conflict with distribution supplied files.

# dovecot defaults to listening on all IP addresses.  That is good enough for testing
# dovecot defaults to using all installed protocols, since I only installed pop3, again
# no changes needed
# dovecot defaults using /var/mail/%user for getting e-mail to read.  Which is also the
# default for the smtp server I installed for message testing.

In D-rats, the POP3 server is configured by adding an e-mail account. I added one with my linux username/password, ssl disabled, default port 110, and action Form, and enabled.

Action option of Form puts the message in your Inbox.

Action option of Chat, writes the message out to all "radio ports" that you have active connections on. For testing, make sure that you have all but your local test "radio ports" disabled.

First bug, the password is displayed in plain text in the configuration form.

Next bug: The edit and remove buttons are active when nothing is selected.