{"id":9308,"date":"2017-09-15T08:57:17","date_gmt":"2017-09-15T16:57:17","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/09\/15\/news-3081\/"},"modified":"2017-09-15T08:57:17","modified_gmt":"2017-09-15T16:57:17","slug":"news-3081","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2017\/09\/15\/news-3081\/","title":{"rendered":"Explained: YARA rules"},"content":{"rendered":"<p><strong>Credit to Author: Pieter Arntz| Date: Fri, 15 Sep 2017 15:00:08 +0000<\/strong><\/p>\n<p>YARA rules are a way of identifying malware (or other files) by creating rules that look for certain characteristics. YARA was originally developed by Victor Alvarez of Virustotal and is mainly used in malware research and detection. It was developed with the idea to describe patterns that identify particular strains or entire families of malware.<\/p>\n<h3>Syntax<\/h3>\n<p>Each rule has to start with the word <em>rule<\/em>, followed by the name or identifier. The identifier can contain any alphanumeric character and the underscore character, but the first character is not allowed to be a digit. There is a list of <a href=\"http:\/\/yara.readthedocs.io\/en\/v3.6.3\/writingrules.html#id2\" target=\"_blank\" rel=\"noopener\">YARA keywords<\/a> that are not allowed to be used as an identifier because they have a predefined meaning.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-19669\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/09\/examplepcsmartcleanup.png\" alt=\"\" width=\"459\" height=\"236\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/09\/examplepcsmartcleanup.png 459w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/09\/examplepcsmartcleanup-300x154.png 300w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/p>\n<h3>Condition<\/h3>\n<p>Rules are composed of several sections. The <em>condition<\/em> section is the only one that is required. This section specifies when the rule result is <em>true<\/em> for the object (file) that is under investigation. It contains a Boolean expression that determines the result. Conditions are by design Boolean expressions and can contain all the usual logical and relational operators. You can also include another rule as part of your conditions.<\/p>\n<h3>Strings<\/h3>\n<p>To give the <em>condition<\/em> section a meaning you will also need a <em>strings<\/em> section. The strings sections is where you can define the strings that will be looked for in the file. Let\u2019s look at an easy example.<\/p>\n<p><code>rule vendor<br \/> {<br \/> strings:<br \/> $text_string1 = \u201cVendor name\u201d wide<br \/> $text_string2 = \u201cAlias name\u201d wide<br \/> condition:<br \/> $text_string1 or $wide_string2<br \/> }<br \/> <\/code><\/p>\n<p>The rule shown above is named vendor and looks for the strings \u201cVendor name\u201d and \u201cAlias name\u201d. If either of those strings is found, then the result of the rule is <em>true<\/em>.<\/p>\n<p>There are several types of strings you can look for:<\/p>\n<ul>\n<li>Hexadecimal, in combination with wild-cards, jumps, and alternatives.<\/li>\n<li>Text strings, with modifiers: nocase, fullword, wide, and ascii.<\/li>\n<li>Regular expressions, with the same modifiers as text strings.<\/li>\n<\/ul>\n<p>There are many more advanced conditions you can use, but they are outside the scope of this post. If you would like to know more you can find it in the <a href=\"http:\/\/yara.readthedocs.io\/en\/v3.6.3\/index.html\" target=\"_blank\" rel=\"noopener\">YARA documentation<\/a>.<\/p>\n<h3>Metadata<\/h3>\n<p>Metadata can be added to help identify the files that were picked up by a certain rule. The metadata identifiers are always followed by an equal sign and the set value. The assigned values can be strings, integers, or a Boolean value. Note that identifier\/value pairs defined in the metadata section can\u2019t be used in the condition section, their only purpose is to store additional information about the rule.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-19668\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/09\/caught.png\" alt=\"\" width=\"601\" height=\"156\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/09\/caught.png 601w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/09\/caught-300x78.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/09\/caught-600x156.png 600w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/p>\n<h3>Summary<\/h3>\n<p>YARA is a tool that can be used to identify files that meet certain conditions. It is mainly in use by security researchers to classify malware.<\/p>\n<h3>Links<\/h3>\n<p><a href=\"https:\/\/securityintelligence.com\/signature-based-detection-with-yara\/\" target=\"_blank\" rel=\"noopener\">Signature-Based Detection With YARA<\/a><\/p>\n<p><a href=\"http:\/\/yara.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noopener\">Latest YARA documentation<\/a><\/p>\n<p><a href=\"http:\/\/resources.infosecinstitute.com\/yara-simple-effective-way-dissecting-malware\/\" target=\"_blank\" rel=\"noopener\">YARA: Simple and Effective Way of Dissecting Malware<\/a><\/p>\n<p>Screenshots were made using <a href=\"https:\/\/www.adlice.com\/download\/yaraeditor\/\" target=\"_blank\" rel=\"noopener\">Yara Editor by Adlice Software<\/a><\/p>\n<p><em>Pieter Arntz<\/em><\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\/security-world\/technology\/2017\/09\/explained-yara-rules\/\">Explained: YARA rules<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\">Malwarebytes Labs<\/a>.<\/p>\n<p><a href=\"https:\/\/blog.malwarebytes.com\/security-world\/technology\/2017\/09\/explained-yara-rules\/\" target=\"bwo\" >https:\/\/blog.malwarebytes.com\/feed\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><strong>Credit to Author: Pieter Arntz| Date: Fri, 15 Sep 2017 15:00:08 +0000<\/strong><\/p>\n<table cellpadding='10'>\n<tr>\n<td valign='top' align='center'><a href='https:\/\/blog.malwarebytes.com\/security-world\/technology\/2017\/09\/explained-yara-rules\/' title='Explained: YARA rules'><img src='https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/09\/yaralogo.jpg' border='0'  width='300px'  \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign='top' align='left'>YARA is a tool that can be used to identify files that meet certain conditions. It is mainly in use by security researchers to classify malware.<\/p>\n<p>Categories: <\/p>\n<ul class=\"post-categories\">\n<li><a href=\"https:\/\/blog.malwarebytes.com\/category\/security-world\/\" rel=\"category tag\">Security world<\/a><\/li>\n<li><a href=\"https:\/\/blog.malwarebytes.com\/category\/security-world\/technology\/\" rel=\"category tag\">Technology<\/a><\/li>\n<li><a href=\"https:\/\/blog.malwarebytes.com\/category\/threat-analysis\/\" rel=\"category tag\">Threat analysis<\/a><\/li>\n<\/ul>\n<p>Tags: <a href=\"https:\/\/blog.malwarebytes.com\/tag\/explained\/\" rel=\"tag\">Explained<\/a><a href=\"https:\/\/blog.malwarebytes.com\/tag\/malware\/\" rel=\"tag\">malware<\/a><a href=\"https:\/\/blog.malwarebytes.com\/tag\/pieter-arntz\/\" rel=\"tag\">Pieter Arntz<\/a><a href=\"https:\/\/blog.malwarebytes.com\/tag\/rules\/\" rel=\"tag\">rules<\/a><a href=\"https:\/\/blog.malwarebytes.com\/tag\/the-more-you-know\/\" rel=\"tag\">the more you know<\/a><a href=\"https:\/\/blog.malwarebytes.com\/tag\/yara\/\" rel=\"tag\">yara<\/a><\/p>\n<table width='100%'>\n<tr>\n<td align=right>\n<p><b>(<a href='https:\/\/blog.malwarebytes.com\/security-world\/technology\/2017\/09\/explained-yara-rules\/' title='Explained: YARA rules'>Read more&#8230;<\/a>)<\/b><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/td>\n<\/tr>\n<\/table>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\/security-world\/technology\/2017\/09\/explained-yara-rules\/\">Explained: YARA rules<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\">Malwarebytes Labs<\/a>.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10488,10378],"tags":[10522,3764,10523,14787,10497,1331,10524,10494,14788],"class_list":["post-9308","post","type-post","status-publish","format-standard","hentry","category-malwarebytes","category-security","tag-explained","tag-malware","tag-pieter-arntz","tag-rules","tag-security-world","tag-technology","tag-the-more-you-know","tag-threat-analysis","tag-yara"],"_links":{"self":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/9308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=9308"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/9308\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=9308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=9308"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=9308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}