3

I work for an ISP in Australia. Recently a users account has been comprimised and is sending spam. How can I read the contents of a mail item in the mailq to find the authenticated user which has been comprimised. I know how to do this in Postfix but have had no luck in finding a way to do it in sendmail. Running CentOS.

Thanks in advanced. Struggling Network Operator.

Khan McDonald
  • 31
  • 1
  • 1
  • 2
  • Your logs will tell you where the mail is coming from. – womble Aug 20 '15 at 01:07
  • Yeah I could use the logs but there's around 500-1000 emails per second. There has to be a way to read a qf or df file referencing the ID? – Khan McDonald Aug 20 '15 at 03:08
  • Typically most emails (>95%) are delivered in a few seconds. It makes scanning log files a better option than scan "not yet delivered" messages in sendmail queue. Anyway I would suggest solution for "next time" too. – AnFi Aug 20 '15 at 06:52

1 Answers1

2

Sendmail will save the message in the queue for safe keeping before trying to get the message delivered. The command to manipulate the queue is mailq.

By design the queue is very transient and typically in cases like this you should rely on your log files, which also contains information about messages that are already delivered and no longer can be found in the queue, rather than scanning the few messages that are/remain in the queue.

(If your maillog currently does not quite contain the information you need this answer may be of interest. for future reference)

Each message in the queu is stored in the directory /var/spool/clientmqueue and mqueue as a couple of files which are named thus: first letter for "type and status", second letter is "f", rest is the sendmail queue ID that you see in the logs and mailq output.

The first letter is usually one of :

d the body of the mail

q the message envelope with routing information and headers when the message is normal

Q rename of the "q" file when the message is abandoned for some reason

h rename of the "q" file when the message is held (quarantined by a milter)

t temporary file

x transcript of delivery attempts

If you're looking for authentication information: The qf file is structured as a series of lines, each beginning with a purpose code letter with the A containing the information given by the AUTH= parameter of the "MAIL FROM:" command or $f@$j if sendmail has been called directly.
Some more on the make up of the other fields in the qf file here.

So grep ^A /var/spool/mqueu/qf* will list the authenticated senders.

HBruijn
  • 77,029
  • 24
  • 135
  • 201