Xylitol

Email_PHP_Mailer.yar

May 10th, 2020
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.34 KB | None | 0 0
  1. /*
  2.     This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or
  3.     organization, as long as you use it under this license.
  4. */
  5. rule Email_Generic_PHP_Mailer_Script
  6. {
  7.     meta:
  8.         Description ="Generic rule to identify potential emails sent from hacktool mailer scripts"
  9.         Author = "Xylitol <[email protected]>"
  10.         date = "2020-05-11"
  11.         // Attempt at getting live urls of HackTool.PHP.SpyMail (kav),
  12.         // Script.Trojan.PHPMailer (gdata), Trojan.PHP.Mailar (Ikarus)
  13.         // This Yara rule is meant to be run against .eml files
  14.         // May only the challenge guide you
  15.     strings:
  16.  
  17.         // Files, part of php package who can trigger the rules
  18.         // we don't want that if we scan a mixed batch of files.
  19.         $donotwant1 = { FE ED FA CE } // Mach-O binary (32-bit)
  20.         $donotwant2 = { FE ED FA CF } // Mach-O binary (64-bit)
  21.         $donotwant3 = { CE FA ED FE } // Mach-O binary (reverse byte ordering scheme, 32-bit)
  22.         $donotwant4 = { CE FA ED FE } // Mach-O binary (reverse byte ordering scheme, 64-bit)
  23.         $donotwant5 = { 4D 5A 50 00 02 } // Win32 Dynamic Link Library - Borland C/C++
  24.         $donotwant6 = { 53 75 62 6A 65 63 74 3A 20 25 73 } // "Subject: %s"
  25.        
  26.         // Adjust to your need the list of legitimate. You may miss web sent
  27.         // spam through this filter, but we don't need stuff we can't access
  28.         // publicly like cpanel, Roundcube, etc...
  29.         $legit1 = "(https://github.com/PHPMailer/PHPMailer)" // PHPMailer
  30.         $legit2 = "(phpmailer.sourceforge.net)" // PHPMailer
  31.         $legit3 = "X-Mailer: PHPMailer" // PHPMailer
  32.         $legit4 = "SimpleMailInvoker.php" // Swiftmailer
  33.         $legit5 = "X-Mailer: SMF" // Simple Machines Forum
  34.         $legit6 = "X-Mailer: phpBB3" // phpBB3
  35.         $legit7 = "X-Mailer: PHP/Xooit" // Xooit forum
  36.         $legit8 = "X-Mailer: vBulletin" // vBulletin
  37.         $legit9 = "X-Mailer: MediaWiki mailer" // MediaWiki
  38.         $legit10 = "X-Mailer: Drupal" // Drupal
  39.         $legit11 = "X-Mailer: osCommerce Mailer" // osCommerce
  40.         $legit12 = "[email protected]" // Message sent by Mailjet
  41.         $legit13 = "class.foxycart.transaction.php" // Foxy Ecommerce
  42.         $legit14 = "User-Agent: Roundcube Webmail" // Roundcube
  43.         $legit15 = "User-Agent: SquirrelMail" // SquirrelMail
  44.         $legit16 = "X-Source: /opt/cpanel/" // mail send from cpanel
  45.         $legit17 = { 58 2D 50 48 50 2D 4F 72 69 67 69 6E 61 74 69 6E 67 2D 53 63 72 69 70 74 3A 20 [1-6] 3A 70 6F 73 74 2E 70 68 70 28 [1-6] 29 } // "X-PHP-Originating-Script: ?:post.php(?)" Might be related to cpanel.
  46.         $legit18 = { 58 2D 50 48 50 2D 53 63 72 69 70 74 3A 20 [3-30] 2F 70 6F 73 74 2E 70 68 70 20 66 6F 72 20 } // "X-PHP-Script: ????/post.php for " Might be related to cpanel.
  47.  
  48.         $eml1 = "From:"
  49.         $eml2 = "To:"
  50.         $eml3 = "Subject:"
  51.    
  52.         $mailer1 = /X-PHP-Originating-Script: ([\w\.]+(.*\.php))?/
  53.         $mailer2 = /X-PHP-Script: ([\w\.\/]+\/(.*\.php))?/
  54.         $mailer3 = /X-PHP-Filename: (\/[\w]+\/(.*\.php))?/
  55.         // $mailer4 = /X-Source-Args: (\/[\w]+\/(.*\.php))?/  // may lead to false positive and unwanted, up to you.
  56.  
  57.     condition:
  58.         not  any of ($donotwant*) and not any of ($legit*)
  59.         and all of ($eml*) and 2 of ($mailer*)
  60. }
Add Comment
Please, Sign In to add comment