{"id":2959,"date":"2018-02-10T15:07:04","date_gmt":"2018-02-10T14:07:04","guid":{"rendered":"http:\/\/nextron.bsk-consulting.de\/?p=2959"},"modified":"2022-10-04T15:14:48","modified_gmt":"2022-10-04T13:14:48","slug":"write-sigma-rules","status":"publish","type":"post","link":"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/","title":{"rendered":"How to Write Sigma Rules"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; admin_label=&#8221;section&#8221; _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; da_is_popup=&#8221;off&#8221; da_exit_intent=&#8221;off&#8221; da_has_close=&#8221;on&#8221; da_alt_close=&#8221;off&#8221; da_dark_close=&#8221;off&#8221; da_not_modal=&#8221;on&#8221; da_is_singular=&#8221;off&#8221; da_with_loader=&#8221;off&#8221; da_has_shadow=&#8221;on&#8221; da_disable_devices=&#8221;off|off|off&#8221;][et_pb_row admin_label=&#8221;row&#8221; _builder_version=&#8221;4.16&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;|||&#8221; global_colors_info=&#8221;{}&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_text admin_label=&#8221;Text&#8221; _builder_version=&#8221;4.18.0&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; sticky_enabled=&#8221;0&#8243;]Sigma is an open standard for rules that allow you to describe searches on log data in generic form. These rules can be converted and applied to many log management or SIEM systems and can even be used with grep on the command line.<\/p>\n<p>In this article I&#8217;d like to give you a brief practical introduction into the rule creation process. I&#8217;ll recommend some tools and draft a guide that helps you to write Sigma rules as quick and sound as possible.<\/p>\n<h2>1. Get the Repository<\/h2>\n<p>First download or clone our <a href=\"https:\/\/github.com\/Neo23x0\/sigma\">Sigma repository<\/a> from Github.<\/p>\n<p>It contains the rule base in the folder &#8220;.\/rules&#8221; and the Sigma rule compiler &#8220;.\/tools\/sigmac&#8221;. We will use the existing rules as examples and create a new rule based on a similar existing one. We will then test that rule by using &#8220;sigmac&#8221;.<\/p>\n<div id=\"attachment_2961\" style=\"width: 1040px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2961\" class=\"wp-image-2961 size-full\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.38.58.png\" alt=\"\" width=\"1030\" height=\"615\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.38.58.png 1030w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.38.58-300x179.png 300w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.38.58-768x459.png 768w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.38.58-1024x611.png 1024w\" sizes=\"(max-width: 1030px) 100vw, 1030px\" \/><p id=\"caption-attachment-2961\" class=\"wp-caption-text\">Sigma Github Repository<\/p><\/div>\n<h2>2. Copy and Edit YAML Files<\/h2>\n<p>My personal favorite editor for YAML is <a href=\"https:\/\/code.visualstudio.com\/\">VSCode<\/a>. It is free and runs on all major platforms. (alternatively you can use <a href=\"https:\/\/atom.io\/\">Atom<\/a>\u00a0with &#8216;language-yaml&#8217; and &#8216;linter-js-yaml&#8217; packages)<\/p>\n<div id=\"attachment_2960\" style=\"width: 1185px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2960\" class=\"wp-image-2960 size-full\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.33.49.png\" alt=\"\" width=\"1175\" height=\"742\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.33.49.png 1175w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.33.49-300x189.png 300w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.33.49-768x485.png 768w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.33.49-1024x647.png 1024w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.33.49-1080x682.png 1080w\" sizes=\"(max-width: 1175px) 100vw, 1175px\" \/><p id=\"caption-attachment-2960\" class=\"wp-caption-text\">Visual Studio Code<\/p><\/div>\n<p>I used the following extensions but I don&#8217;t know if they are still necessary. VSCode has improved a lot over the last 12 months and it is possible that it supports YAML highlighting and syntax checks by default now.<\/p>\n<div id=\"attachment_2965\" style=\"width: 879px\" class=\"wp-caption alignleft\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2965\" class=\"wp-image-2965 size-full\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.54.10.png\" alt=\"\" width=\"869\" height=\"602\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.54.10.png 869w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.54.10-300x208.png 300w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.54.10-768x532.png 768w\" sizes=\"(max-width: 869px) 100vw, 869px\" \/><p id=\"caption-attachment-2965\" class=\"wp-caption-text\">YAML Extensions for VSCode<\/p><\/div>\n<p>We open the Sigma repository folder with &#8220;Open &#8230;&#8221; and see all existing rules.<\/p>\n<div id=\"attachment_2966\" style=\"width: 922px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2966\" class=\"wp-image-2966 size-full\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-10.23.48.png\" alt=\"\" width=\"912\" height=\"605\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-10.23.48.png 912w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-10.23.48-300x199.png 300w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-10.23.48-768x509.png 768w\" sizes=\"(max-width: 912px) 100vw, 912px\" \/><p id=\"caption-attachment-2966\" class=\"wp-caption-text\">Sigma Rules<\/p><\/div>\n<h2>3. Create a Sigma Rule<\/h2>\n<p>I selected an example in which we will create a Sigma rule from one of <a href=\"https:\/\/twitter.com\/jpcert_en?lang=en\">@JPCERT<\/a>&#8216;s findings in their awesome &#8220;<a href=\"https:\/\/jpcertcc.github.io\/ToolAnalysisResultSheet\/#\">Tool Analysis Result Sheet<\/a>&#8220;.<\/p>\n<p>We open the results for &#8220;<a href=\"https:\/\/jpcertcc.github.io\/ToolAnalysisResultSheet\/details\/QuarksPWDump.htm\">Quarks PWDump<\/a>&#8220;, a password dumper often used by Chinese threat groups. It creates temporary files that we want to detect in our <a href=\"https:\/\/docs.microsoft.com\/en-us\/sysinternals\/downloads\/sysmon\">SysInternals Sysmon<\/a> log data. To collect the needed events we use Sysmon with <a href=\"https:\/\/twitter.com\/swiftonsecurity\">@SwiftOnSecurity<\/a>&#8216;s <a href=\"https:\/\/github.com\/SwiftOnSecurity\/sysmon-config\">Sysmon config file<\/a>, <a href=\"https:\/\/www.petri.com\/configure-event-log-forwarding-windows-server-2012-r2\" rel=\"noopener noreferrer\" target=\"_blank\">Windows Event Forwarding<\/a> or <a href=\"https:\/\/nxlog.co\/\" rel=\"noopener noreferrer\" target=\"_blank\">NXlog<\/a>.<\/p>\n<div id=\"attachment_2968\" style=\"width: 1142px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2968\" class=\"wp-image-2968 size-full\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.26.17.png\" alt=\"\" width=\"1132\" height=\"972\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.26.17.png 1132w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.26.17-300x258.png 300w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.26.17-768x659.png 768w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.26.17-1024x879.png 1024w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.26.17-1080x927.png 1080w\" sizes=\"(max-width: 1132px) 100vw, 1132px\" \/><p id=\"caption-attachment-2968\" class=\"wp-caption-text\">Quarks PWDump Analysis Results<\/p><\/div>\n<p>So, what we do is to find a Sigma rule in the repository that we can use as a template for our new rule. We use the &#8216;search&#8217; function to find a rule that looks for &#8220;File Creation&#8221; events (EventID 11) in Sysmon log data.<\/p>\n<div id=\"attachment_2970\" style=\"width: 876px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2970\" class=\"size-full wp-image-2970\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.55.17.png\" alt=\"\" width=\"866\" height=\"718\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.55.17.png 866w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.55.17-300x249.png 300w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.55.17-768x637.png 768w\" sizes=\"(max-width: 866px) 100vw, 866px\" \/><p id=\"caption-attachment-2970\" class=\"wp-caption-text\">Sigma Example Rule<\/p><\/div>\n<p>We find a rule that has a special format. It is a so-called &#8220;<a href=\"https:\/\/github.com\/Neo23x0\/sigma\/wiki\/Specification#rule-collections\">rule-collection<\/a>&#8220;, which allows us to define a global section in the YAML file marked with &#8220;action: global&#8221; that will be applied to all other sections in that file during the search query generation process. This way you can define and create multiple search queries from a single YAML file.<\/p>\n<p>In the case of our QuarksPwDump example we don&#8217;t need a rule collection, so we reduce the rule to a standard rule that contains a detection expression looking Sysmon Events with Event ID 11 and save it as &#8220;sysmon_quarkspw_filedump.yml&#8221; to a new file in the folder &#8220;.\/rules\/windows\/sysmon\/&#8221;.<\/p>\n<div id=\"attachment_2971\" style=\"width: 649px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2971\" class=\"wp-image-2971 size-full\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.05.23.png\" alt=\"\" width=\"639\" height=\"398\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.05.23.png 639w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.05.23-300x187.png 300w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.05.23-400x250.png 400w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><p id=\"caption-attachment-2971\" class=\"wp-caption-text\">Simple Sysmon Sigma Rule<\/p><\/div>\n<p>After that, we modify several fields of that rule:<\/p>\n<ul>\n<li>We give the rule a correct &#8220;title&#8221; and &#8220;description&#8221;<\/li>\n<li>We leave the status &#8220;experimental&#8221; to inform everyone that this is a new and untested rule<\/li>\n<li>We add the correct reference to the source from which we derived that rule<\/li>\n<li>We change the author of the rule<\/li>\n<li>We set the level of that rule to one of &#8220;low&#8221;, &#8220;medium&#8221;, &#8220;high&#8221; or &#8220;critical&#8221;<\/li>\n<li>We adjust the date (of last modification) and use the format %Y\/%m%d (strftime)<\/li>\n<li>We check if the log source is correct, which is important for the <a href=\"https:\/\/github.com\/Neo23x0\/sigma\/wiki\/Converter-Tool-Sigmac#configuration-file\">field mappings<\/a> used by &#8220;sigmac&#8221;<\/li>\n<\/ul>\n<div id=\"attachment_2972\" style=\"width: 677px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2972\" class=\"size-full wp-image-2972\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.21.26.png\" alt=\"\" width=\"667\" height=\"251\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.21.26.png 667w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.21.26-300x113.png 300w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><p id=\"caption-attachment-2972\" class=\"wp-caption-text\">New Sigma Rule Header<\/p><\/div>\n<p>Before we create the new &#8220;detection&#8221; section, we review the analysis report in detail.<\/p>\n<div id=\"attachment_2973\" style=\"width: 769px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2973\" class=\"size-full wp-image-2973\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.25.23.png\" alt=\"\" width=\"759\" height=\"389\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.25.23.png 759w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.25.23-300x154.png 300w\" sizes=\"(max-width: 759px) 100vw, 759px\" \/><p id=\"caption-attachment-2973\" class=\"wp-caption-text\">Details: QuarksPwDump Temporary Files<\/p><\/div>\n<p>We add a string with wildcards that matches on the &#8216;TargetFileName&#8217; field in the Sysmon events of type 11. That&#8217;s what the new rule looks like:<\/p>\n<div id=\"attachment_2976\" style=\"width: 680px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2976\" class=\"size-full wp-image-2976\" src=\"\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.54.09.png\" alt=\"\" width=\"670\" height=\"393\" srcset=\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.54.09.png 670w, https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.54.09-300x176.png 300w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><p id=\"caption-attachment-2976\" class=\"wp-caption-text\">QuarksPwDump Sigma Rule<\/p><\/div>\n<h2>4. Test the Rules<\/h2>\n<p>We test our newly created rule with &#8220;sigmac&#8221;, which requires python3. It is located in the &#8220;.\/tools&#8221; folder. It features several targets for which we can create searches\/configurations from our rules.<\/p>\n<p>Currently supported targets (10.02.2018):<\/p>\n<ul>\n<li>es-qs (Elastic Search Query Language)<\/li>\n<li>kibana<\/li>\n<li>xpack-watcher<\/li>\n<li>logpoint<\/li>\n<li>splunk<\/li>\n<li>grep<\/li>\n<li>fieldlist (only used to show all fields that require mapping in a config file)<\/li>\n<\/ul>\n<p>Running &#8220;python3 sigmac -h&#8221; shows a help:<\/p>\n<pre>\n$ python3 sigmac -h\nusage: sigmac [-h] [--recurse] [--filter FILTER]\n[--target {es-qs,kibana,xpack-watcher,logpoint,splunk,grep,fieldlist}]\n[--target-list] [--config CONFIG] [--output OUTPUT]\n[--backend-option BACKEND_OPTION] [--defer-abort]\n[--ignore-not-implemented] [--verbose] [--debug]\n[inputs [inputs ...]]\n\nConvert Sigma rules into SIEM signatures.\n\npositional arguments:\ninputs Sigma input files\n\noptional arguments:\n-h, --help show this help message and exit\n--recurse, -r Recurse into subdirectories (not yet implemented)\n--filter FILTER, -f FILTER\nDefine comma-separated filters that must match (AND-\nlinked) to rule to be processed. Valid filters:\nlevel&lt;=x, level&gt;=x, level=x, status=y, logsource=z. x\nis one of: low, medium, high, critical. y is one of:\nexperimental, testing, stable. z is a word appearing\nin an arbitrary log source attribute. Multiple log\nsource specifications are AND linked.\n--target {es-qs,kibana,xpack-watcher,logpoint,splunk,grep,fieldlist}, -t {es-qs,kibana,xpack-watcher,logpoint,splunk,grep,fieldlist}\nOutput target format\n--target-list, -l List available output target formats\n--config CONFIG, -c CONFIG\nConfiguration with field name and index mapping for\ntarget environment (not yet implemented)\n--output OUTPUT, -o OUTPUT\nOutput file or filename prefix if multiple files are\ngenerated (not yet implemented)\n--backend-option BACKEND_OPTION, -O BACKEND_OPTION\nOptions and switches that are passed to the backend\n--defer-abort, -d Don't abort on parse or conversion errors, proceed\nwith next rule. The exit code from the last error is\nreturned\n--ignore-not-implemented, -I\nOnly return error codes for parse errors and ignore\nerrors for rules with not implemented features\n--verbose, -v Be verbose\n--debug, -D Debugging output\n<\/pre>\n<p>We test our new rule with &#8220;sigmac&#8221; and the target &#8220;splunk&#8221;.<\/p>\n<pre>\n$ python3 sigmac -t splunk ..\/rules\/windows\/sysmon\/sysmon_quarkspw_filedump.yml\n(EventID=\"11\" TargetFileName=\"*\\AppData\\Local\\Temp\\SAM-*.dmp*\")\n<\/pre>\n<p>Now the rule is ready for a pull request. Follow me or contact me on Twitter: <a href=\"https:\/\/twitter.com\/cyb3rops\" rel=\"noopener noreferrer\" target=\"_blank\">@cyb3rops<\/a>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sigma is an open standard for rules that allow you to describe searches on log data in generic form. These rules can be converted and applied to many log management or SIEM systems and can even be used with grep on the command line. In this article I&#8217;d like to give you a brief practical introduction into the rule creation process. I&#8217;ll recommend some tools and draft a guide that helps you to write Sigma rules as quick and sound as possible. 1. Get the Repository First download or clone our Sigma repository from Github. It contains the rule base in the folder &#8220;.\/rules&#8221; and the Sigma rule compiler &#8220;.\/tools\/sigmac&#8221;. We will use the existing rules as examples and create a new rule based on a similar existing one. We will then test that rule by using &#8220;sigmac&#8221;. 2. Copy and Edit YAML Files My personal favorite editor for YAML is VSCode. It is free and runs on all major platforms. (alternatively you can use Atom\u00a0with &#8216;language-yaml&#8217; and &#8216;linter-js-yaml&#8217; packages) I used the following extensions but I don&#8217;t know if they are still necessary. VSCode has improved a lot over the last 12 months and it is possible that it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"Sigma is an open standard for rules that allow you to describe searches on log data in generic form. These rules can be converted and applied to many log management or SIEM systems and can even be used with grep on the command line. \r\n\r\nIn this article I'd like to give you a brief practical introduction into the rule creation process. I'll recommend some tools and draft a guide that helps you to write Sigma rules as quick and sound as possible.\r\n<h2>1. Get the Repository<\/h2>\r\nFirst download or clone our <a href=\"https:\/\/github.com\/Neo23x0\/sigma\">Sigma repository<\/a> from Github.\r\n\r\nIt contains the rule base in the folder \".\/rules\" and the Sigma rule compiler \".\/tools\/sigmac\". We will use the existing rules as examples and create a new rule based on a similar existing one. We will then test that rule by using \"sigmac\".\r\n\r\n[caption id=\"attachment_2961\" align=\"alignnone\" width=\"1030\"]<img class=\"wp-image-2961 size-full\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.38.58.png\" alt=\"\" width=\"1030\" height=\"615\" \/> Sigma Github Repository[\/caption]\r\n<h2>2. Copy and Edit YAML Files<\/h2>\r\nMy personal favorite editor for YAML is <a href=\"https:\/\/code.visualstudio.com\/\">VSCode<\/a>. It is free and runs on all major platforms. (alternatively you can use <a href=\"https:\/\/atom.io\/\">Atom<\/a>\u00a0with 'language-yaml' and 'linter-js-yaml' packages)\r\n\r\n[caption id=\"attachment_2960\" align=\"alignnone\" width=\"1175\"]<img class=\"wp-image-2960 size-full\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.33.49.png\" alt=\"\" width=\"1175\" height=\"742\" \/> Visual Studio Code[\/caption]\r\n\r\nI used the following extensions but I don't know if they are still necessary. VSCode has improved a lot over the last 12 months and it is possible that it supports YAML highlighting and syntax checks by default now. \r\n\r\n[caption id=\"attachment_2965\" align=\"alignleft\" width=\"869\"]<img class=\"wp-image-2965 size-full\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-09.54.10.png\" alt=\"\" width=\"869\" height=\"602\" \/> YAML Extensions for VSCode[\/caption]\r\n\r\nWe open the Sigma repository folder with \"Open ...\" and see all existing rules.\r\n\r\n[caption id=\"attachment_2966\" align=\"alignnone\" width=\"912\"]<img class=\"wp-image-2966 size-full\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-10.23.48.png\" alt=\"\" width=\"912\" height=\"605\" \/> Sigma Rules[\/caption]\r\n<h2>3. Create a Sigma Rule<\/h2>\r\nI selected an example in which we will create a Sigma rule from one of <a href=\"https:\/\/twitter.com\/jpcert_en?lang=en\">@JPCERT<\/a>'s findings in their awesome \"<a href=\"https:\/\/jpcertcc.github.io\/ToolAnalysisResultSheet\/#\">Tool Analysis Result Sheet<\/a>\".\r\n\r\nWe open the results for \"<a href=\"https:\/\/jpcertcc.github.io\/ToolAnalysisResultSheet\/details\/QuarksPWDump.htm\">Quarks PWDump<\/a>\", a password dumper often used by Chinese threat groups. It creates temporary files that we want to detect in our <a href=\"https:\/\/docs.microsoft.com\/en-us\/sysinternals\/downloads\/sysmon\">SysInternals Sysmon<\/a> log data. To collect the needed events we use Sysmon with <a href=\"https:\/\/twitter.com\/swiftonsecurity\">@SwiftOnSecurity<\/a>'s <a href=\"https:\/\/github.com\/SwiftOnSecurity\/sysmon-config\">Sysmon config file<\/a>, <a href=\"https:\/\/www.petri.com\/configure-event-log-forwarding-windows-server-2012-r2\" rel=\"noopener\" target=\"_blank\">Windows Event Forwarding<\/a> or <a href=\"https:\/\/nxlog.co\/\" rel=\"noopener\" target=\"_blank\">NXlog<\/a>.\r\n\r\n[caption id=\"attachment_2968\" align=\"alignnone\" width=\"1132\"]<img class=\"wp-image-2968 size-full\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.26.17.png\" alt=\"\" width=\"1132\" height=\"972\" \/> Quarks PWDump Analysis Results[\/caption]\r\n\r\nSo, what we do is to find a Sigma rule in the repository that we can use as a template for our new rule. We use the 'search' function to find a rule that looks for \"File Creation\" events (EventID 11) in Sysmon log data.\r\n\r\n[caption id=\"attachment_2970\" align=\"alignnone\" width=\"866\"]<img class=\"size-full wp-image-2970\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-13.55.17.png\" alt=\"\" width=\"866\" height=\"718\" \/> Sigma Example Rule[\/caption]\r\n\r\nWe find a rule that has a special format. It is a so-called \"<a href=\"https:\/\/github.com\/Neo23x0\/sigma\/wiki\/Specification#rule-collections\">rule-collection<\/a>\", which allows us to define a global section in the YAML file marked with \"action: global\" that will be applied to all other sections in that file during the search query generation process. This way you can define and create multiple search queries from a single YAML file.\r\n\r\nIn the case of our QuarksPwDump example we don't need a rule collection, so we reduce the rule to a standard rule that contains a detection expression looking Sysmon Events with Event ID 11 and save it as \"sysmon_quarkspw_filedump.yml\" to a new file in the folder \".\/rules\/windows\/sysmon\/\".\r\n\r\n[caption id=\"attachment_2971\" align=\"alignnone\" width=\"639\"]<img class=\"wp-image-2971 size-full\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.05.23.png\" alt=\"\" width=\"639\" height=\"398\" \/> Simple Sysmon Sigma Rule[\/caption]\r\n\r\nAfter that, we modify several fields of that rule:\r\n<ul>\r\n \t<li>We give the rule a correct \"title\" and \"description\"<\/li>\r\n \t<li>We leave the status \"experimental\" to inform everyone that this is a new and untested rule<\/li>\r\n \t<li>We add the correct reference to the source from which we derived that rule<\/li>\r\n \t<li>We change the author of the rule<\/li>\r\n \t<li>We set the level of that rule to one of \"low\", \"medium\", \"high\" or \"critical\"<\/li>\r\n \t<li>We adjust the date (of last modification) and use the format %Y\/%m%d (strftime)<\/li>\r\n \t<li>We check if the log source is correct, which is important for the <a href=\"https:\/\/github.com\/Neo23x0\/sigma\/wiki\/Converter-Tool-Sigmac#configuration-file\">field mappings<\/a> used by \"sigmac\"<\/li>\r\n<\/ul>\r\n[caption id=\"attachment_2972\" align=\"alignnone\" width=\"667\"]<img class=\"size-full wp-image-2972\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.21.26.png\" alt=\"\" width=\"667\" height=\"251\" \/> New Sigma Rule Header[\/caption]\r\n\r\nBefore we create the new \"detection\" section, we review the analysis report in detail.\r\n\r\n[caption id=\"attachment_2973\" align=\"alignnone\" width=\"759\"]<img class=\"size-full wp-image-2973\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.25.23.png\" alt=\"\" width=\"759\" height=\"389\" \/> Details: QuarksPwDump Temporary Files[\/caption]\r\n\r\nWe add a string with wildcards that matches on the 'TargetFileName' field in the Sysmon events of type 11. That's what the new rule looks like:\r\n\r\n[caption id=\"attachment_2976\" align=\"alignnone\" width=\"670\"]<img class=\"size-full wp-image-2976\" src=\"http:\/\/nextron.bsk-consulting.de\/wp-content\/uploads\/2018\/02\/Screen-Shot-2018-02-10-at-14.54.09.png\" alt=\"\" width=\"670\" height=\"393\" \/> QuarksPwDump Sigma Rule[\/caption]\r\n<h2>4. Test the Rules<\/h2>\r\nWe test our newly created rule with \"sigmac\", which requires python3. It is located in the \".\/tools\" folder. It features several targets for which we can create searches\/configurations from our rules.\r\n\r\nCurrently supported targets (10.02.2018):\r\n<ul>\r\n \t<li>es-qs (Elastic Search Query Language)<\/li>\r\n \t<li>kibana<\/li>\r\n \t<li>xpack-watcher<\/li>\r\n \t<li>logpoint<\/li>\r\n \t<li>splunk<\/li>\r\n \t<li>grep<\/li>\r\n \t<li>fieldlist (only used to show all fields that require mapping in a config file)<\/li>\r\n<\/ul>\r\nRunning \"python3 sigmac -h\" shows a help:\r\n\r\n[cc]\r\n$ python3 sigmac -h\r\nusage: sigmac [-h] [--recurse] [--filter FILTER]\r\n              [--target {es-qs,kibana,xpack-watcher,logpoint,splunk,grep,fieldlist}]\r\n              [--target-list] [--config CONFIG] [--output OUTPUT]\r\n              [--backend-option BACKEND_OPTION] [--defer-abort]\r\n              [--ignore-not-implemented] [--verbose] [--debug]\r\n              [inputs [inputs ...]]\r\n\r\nConvert Sigma rules into SIEM signatures.\r\n\r\npositional arguments:\r\n  inputs                Sigma input files\r\n\r\noptional arguments:\r\n  -h, --help            show this help message and exit\r\n  --recurse, -r         Recurse into subdirectories (not yet implemented)\r\n  --filter FILTER, -f FILTER\r\n                        Define comma-separated filters that must match (AND-\r\n                        linked) to rule to be processed. Valid filters:\r\n                        level<=x, level>=x, level=x, status=y, logsource=z. x\r\n                        is one of: low, medium, high, critical. y is one of:\r\n                        experimental, testing, stable. z is a word appearing\r\n                        in an arbitrary log source attribute. Multiple log\r\n                        source specifications are AND linked.\r\n  --target {es-qs,kibana,xpack-watcher,logpoint,splunk,grep,fieldlist}, -t {es-qs,kibana,xpack-watcher,logpoint,splunk,grep,fieldlist}\r\n                        Output target format\r\n  --target-list, -l     List available output target formats\r\n  --config CONFIG, -c CONFIG\r\n                        Configuration with field name and index mapping for\r\n                        target environment (not yet implemented)\r\n  --output OUTPUT, -o OUTPUT\r\n                        Output file or filename prefix if multiple files are\r\n                        generated (not yet implemented)\r\n  --backend-option BACKEND_OPTION, -O BACKEND_OPTION\r\n                        Options and switches that are passed to the backend\r\n  --defer-abort, -d     Don't abort on parse or conversion errors, proceed\r\n                        with next rule. The exit code from the last error is\r\n                        returned\r\n  --ignore-not-implemented, -I\r\n                        Only return error codes for parse errors and ignore\r\n                        errors for rules with not implemented features\r\n  --verbose, -v         Be verbose\r\n  --debug, -D           Debugging output\r\n[\/cc]\r\n\r\nWe test our new rule with \"sigmac\" and the target \"splunk\".\r\n\r\n[cc lang=\"bash\"]\r\n$ python3 sigmac -t splunk ..\/rules\/windows\/sysmon\/sysmon_quarkspw_filedump.yml\r\n(EventID=\"11\" TargetFileName=\"*AppDataLocalTempSAM-*.dmp*\")\r\n[\/cc]\r\n\r\nNow the rule is ready for a pull request. Follow me or contact me on Twitter: <a href=\"https:\/\/twitter.com\/cyb3rops\" rel=\"noopener\" target=\"_blank\">@cyb3rops<\/a>","_et_gb_content_width":"","footnotes":""},"categories":[1],"tags":[63,62,61,60,59,12],"class_list":["post-2959","post","type-post","status-publish","format-standard","hentry","category-nextron","tag-hunting","tag-rules","tag-security-monitoring","tag-siem","tag-sigma","tag-threat"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Write Sigma Rules - Nextron Systems<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/\"},\"author\":{\"name\":\"Florian Roth\",\"@id\":\"https:\/\/www.nextron-systems.com\/#\/schema\/person\/4fd503007d60aabaf1ae747502f36919\"},\"headline\":\"How to Write Sigma Rules\",\"datePublished\":\"2018-02-10T14:07:04+00:00\",\"dateModified\":\"2022-10-04T13:14:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/\"},\"wordCount\":938,\"publisher\":{\"@id\":\"https:\/\/www.nextron-systems.com\/#organization\"},\"keywords\":[\"Hunting\",\"Rules\",\"Security Monitoring\",\"SIEM\",\"Sigma\",\"threat\"],\"articleSection\":[\"Nextron\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/\",\"url\":\"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/\",\"name\":\"How to Write Sigma Rules - Nextron Systems\",\"isPartOf\":{\"@id\":\"https:\/\/www.nextron-systems.com\/#website\"},\"datePublished\":\"2018-02-10T14:07:04+00:00\",\"dateModified\":\"2022-10-04T13:14:48+00:00\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.nextron-systems.com\/#website\",\"url\":\"https:\/\/www.nextron-systems.com\/\",\"name\":\"Nextron Systems\",\"description\":\"We Detect Hackers\",\"publisher\":{\"@id\":\"https:\/\/www.nextron-systems.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.nextron-systems.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.nextron-systems.com\/#organization\",\"name\":\"Nextron Systems GmbH\",\"url\":\"https:\/\/www.nextron-systems.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.nextron-systems.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2017\/11\/Nextron_0.2s_inv_symbol_only.png\",\"contentUrl\":\"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2017\/11\/Nextron_0.2s_inv_symbol_only.png\",\"width\":260,\"height\":260,\"caption\":\"Nextron Systems GmbH\"},\"image\":{\"@id\":\"https:\/\/www.nextron-systems.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.nextron-systems.com\/#\/schema\/person\/4fd503007d60aabaf1ae747502f36919\",\"name\":\"Florian Roth\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.nextron-systems.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0dfaa838ce5d82e2e7bfa75ed3f43ae5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0dfaa838ce5d82e2e7bfa75ed3f43ae5?s=96&d=mm&r=g\",\"caption\":\"Florian Roth\"},\"description\":\"Florian Roth serves as the Head of Research and Development at Nextron Systems. With a background in IT security since 2000, he has delved deep into nation-state cyber attacks since 2012. Florian has developed the THOR Scanner and actively engages with the community via his Twitter handle @cyb3rops. He has contributed to open-source projects, including 'Sigma', a generic SIEM rule format, and 'LOKI', an open-source scanner. Additionally, he has shared valuable resources like a mapping of APT groups and operations and an Antivirus Event Analysis Cheat Sheet.\",\"url\":\"https:\/\/www.nextron-systems.com\/author\/florian\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Write Sigma Rules - Nextron Systems","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/#article","isPartOf":{"@id":"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/"},"author":{"name":"Florian Roth","@id":"https:\/\/www.nextron-systems.com\/#\/schema\/person\/4fd503007d60aabaf1ae747502f36919"},"headline":"How to Write Sigma Rules","datePublished":"2018-02-10T14:07:04+00:00","dateModified":"2022-10-04T13:14:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/"},"wordCount":938,"publisher":{"@id":"https:\/\/www.nextron-systems.com\/#organization"},"keywords":["Hunting","Rules","Security Monitoring","SIEM","Sigma","threat"],"articleSection":["Nextron"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/","url":"https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/","name":"How to Write Sigma Rules - Nextron Systems","isPartOf":{"@id":"https:\/\/www.nextron-systems.com\/#website"},"datePublished":"2018-02-10T14:07:04+00:00","dateModified":"2022-10-04T13:14:48+00:00","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.nextron-systems.com\/2018\/02\/10\/write-sigma-rules\/"]}]},{"@type":"WebSite","@id":"https:\/\/www.nextron-systems.com\/#website","url":"https:\/\/www.nextron-systems.com\/","name":"Nextron Systems","description":"We Detect Hackers","publisher":{"@id":"https:\/\/www.nextron-systems.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.nextron-systems.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.nextron-systems.com\/#organization","name":"Nextron Systems GmbH","url":"https:\/\/www.nextron-systems.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.nextron-systems.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2017\/11\/Nextron_0.2s_inv_symbol_only.png","contentUrl":"https:\/\/www.nextron-systems.com\/wp-content\/uploads\/2017\/11\/Nextron_0.2s_inv_symbol_only.png","width":260,"height":260,"caption":"Nextron Systems GmbH"},"image":{"@id":"https:\/\/www.nextron-systems.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.nextron-systems.com\/#\/schema\/person\/4fd503007d60aabaf1ae747502f36919","name":"Florian Roth","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.nextron-systems.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0dfaa838ce5d82e2e7bfa75ed3f43ae5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0dfaa838ce5d82e2e7bfa75ed3f43ae5?s=96&d=mm&r=g","caption":"Florian Roth"},"description":"Florian Roth serves as the Head of Research and Development at Nextron Systems. With a background in IT security since 2000, he has delved deep into nation-state cyber attacks since 2012. Florian has developed the THOR Scanner and actively engages with the community via his Twitter handle @cyb3rops. He has contributed to open-source projects, including 'Sigma', a generic SIEM rule format, and 'LOKI', an open-source scanner. Additionally, he has shared valuable resources like a mapping of APT groups and operations and an Antivirus Event Analysis Cheat Sheet.","url":"https:\/\/www.nextron-systems.com\/author\/florian\/"}]}},"_links":{"self":[{"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/posts\/2959","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/comments?post=2959"}],"version-history":[{"count":25,"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/posts\/2959\/revisions"}],"predecessor-version":[{"id":14647,"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/posts\/2959\/revisions\/14647"}],"wp:attachment":[{"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/media?parent=2959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/categories?post=2959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nextron-systems.com\/wp-json\/wp\/v2\/tags?post=2959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}