Hermes
What is hermes?
hermes is an SMTP proxy. We developed hermes for our own use on ITEISA, and we have perfected it with new features to cover our own needs. It is now being made public on the hope that it will help others to stop spam the same way it does for us everyday.
What makes it special is that it can be used to stop spam using a combination of the following techniques:
- SMTP banner delay
- Most spammers will start sending data as soon as the connection is open, without waiting for the SMTP banner. What we do is delay this banner and if we have data waiting before we print it, we drop the connection.
- Throttling
- hermes will process incoming SMTP commands at a slow pace. Most spammers have very little patience, so they will stop sending an email if it's taking too long to deliver.
- Greylisting
- Greylisting is a process that will delay incoming mails for some minutes before allowing them to be delivered. As most spammers will not resend their messages, you will not receive them. If you want a more technical description, scroll down to read a greylisting description.
- DNSBL
- As of hermes 1.2 you can now configure hermes to reject emails coming from ips listed on your favourite DNSBL, using the rbl_domain option.
How does it work?
SMTP banner delay
When a client connects to a SMTP server, the first thing that happens is that the server shows a line like the following:
220 ns1.iteisa.com ESMTPThis line, in its most basic form, informs the client of three things:
- Is the server ready to start a connection?. To do that it sends a code, in this case "220".
- The server name is ns1.iteisa.com
- This particular server implements the enhanced version of SMTP, ESMTP
Of course, if you are a spammer, you don't care wether it's SMTP or ESMTP, and you will just start the connection without waiting for this line.
So what we have done is to simply delay this line for a few seconds, and before printing it, check wether the client has started the communication. If it has, we simply drop the connection, as it is certainly a spammer.
Throttling
Spammers are always trying to send their spam as fast as posible, and usually have a limit on how much time they want to spend to send an email.
What we do is just insert a small delay between each command, making the connection much slower, so an impatient spammer will simply give up. If they don't give up, they have spent more time sending your spam, so they have less time to spend sending other spam, either to you or other people.
Example of a normal SMTP connection
220 ns1.iteisa.com ESMTP EHLO [127.0.0.1] 250-ns1.iteisa.com 250-AUTH=LOGIN CRAM-MD5 250-AUTH LOGIN CRAM-MD5 250-STARTTLS 250 8BITMIME MAIL FROM: xxxx@xxx.xx 250 ok RCPT TO: yyyy@yyy.yy 250 ok DATA 354 go ahead From: xxxx@xxx.xx To: yyyy@yy.yy Subject: Stuff <mail-contents> . 250 ok 1174992091 qp 12536 QUIT 221 ns1.iteisa.com
Example connection with throttling
220 ns1.iteisa.com ESMTP EHLO [127.0.0.1] <1 second delay> 250-ns1.iteisa.com 250-AUTH=LOGIN CRAM-MD5 250-AUTH LOGIN CRAM-MD5 250-STARTTLS 250 8BITMIME MAIL FROM: xxxx@xxx.xx <1 second delay> 250 ok RCPT TO: yyyy@yyy.yy <1 second delay> 250 ok DATA <1 second delay> 354 go ahead From: xxxx@xxx.xx To: yyyy@yy.yy Subject: Stuff <mail-contents> . <1 second delay> 250 ok 1174992091 qp 12536 QUIT <1 second delay> 221 ns1.iteisa.comIf this connection came from a spammer, somewhere on the middle of the communication, they will simply drop the connection and move on to spamming other accounts.
Greylisting
SMTP has a way of telling clients "I can't receive your email right now, can you try later?". To do so, it uses temporary error codes (of the form 4xx). Examples of this include (but are not limited to), 450 (mailbox busy), 452 (insufficient space on disk) and 421 (service not available).
hermes implements a technique know as greylisting, where the server will answer with a temporary error in the first try to deliver a message. If the connection was from a spammer, they will probably NOT retry it, as that would be too much work for their systems. As a result, hermes will effectively stop those spam emails.
Example of a greylisting session:
220 ns1.iteisa.com ESMTP EHLO [127.0.0.1] 250-ns1.iteisa.com 250-AUTH=LOGIN CRAM-MD5 250-AUTH LOGIN CRAM-MD5 250-STARTTLS 250 8BITMIME MAIL FROM: xxxx@xxx.xx 250 ok RCPT TO: yyyy@yyy.yy 421 Greylisted!! Please try again in a few minutes
On the second try, hermes will recognize the sender and will allow the mail to go through without any problem. To do this, hermes keeps track of three things, known as a triplet, that consist of the following things:
- IP of the sending computer
- The IP of the server that is sending the email.
- From address
- The email address of the person sending you the email
- To addres
- The email address of the person receiving the email
To make it simple, this means:
- you will not receive (most) spam
- someone emailing you the first time will get a few minutes delay
- the next time they write to you, they will get to you instantly