{"id":30091,"date":"2021-01-18T03:10:16","date_gmt":"2021-01-17T19:10:16","guid":{"rendered":"https:\/\/web.mwwsb.com.my\/pjci\/?post_type=kb&p=30091"},"modified":"2022-09-08T21:36:30","modified_gmt":"2022-09-08T13:36:30","slug":"check-server-hack-and-exim-spamming","status":"publish","type":"kb","link":"https:\/\/www.casbay.com\/guide\/kb\/check-server-hack-and-exim-spamming","title":{"rendered":"Check Server hack and exim spamming"},"content":{"rendered":"\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t

Check Server hack and exim spamming<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t

This will probably help you to find out the IP which tried the malpractices in a server to get compromised. First, we can try to find the IP which I need to monitor:<\/p>

  1. This netstat script will list out the number of connections made by an IP

    netstat -ntu | awk \u2018{print $5}\u2019 | cut -d: -f1 | sort | uniq -c | sort -n

    <\/strong><\/li>
  2. Now you got the IP then you check it out in

    a. \/var\/log\/messages

    <\/strong>b. \/var\/log\/secure

    <\/strong>cat \/var\/log\/messages | grep ip | awk \u2018{print$5}\u2019 | cut -d: -f1 | uniq -c |sort -n

    <\/strong>grep \u201cunauthorised attempt\u201d \/var\/log\/messages | awk \u2018{print$5}\u2019 |cut -d: -f1 | uniq -c | sort -n

    <\/strong>grep \u201cunauthorised attempt\u201d \/var\/log\/secure | awk \u2018{print$5}\u2019 |cut -d: -f1 | uniq -c | sort -n

    <\/strong>Note :- In {print$5} value may change it can become 7, 8, 11, 12 etc \u2026. eg:- {print$7}<\/li><\/ol>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t

    Exim Commands<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t

    To view the mail queue:<\/p>

    exim -bp<\/strong><\/p>

    Number of mail in the queue:<\/p>

    exim -bpc<\/strong><\/p>

    To open a mail:<\/p>

    exim -Mvh<\/strong><\/p>

    The number of emails in the queue:<\/p>

    im -bpr | grep \u201c<\u201d | wc -l<\/strong><\/p>

    How many Frozen mails on the queue:<\/p>

    \/usr\/sbin\/exim -bpr | grep frozen | wc -l<\/strong><\/p>

    Deleting Frozen Messages:<\/p>

    \/usr\/sbin\/exim -bpr | grep frozen | awk {\u2018print $3\u2032} | xargs exim -Mrm<\/strong><\/p>

    To know the number of frozen mails in the mail queue, you can use the following command<\/p>

    exim -bpr | grep frozen | wc -l<\/strong><\/p>

    In order to remove all frozen emails from the Exim mail queue, use the following command<\/p>

    exim -bpr | grep frozen | awk {\u2018print $3\u2032} | xargs exim -Mrm<\/strong><\/p>

    You can also use the command given below to delete all frozen mails<\/p>

    exiqgrep -z -i | xargs exim -Mrm<\/strong><\/p>

    To flush the exim queue<\/p>

    exim -qff<\/strong><\/p>

    Base64 injection scripts<\/p>

    We can use this script to find out the PHP script<\/p>

    grep \u201cauthentication failure\u201d \/var\/log\/secure | awk \u2018{ print $3}\u2019 | cut -b7- | sort | uniq -c<\/strong><\/p>

    find \/var\/www\/vhosts\/ -name \u201c*.php\u201d | xargs -I{} sed -i \u2018\/<?php eval(gzinflate(base64_decode(\/d\u2019 {};\u00a0<\/strong><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t

    \n\t\t\t\t
    \n\t\t\t

    How to Find the spammer spamming from home directory<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t

    The spammer may use his home directory for spamming we can use a script to locate the top scripts on your server that send out the email. Then you can search the Exim mail log for those scripts to determine if it looks like spam, and even check your Apache access logs in order to find how a spammer might be using your scripts to send out spam.<\/p>

    og | grep -v \/var\/spool | awk -F\u201dcwd=\u201d \u2018{print $2}\u2019 | awk \u2018{print $1}\u2019 | sort | uniq -c | sort -n<\/strong><\/p>

    To find suspicious IP activities<\/strong><\/p>

    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013<\/p>

    This will list the entries for the IP Address in question ( replace ip.add.re.ss with the suspicious IP address )<\/p>

    find \/var\/log\/ -exec grep \u201cip.add.re.ss\u201d \u2018{}\u2019 ; -print<\/strong><\/p>

    This script will provide you top 10 IP addresses that hit your apache access log<\/p>

    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013<\/p>

    cat \/var\/log\/httpd\/access_log |awk \u2018{print $1}\u2019|cut -d? -f1|sort -n|uniq -c|sort -n|tail -10<\/strong><\/p>

    This script will list the ten most accessed files on your site<\/p>

    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>

    This script will Sort files and display the number of times that file was accessed<\/p>

    cat \/var\/log\/httpd\/access_log |awk \u2018{print $7}\u2019|cut -d? -f1|sort -n|uniq -c|sort -n| tail -10<\/b><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t

    \n\t\t\t\t
    \n\t\t\t\t\t\t\t

    We hope this article helped you to learn how to check server hack and exim spamming. For more articles, please go to Knowledge Base<\/a>.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"

    Check Server hack and exim spamming This will probably help you to find out the IP which tried the malpractices in a server to get compromised. First, we can try to find the IP which I need to monitor: This netstat script will list out the number of connections made by an IPnetstat -ntu | […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}}},"kbtopic":[117,113],"kbtag":[106],"mkb_version":[],"_links":{"self":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30091"}],"collection":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/comments?post=30091"}],"version-history":[{"count":2,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30091\/revisions"}],"predecessor-version":[{"id":36542,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30091\/revisions\/36542"}],"wp:attachment":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/media?parent=30091"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=30091"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtag?post=30091"},{"taxonomy":"mkb_version","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/mkb_version?post=30091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}