{"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&#038;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<div data-elementor-type=\"wp-post\" data-elementor-id=\"30091\" class=\"elementor elementor-30091\" data-elementor-post-type=\"kb\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-cc946a8 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"cc946a8\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-979c54f\" data-id=\"979c54f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0cebeb7 elementor-widget elementor-widget-heading\" data-id=\"0cebeb7\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Check Server hack and exim spamming<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ec5d171 elementor-widget elementor-widget-text-editor\" data-id=\"ec5d171\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>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><ol><li>This netstat script will list out the number of connections made by an IP<br \/><br \/><strong>netstat -ntu | awk \u2018{print $5}\u2019 | cut -d: -f1 | sort | uniq -c | sort -n<br \/><br \/><\/strong><\/li><li>Now you got the IP then you check it out in<br \/><br \/><strong style=\"font-size: 16px;\">a. \/var\/log\/messages<br \/><br \/><\/strong><strong style=\"font-size: 16px;\">b. \/var\/log\/secure<br \/><br \/><\/strong><strong style=\"font-size: 16px;\">cat \/var\/log\/messages | grep ip | awk \u2018{print$5}\u2019 | cut -d: -f1 | uniq -c |sort -n<br \/><br \/><\/strong><strong style=\"font-size: 16px;\">grep \u201cunauthorised attempt\u201d \/var\/log\/messages | awk \u2018{print$5}\u2019 |cut -d: -f1 | uniq -c | sort -n<br \/><br \/><\/strong><strong style=\"font-size: 16px;\">grep \u201cunauthorised attempt\u201d \/var\/log\/secure | awk \u2018{print$5}\u2019 |cut -d: -f1 | uniq -c | sort -n<br \/><br \/><\/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<div class=\"elementor-element elementor-element-b31c4f7 elementor-widget elementor-widget-heading\" data-id=\"b31c4f7\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Exim Commands<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-166cb6d elementor-widget elementor-widget-text-editor\" data-id=\"166cb6d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>To view the mail queue:<\/p><p><strong>exim -bp<\/strong><\/p><p>Number of mail in the queue:<\/p><p><strong>exim -bpc<\/strong><\/p><p>To open a mail:<\/p><p><strong>exim -Mvh<\/strong><\/p><p>The number of emails in the queue:<\/p><p><strong>im -bpr | grep \u201c&lt;\u201d | wc -l<\/strong><\/p><p>How many Frozen mails on the queue:<\/p><p><strong>\/usr\/sbin\/exim -bpr | grep frozen | wc -l<\/strong><\/p><p>Deleting Frozen Messages:<\/p><p><strong>\/usr\/sbin\/exim -bpr | grep frozen | awk {\u2018print $3\u2032} | xargs exim -Mrm<\/strong><\/p><p>To know the number of frozen mails in the mail queue, you can use the following command<\/p><p><strong>exim -bpr | grep frozen | wc -l<\/strong><\/p><p>In order to remove all frozen emails from the Exim mail queue, use the following command<\/p><p><strong>exim -bpr | grep frozen | awk {\u2018print $3\u2032} | xargs exim -Mrm<\/strong><\/p><p>You can also use the command given below to delete all frozen mails<\/p><p><strong>exiqgrep -z -i | xargs exim -Mrm<\/strong><\/p><p>To flush the exim queue<\/p><p><strong>exim -qff<\/strong><\/p><p>Base64 injection scripts<\/p><p>We can use this script to find out the PHP script<\/p><p><strong>grep \u201cauthentication failure\u201d \/var\/log\/secure | awk \u2018{ print $3}\u2019 | cut -b7- | sort | uniq -c<\/strong><\/p><p><strong style=\"size: 16px;\">find \/var\/www\/vhosts\/ -name \u201c*.php\u201d | xargs -I{} sed -i \u2018\/&lt;?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<div class=\"elementor-element elementor-element-9ddb48d elementor-widget elementor-widget-heading\" data-id=\"9ddb48d\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">How to Find the spammer spamming from home directory<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5c36a26 elementor-widget elementor-widget-text-editor\" data-id=\"5c36a26\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>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><p><strong>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><p><strong>To find suspicious IP activities<\/strong><\/p><p>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013<\/p><p>This will list the entries for the IP Address in question ( replace ip.add.re.ss with the suspicious IP address )<\/p><p><strong>find \/var\/log\/ -exec grep \u201cip.add.re.ss\u201d \u2018{}\u2019 ; -print<\/strong><\/p><p>This script will provide you top 10 IP addresses that hit your apache access log<\/p><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><p><strong>cat \/var\/log\/httpd\/access_log |awk \u2018{print $1}\u2019|cut -d? -f1|sort -n|uniq -c|sort -n|tail -10<\/strong><\/p><p>This script will list the ten most accessed files on your site<\/p><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><p>This script will Sort files and display the number of times that file was accessed<\/p><p><b>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<div class=\"elementor-element elementor-element-e38f80a elementor-widget elementor-widget-text-editor\" data-id=\"e38f80a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>We hope this article helped you to learn how to check server hack and exim spamming. For more articles, please go to <a href=\"https:\/\/www.casbay.com.my\/guide\/\">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":"<p>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 | [&hellip;]<\/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}]}}