{"id":1106,"date":"2013-09-10T01:16:27","date_gmt":"2013-09-10T07:16:27","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=1106"},"modified":"2019-10-30T04:27:08","modified_gmt":"2019-10-30T10:27:08","slug":"spamming-in-a-qmail-enabled-plesk-server-finding-the-culprit","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/spamming-in-a-qmail-enabled-plesk-server-finding-the-culprit\/","title":{"rendered":"Spamming in a Qmail Enabled Plesk Server &#8211; Finding the Culprit"},"content":{"rendered":"<p>The following is the result of a live analysis done when spamming has been found from a <a href=\"https:\/\/www.supportpro.com\/blog\/qmail-a-brief-introduction\/\">Plesk<\/a> server with the <a href=\"https:\/\/www.supportpro.com\/blog\/cpanel-vs-plesk\/\">qmail<\/a> mail server. This will help you to understand how to trace a qmail spamming in the server.<\/p>\n<blockquote><p>[root@server ~]# \/var\/qmail\/bin\/qmail-qstat<\/p>\n<p>messages in queue: 758<\/p>\n<p>messages in queue but not yet preprocessed: 0<\/p><\/blockquote>\n<p>We do have 758 mails in the queue. Let&#8217;s examine the queue with qmail-qread. Seeing a bunch of strange email addresses in the recipient list? Usually, it is meaning spam.<\/p>\n<p><!--more--><\/p>\n<blockquote><p>[root@server ~]# \/var\/qmail\/bin\/qmail-qread<\/p>\n<p>[&#8230;]<\/p><\/blockquote>\n<p>You can examine the email content of the emails in the queue using the Plesk interface or just less command. Firstly we should find messages id using qmail-qread, then find the file holding the email in \/var\/qmail\/queue with the find command.<\/p>\n<blockquote><p>[root@server ~]# \/var\/qmail\/bin\/qmail-qread<\/p>\n<p>[&#8230;]<\/p>\n<p>18 Jul 2008 02:01:11 GMT #22094026 1552 &lt;&gt;<\/p>\n<p>remote user@yahoo.com<\/p>\n<p>[&#8230;]<\/p>\n<p>[root@server ~]# find \/var\/qmail\/queue\/ -name 22094026<\/p><\/blockquote>\n<p>\/var\/qmail\/queue\/mess\/19\/22094026<\/p>\n<p>\/var\/qmail\/queue\/remote\/19\/22094026<\/p>\n<p>\/var\/qmail\/queue\/info\/19\/22094026<\/p>\n<blockquote><p>[root@server ~]# less \/var\/qmail\/queue\/mess\/19\/22094026<\/p><\/blockquote>\n<p>Received: (qmail 10728 invoked from network); 22 Jul 2008 19:40:46 +0300<\/p>\n<p>Received: from unknown (HELO User) (86.107.221.138)<\/p>\n<p>by domain.com with SMTP; 22 Jul 2008 19:40:46 +0300<\/p>\n<p>Reply-To: &lt;support@PayPal.Inc.com&gt;<\/p>\n<p>From: &#8220;PayPal&#8221;&lt;support@PayPal.Inc.com&gt;<\/p>\n<p>Subject: Dispute Transaction<\/p>\n<p>Date: Tue, 22 Jul 2008 19:40:52 +0300<\/p>\n<p>MIME-Version: 1.0<\/p>\n<p>Content-Type: text\/html;<\/p>\n<p>charset=&#8221;Windows-1251&#8221;<\/p>\n<p>Content-Transfer-Encoding: 7bit<\/p>\n<p>X-Priority: 1<\/p>\n<p>X-MSMail-Priority: High<\/p>\n<p>X-Mailer: Microsoft Outlook Express 6.00.2600.0000<\/p>\n<p>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000<\/p>\n<p>[&#8230;]<\/p>\n<p>Oops, we do have some spam in the queue that&#8217;s received from the network (IP: 86.107.221.138). We should remove spam from the queue or the server IP address will finish listed in the RBLs, qmail-remove is the right tool for this job.<\/p>\n<p>Check the number of the spams with the spam pattern (PayPal.Inc.com in this case):<\/p>\n<blockquote><p>[root@server ~]# qmail-remove -p &#8216;PayPal.Inc.com&#8217;<\/p><\/blockquote>\n<p>Now, remove spams (notice the -r switch), they all will end up in the \/var\/qmail\/queue\/yanked directory. Don&#8217;t forget to stop qmail daemon before (\/etc\/init.d\/qmail stop).<\/p>\n<blockquote><p>[root@server ~]# qmail-remove -r -p &#8216;PayPal.Inc.com&#8217;<\/p><\/blockquote>\n<p>In a few minutes, we do have more emails with the same patterns from the same IP address.<\/p>\n<p>That&#8217;s great, we do have the opportunity to examine SMTP traffic from the spammers IP address. Run tcpdump and wait a few minutes.<\/p>\n<blockquote><p>[root@server ~]# tcpdump -i eth0 -n src 86.107.221.138 \\or dst 86.107.221.138 -w smtp.tcpdump -s 2048<\/p><\/blockquote>\n<p>Examining log file with less or wireshark we found that spammer is sending spam using LOGIN authentication:<\/p>\n<p>220 server.domain.com ESMTP<\/p>\n<p>ehlo User<\/p>\n<p>250-server.domain.com<\/p>\n<p>250-AUTH=LOGIN CRAM-MD5 PLAIN<\/p>\n<p>250-AUTH LOGIN CRAM-MD5 PLAIN<\/p>\n<p>250-STARTTLS<\/p>\n<p>250-PIPELINING<\/p>\n<p>250 8BITMIME<\/p>\n<p>AUTH LOGIN<\/p>\n<p>334 VXNlcm5hbWU6<\/p>\n<p>dGVzdA==<\/p>\n<p>334 UGFzc3dvcmQ6<\/p>\n<p>MTIzNDU=<\/p>\n<p>235<\/p>\n<p>Interesting, let us decode the user\/pass to see which account is used:<\/p>\n<blockquote><p>[root@server ~]# perl -MMIME::Base64 -e &#8216;print decode_base64(&#8220;dGVzdA==&#8221;)&#8217;<\/p><\/blockquote>\n<p>test<\/p>\n<blockquote><p>[root@server ~]# perl -MMIME::Base64 -e &#8216;print decode_base64(&#8220;MTIzNDU=&#8221;)&#8217;<\/p><\/blockquote>\n<p>12345<\/p>\n<p>So, someone created a test account with a weak password and someone else guessed it and is sending spam through the server.<\/p>\n<p>Let us find the domain owning of the mailbox.<\/p>\n<blockquote><p>[root@server ~]# mysql -uadmin -p`cat \/etc\/psa\/.psa.shadow` psa<\/p><\/blockquote>\n<p>[&#8230;]<\/p>\n<p>mysql&gt; SELECT m.mail_name, d.name, a.password FROM mail AS m LEFT JOIN (domains AS d, accounts AS a) ON (m.dom_id = d.id AND m.account_id = a.id) WHERE m.mail_name=&#8217;test&#8217; AND a.password=&#8217;12345&#8242;;<\/p>\n<p>+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+<\/p>\n<p>| mail_name | name | password |<\/p>\n<p>+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+<\/p>\n<p>| test | example.com | 12345 |<\/p>\n<p>+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+<\/p>\n<p>1 row in set (0.01 sec)<\/p>\n<p>Next step is to delete test mailbox and send a warning to the client.<\/p>\n<p>To improve your server&#8217;s security you&#8217;ll need to enable:<\/p>\n<p>Server -&gt; Mail -&gt; Check the passwords for mailboxes in the dictionary<\/p>\n<p>Creating a mailbox test with password &#8220;12345&#8221; is a stupid thing and spammers just love to exploit it.<br \/>\nIf you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><\/p>\n<p style=\"text-align: center;\"><!--HubSpot Call-to-Action Code --><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><!-- [if lte IE 8]><\/p>\n\n\n\n\n\n<div id=\"hs-cta-ie-element\"><\/div>\n\n\n<![endif]--><a href=\"https:\/\/www.supportpro.com\/requestquote.php\"><img decoding=\"async\" id=\"hs-cta-img-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-img\" style=\"border-width: 0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b.png\" alt=\"Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value\" \/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '9d590242-d641-4383-94b4-8cfd62f0af6b', {}); <\/script><\/span><!-- end HubSpot Call-to-Action Code --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following is the result of a live analysis done when spamming has been found from a Plesk server with the qmail mail server. This will help you to understand&hellip;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1106","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":11,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"predecessor-version":[{"id":4142,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1106\/revisions\/4142"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}