trickle of unatuhorized email being sent from local

sjwrick

Member
Jan 9, 2014
8
1
3
cPanel Access Level
Root Administrator
How can I tell which process is sending out emails?
I am seeing bouncebacks and the email is being sent out by the main cPanel user (established when hosting account was created)

The server is starting to get listed in a RBL

Thanks Rick

*********************************************

from the log /var/log/exim_mainlog

cwd=/home/**user**/public_html 5 args: /usr/sbin/sendmail -t -i -f [email protected]**domain**.com


These are sending out emails from random addresses all [email protected]

aValidName = not a vaild user on the system - just a readable name.
- = a hyphen
linuxtimestamp = if you covert the seemingly random number it is a time stamp of when the email was sent.
**domain* = the same domain each time.

I know the domain in question.
These are not smtp incoming emails they are generated by a process on the server as reflected in the mail headers.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello :)

The message logs you provided show that mail is coming from:

/home/$username/public_html

Check that directory for scripts with the ability to send out email.

Thank you.
 

cPanelPeter

Senior Technical Analyst
Staff member
Sep 23, 2013
585
25
153
cPanel Access Level
Root Administrator
Hello,

I would search the public_html folder for the mail() function...

Code:
# grep -r 'mail(' *
I'm betting some PHP script or plugin for WordPress/Joomla or other CMS software is poorly written and sending spam out.
 

quizknows

Well-Known Member
Oct 20, 2009
1,008
87
78
cPanel Access Level
DataCenter Provider
Grepping recursively for the PHP mail function is a crap chute.

First, check output from ps faux for any suspect PID's running as that user.

Second, take the exact timestamp from one of the messages in exim mainlog, and try to match that up to the exact same time in the domains access logs. This is a much better way to search for spam from scripts.

If that still leaves you scratching your head, clamav or maldet might find the script(s) if there is a malicious PHP mailer. Sometimes mail is sent from legitimate files (such as a "tell a friend" feature), so virus scanners won't find that.

last ditch effort would be checking crontab or possibly grepping for the php mail function, but a lot of spam scripts just use an eval or exec call, or encoded code that will avoid being found with that grep command. You're almost better off looking for base64() calls instead of mail().
 
Last edited: