• DevOps
    Case Study

    How we built a resilient multi-account, multi-cloud solution for a Health Tech service provider!

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How we built a scalable Odoo solution for a Travel Tech service provider!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    How we built a scalable Odoo solution for TravelTech service provider!

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Contact Us

Connect with us!


LinkedInFacebookXInstagramYouTube

aws partneraws advanced partner
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

Spamming: A handbook for admins

Sreejith K R

  • 6 min read
Spamming: A handbook for admins

Generating audio, please wait...

We are here discussing different commands which can be used in find spamming in an Exim mail server,

1. Hourly count of sent mail for a domain, by specifying the domain and date.

DOMAIN='<DOMAIN>';DATE='YYYY-MM-DD';o1=`for i in $(grep $DOMAIN /var/log/exim_mainlog|grep $DATE|egrep "A=fixed|A=<LOGIN>"|awk {'print $4'}|sort|uniq);do grep $i /var/log/exim_mainlog;done|grep -v "retry time not reached for any host"`;unset DOMAIN;unset DATE;o2=`echo "$o1"|awk {'print $2'}|cut -d: -f1|sort| uniq -c`;echo " COUNT HOUR";echo "$o2";unset o1;unset o2;

DOMAIN : domain.com without www

YYYY-MM-DD : Date like 2011-11-03

LOGIN : dovecot_login / courier_login

Replace all instances of above terms with appropriate values from now on.

2. How many emails have been sent per email address for the specified domain.

grep somedomain.com /var/log/exim_mainlog | grep courier_login | awk -F"courier_login:" '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -n

3. Show how many emails have been sent from ALL domains since the beginning of the log.

cat /var/log/exim_mainlog | grep "A\=<LOGIN>" | awk -F"A=<LOGIN>:" {'print $2'} | cut -f1 -d' ' | sort | uniq -c | sort -n | awk {'print $1, " unique emails sent by " , $2'}

 4. Delete mail in queue from a certain user.


for i in $(exim -bp|grep [email protected]|grep -|grep @|awk {'print $3'});do exim -Mrm $i;done

 5. Find the source path if from address is being forged.

echo -ne “What cpanel user: “; read p; cat /var/log/exim_mainlog | grep cwd | grep -v /var/spool | awk -F”cwd=” ‘{print $2}’ | awk ‘{print $1}’ | sort | uniq -c | sort -n | grep $p

6. Find the files that sends mail via phpMail.

find ./ -name \*.php -exec grep -l "mail(" {} \;

7. Show user and number of connections to IMAP.

ps -ef |grep imap | awk ‘{print $1}’ | sort | uniq -c | sort -g -k 1 | tail

8. Fix Shadow file permission.

If the user receives mail, but can not send and all settings are correct

find /home/<user>/etc -type f -name shadow -exec chmod 644 {} \;

9. Show the number of failed logins per IP (Check if the user is being brute forced).

grep FAILED /var/log/maillog |awk ‘{print $9}’ |sort -n|uniq -c |sort -n |tail -7

10. Shows number of failed logins, the IP doing the failing, and how many different users were attempted to be logged into:

awk -F”ffff:” ‘/FAILED/ {IP[$NF]++;}END{ for ( host in IP ) print IP[host]” “host}’ /var/log/maillog | awk ‘{ if ( $1 &gt; 99 ) print $0}’ | sort -nk1 | sed ‘s#]##’ > IPS; for IP in `awk ‘{print $2}’ IPS`; do echo -n $(grep $IP IPS); echo -n ” – Failed users: “; grep $IP /var/log/maillog | awk -F”user=” ‘/FAILED/ {print $2}’ | cut -d, -f1 | sort | uniq | wc -l; done

Will show something like:

135 50.75.12.41 – Failed users: 3

11. Show all the emails in queue by domain.

exim -bp | /usr/sbin/exiqsumm

12. Show you all the emails in queue by email account

exim -bp|awk 'NF>1{print $4}' | sort | uniq -c |sort -nk1

13. Force delivery of one message

exim -M <messageID>

14. View the log for the message.

exim -Mvl <messageID>

15. View the header of the message

exim -Mvh <messageID>

16. View the body of the message

exim -Mvb <messageID>

17. Remove message without sending any error message.

exim -Mrm <messageID>

18. Number of frozen mails in the queue

exim -bpr | grep frozen | wc -l

19. Deleting frozen Messages

exim -bpr | grep frozen | awk {'print $3'} | xargs exim -Mrm

OR

exiqgrep -z -i | xargs exim -Mrm

20. Check to see how many emails are in queue for domain.com, run the following:

exim -bp | grep ‘domain.com>’

Make sure the ‘>‘ is in there because that character appears in the sending field. If you don’t, then it will show you the to and from results.

21. Top 50 domains using mail server sorted by different criteria.

eximstats -ne -nr /var/log/exim_mainlog

22. Show the IPs which are connected to server through port number 25.

netstat -plan | grep :25 | awk {‘print $5′} | cut -d: -f 1 | sort | uniq -c | sort -nk 1

23. Find “nobody” spamming (Only works when the spamming is going on).

ps -C exim -fH ewww | awk ‘{for(i=1;i&lt;=40;i++){print $i}}’ | sort | uniq -c | grep PWD | sort -n

It will give some result like:
Example :
6 PWD=/
347 PWD=/home/sample/public_html/test
Count the PWD and if it is a large value check the files in the directory listed in PWD
(Ignore if it is / or /var/spool/mail /var/spool/exim)

24. Remove all mails from ‘<>’

exim -bp | grep “<>” | awk ‘{print $3}’ | xargs exim -Mrm

Get 24/7 expert server management

  • cPanel
  • Howtos
  • Linux
  • Troubleshooting
Spamming: A handbook for admins

CentOS: Adding static IP/ IP range

CentOS:  Adding static IP/ IP range
  • General
  • Howtos
  • Linux
  • Troubleshooting
logo

How To Setup Account-Level Filter on cPanel Servers

How To Setup  Account-Level Filter on cPanel Servers
  • cPanel
  • Howtos
  • Troubleshooting
logo

rm -f *: “Argument List too long”

rm -f *:  “Argument List too long”
  • General
  • Howtos
  • Linux
  • Troubleshooting
logo

Steps to enable auto-negotiation for your NIC

Steps to enable auto-negotiation for your NIC
  • Linux
logo

Posts by Sreejith K R

Sreejith is an early adopter of upcoming technologies and has got immense interest on exploring its features for improving productivity. He is quite proficient in various scripting languages and loves to enhance work flow through development of various automation scripts. He is video game junkie and is a perfect choice for the position of a game tester :-)