|
| 1 | +File Block EXE |
| 2 | +=========== |
| 3 | + |
| 4 | +On version 14.0 of Sysmon the capability to block the creation of executables by a process was added, this is the first event type where Sysmon takes a block action on a rule match. Sysmon relies on its filter driver, Sysmon can log the creation of files and information on what process is the the file using **EventID 27**. This event type is found under schema version |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +The minidriver inspect the header of the file for the MZ DOS Executable header. The file can be identified by the ASCII string "MZ" (hexadecimal: 4D 5A) at the beginning of the file (the "magic number"). "MZ" are the initials of Mark Zbikowski, one of the leading developers of MS-DOS. This header is included in DLLs, PE Files, COM executables and other executable types. |
| 10 | + |
| 11 | +Sysmon will not generate any alert on screen for the user once it takes the action. |
| 12 | + |
| 13 | + |
| 14 | +### Event information |
| 15 | + |
| 16 | +The file delete event fields are: |
| 17 | + |
| 18 | +* **RuleName**: Name of rule that triggered the event |
| 19 | + |
| 20 | +* **UtcTime**: Time in UTC when event was created |
| 21 | + |
| 22 | +* **ProcessGuid**: Process Guid of the process that attempted to create the file |
| 23 | + |
| 24 | +* **ProcessId**: Process ID used by the OS to identify the process that attempted to create the file. |
| 25 | + |
| 26 | +* **Image**: File path of the process that attempted to create the file |
| 27 | + |
| 28 | +* **TargetFilename**: Name of the file that is being created. |
| 29 | + |
| 30 | +**Hashes**: Full hash of the file with the algorithms in the HashType field. This is also the filename of the saved file in the ArchiveDirectory |
| 31 | + |
| 32 | + |
| 33 | +Given the potential for this specific rule set to cause friction between a security team with users and other groups in the organization it is recommended to test before deploying. One recommendation is to use a file creation rule set to build a baseline of what executables are create where as part of normal day to day operations and then take that data to build a rule set that will minimize impact. |
| 34 | + |
| 35 | +A sample baseline ruleset can be: |
| 36 | + |
| 37 | +```XML |
| 38 | +<Sysmon schemaversion="4.82"> |
| 39 | + <HashAlgorithms>sha1</HashAlgorithms> |
| 40 | + <CheckRevocation/> |
| 41 | + <EventFiltering> |
| 42 | + <RuleGroup name="File Creation" groupRelation="or"> |
| 43 | + <FileCreate onmatch="include"> |
| 44 | + <TargetFilename name="executables" condition="contains any">.dll;.exe</TargetFilename> |
| 45 | + </FileCreate> |
| 46 | + </RuleGroup> |
| 47 | + </EventFiltering> |
| 48 | +</Sysmon> |
| 49 | +``` |
| 50 | + |
| 51 | +Bellow is an example rule set that covers some of the most common scenarios where actors will drop executables using malicious documents, in emails, |
| 52 | + |
| 53 | +```XML |
| 54 | +<Sysmon schemaversion="4.82"> |
| 55 | + <HashAlgorithms>sha1</HashAlgorithms> |
| 56 | + <CheckRevocation/> |
| 57 | + <EventFiltering> |
| 58 | + <RuleGroup name="File Block Exe" groupRelation="or"> |
| 59 | + <FileBlockExecutable onmatch="include"> |
| 60 | + <!-- Primary --> |
| 61 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">excel.exe</Image> |
| 62 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">winword.exe</Image> |
| 63 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">powerpnt.exe</Image> |
| 64 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">outlook.exe</Image> |
| 65 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">msaccess.exe</Image> |
| 66 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">mspub.exe</Image> |
| 67 | + |
| 68 | + <!-- Scripting Engines --> |
| 69 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">powershell.exe</Image> |
| 70 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">mshta.exe</Image> |
| 71 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">cscript.exe</Image> |
| 72 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">wscript.exe</Image> |
| 73 | + |
| 74 | + <!-- LOLBins --> |
| 75 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">certutil.exe</Image> |
| 76 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">esenutl.exe</Image> |
| 77 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">desktopimgdownldr.exe</Image> |
| 78 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">regsvr32.exe</Image> |
| 79 | + <Image name="technique_id=T1105,technique_name=Ingress Tool Transfer" condition="image">Odbcconf.exe</Image> |
| 80 | + </FileBlockExecutable> |
| 81 | + </RuleGroup> |
| 82 | + </EventFiltering> |
| 83 | +</Sysmon> |
| 84 | +``` |
0 commit comments