Implement Spam Mail
Filtration inside Linux kernel
Jeff Rupp and Frank Watson
Spam Mail Filter
Jeff Rupp & Frank Watson
Our original goals:
To figure out how User Mode Linux works
To modify the kernel to filter out spam mail and send the
appropriate packets to both the receiver and server.
Then to make further modifications to send information
packets to the sender to see if the user and sender existed
(which is common for spammer)
Sends mail
Checks to see if sender exists
Modified proposal: getting the User Mode Linux (UML) to
work and modify the Linux source to change the user name to
all x’s if the sender is on a spam list.
Spam Mail Filter
Jeff Rupp & Frank Watson
What is User Mode Linux?
User-Mode Linux is a virtual machine that runs
entirely inside a single file on the physical machine. It
has internet,and xwindow support and allows users to
install and test applications on this virtual machine
Two main advantages of using UML are:
If the kernel crashes because of test applications or kernel
modifications, the machine does not go with it.
Has a very handy debugger that allows you to debug the
actual linux kernel.
A good three-fifths of our time was spent on this
project trying to get UML to work. This was not a
trivial process.
Spam Mail Filter
Jeff Rupp & Frank Watson
How to install UML
1.Download 3 main files
Kernel source code, UML kernel patch, and Root file system
Unpack the kernel, Apply the UML patch, and Build the "linux“
executable from the linux source
3.Running UML
execute uml with the following command line:
“ linux mem=128M udb=root_fs_slackware_7.0_big udb2=swap
debug=go eth0=ethertap,tap0,fd:fe:0:0:0:1,<IP address # 1>
4.Setting up the internet connection
Use the following commands:
•Ifconfig eth0 <IP address 2>
•Route del –net dev eth0 netmask
•Route add –host <IP of host machine> dev eth0
•Route add default gw <IP of host machine>
Spam Mail Filter
Jeff Rupp & Frank Watson
How UML works
• UML is composed of two major pieces. A root_fs (a
root file system) and a linux executable.
• The linux executable is the linux kernel. The kernel
information on the root_fs is not used for booting, so
it is possible to boot a root_fs (made with Redhat 7.1
and a 2.4.3 kernel) with a UML linux exectuable
which boots the kernel into 2.4.7.
• The internet access is achieved by using a driver
called ethertap. Ethertap is an older driver and
intercepts packets at the ethernet card and sends
them up to the UML code
Spam Mail Filter
Jeff Rupp & Frank Watson
Source Code Modifications
• Checks to see if the packet is for port 25 by checking sk->num
TCP (port #)
• We look for two things in the pay load, text stating “MAIL
FROM:” (case insensitive) sets the flag wasMailfrom and “RCPT
TO:” sets the flag wasRcpt using if statements.
TCP (port #) Payload
Spam Mail Filter
Jeff Rupp & Frank Watson
Source Code Modifications
• If either flag is set, a pointer searches the payload to find the
start of the name.
TCP (port #) Payload
Searches for the email user name
• If the MAILfrom flag is set, it searches to see if it is on the spam
sender’s list. If so, the code waits for the RCPT TO: in the
packet and replaces the RCPT TO: with x’s. For example:
would become
Spam Mail Filter
does not exist
Jeff Rupp & Frank Watson
• Have a working prototype which catches a spammer and changes
the “RCPT TO:” field in the SMTP protocol to an unknown address.
• Below is a sample of an email returned to the user:
----- The following addresses had permanent fatal errors -----<root@feline.uccs.edu>
(reason: 550 <xxxx@feline.uccs.edu>... User unknown)
• Known bug: the sender’s mail server keeps a cache of the email
addresses and on occasion does not send a “RCPT TO:” in the
payload to see if the user exists. In these situations, the mail does
go through and is not modified or blocked.
Spam Mail Filter
Jeff Rupp & Frank Watson
Conclusion/Future work
• Because of time constrains, we only touched the surface of what
can be done with routing and manipulating packets at the TCP
level. This project is just a simple demonstration of the power
and changeability of the linux kernel to suite to a specific need
and purpose.
• In the future, a packet can be sent back and fully responds to
the SMTP command of the receiver and sender.
• The spam list can be inserted through a module oppose to hard
coded into the kernel (as for this project).
• This project can be integrated into UCCS’ Linux Content Switch
and be used as a front end switch, filtering unwanted spam
mails before the mails even hit the back end servers.
Spam Mail Filter
Jeff Rupp & Frank Watson
• http://user-mode-linux.sourceforge.org The user mode linux
• http://www.linux-mag.com/2001-04/user_mode_01.html An
extremely helpful article about setting up UML with a step by
step example
• http://www.linuxfromscratch.org A comprehensive webpage
about setting up a linux kernel from scratch. This webpage
helped with setting up the networking files.
• http://kernelnewbies.org/documents/ipnetworking/linuxipnetworki
ng.html An extremely valuable document about the linux IP
networking layer
• http://www.faqs.org/rfcs/rfc821.html The RFC 821 for the SMTP
Spam Mail Filter
Jeff Rupp & Frank Watson