Repository navigation
added new detection #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
rbecwar
wants to merge
7
commits into
splunk:develop
from
rbecwar:malicious_powershell_executed_as_a_service
Closed
added new detection #1321
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fb08fc8
added new detection
rbecwar 517b71d
Update and rename suspicious_command_executed_as_a_service.yml to mal…
rbecwar ee29693
Update malicious_powershell_executed_as_a_service.yml
rbecwar 51d51af
adding test file
josehelps 8a515a1
Update malicious_powershell_executed_as_a_service.yml
patel-bhavin 72e9955
move test file to endpoint folder
patel-bhavin 3b9ec09
Merge branch 'develop' into malicious_powershell_executed_as_a_service
josehelps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
detections/endpoint/malicious_powershell_executed_as_a_service.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Malicious Powershell Executed As A Service | ||
| id: 8e204dfd-cae0-4ea8-a61d-e972a1ff2ff8 | ||
| version: 1 | ||
| date: '2021-04-07' | ||
| author: Ryan Becwar | ||
| type: batch | ||
| datamodel: | ||
| - Endpoint | ||
| description: This detection is to identify the abuse the Windows SC.exe to | ||
| execute malicious commands or payloads via PowerShell. | ||
| search: ' `wineventlog_system` EventCode=7045 Service_File_Name IN ("*powershell.exe*", "*-nop*", "*hid*") | ||
| | stats count min(_time) as firstTime max(_time) | ||
| as lastTime by EventCode Service_File_Name Service_Name Service_Start_Type Service_Type Service_Account user | ||
| | `security_content_ctime(firstTime)` | ||
| | `security_content_ctime(lastTime)` | ||
| | `malicious_powershell_executed_as_a_service_filter`' | ||
| how_to_implement: To successfully implement this search, you need to be ingesting Windows System | ||
| logs with the Service name, Service File Name Service Start type, and Service Type | ||
| from your endpoints. | ||
| known_false_positives: Creating a hidden powershell service is rare and could key off of those instances. | ||
| references: | ||
| - https://www.fireeye.com/content/dam/fireeye-www/blog/pdfs/dosfuscation-report.pdf | ||
| - http://az4n6.blogspot.com/2017/ | ||
| - https://www.danielbohannon.com/blog-1/2017/3/12/powershell-execution-argument-obfuscation-how-it-can-make-detection-easier | ||
| tags: | ||
| analytic_story: | ||
| - Malicious Powershell | ||
| dataset: | ||
| - https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1569.002/atomic_red_team/windows-system.log | ||
| kill_chain_phases: | ||
| - Privilege Escalation | ||
| mitre_attack_id: | ||
| - T1569.002 | ||
| product: | ||
| - Splunk Enterprise | ||
| - Splunk Enterprise Security | ||
| - Splunk Cloud | ||
| required_fields: | ||
| - EventCode | ||
| - Service_File_Name | ||
| - Service_Type | ||
| - _time | ||
| - Service_Name | ||
| - Service_Start_Type | ||
| - Service_Account | ||
| - user | ||
| security_domain: endpoint | ||
12 changes: 12 additions & 0 deletions
12
tests/endpoint/malicious_powershell_executed_as_a_service.test.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| name: Malicious Powershell Executed As A Service Unit Test | ||
| tests: | ||
| - name: Malicious Powershell Executed As A Service | ||
| file: endpoint/malicious_powershell_executed_as_a_service.yml | ||
| pass_condition: '| stats count | where count > 0' | ||
| earliest_time: '-24h' | ||
| latest_time: 'now' | ||
| attack_data: | ||
| - file_name: windows-system.log | ||
| data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1569.002/atomic_red_team/windows-system.log | ||
| source: WinEventLog:System | ||
| sourcetype: WinEventLog |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@P4T12ICK could you please modify this a bit ... as it is, it would trigger even if this is not about powershell - for example, if we just find "hid" in the command line.
These are some suggestions:
I would add some other names of the powershell executable: psexec, powershell_ise, and pwsh.exe (https://www.powershelladmin.com/wiki/PowerShell_Executables_File_System_Locations)
Let's strengthen the "hide command" option, such that we add spaces and do some ORs: "* -nop " OR " -nopr " OR ..... OR " -noprofile *". Also, try to add these action-hiding options: https://www.danielbohannon.com/blog-1/2017/3/12/powershell-execution-argument-obfuscation-how-it-can-make-detection-easier
Let's please remove "hid" or make it stronger. Hid is pretty generic and also has a very special meaning in Windows (Human Interface device) ... and I think it has some meaning in the registry too. To that end, we can pull hid outside of the IN clause, and replace it with a couple of AND/OR conditions "* -w hidden " OR " -win hidden *".