SlideShare una empresa de Scribd logo
1 de 48
Descargar para leer sin conexión
Michel Coene
Tearing apart a fileless
malware sample
SANS@Night
Tearing apart a fileless malware sample
About us
2
Michel Coene
DFIR and Threat hunting @ NVISO
SANS Instructor development program
@coenemichel
Tearing apart a fileless malware sample
What will we talk about today
3
Introduction
Fileless malware
Cryptocurrency mining malware
Tearing apart a sample!
Tearing apart a fileless malware sample
What will we talk about today
4
Introduction
Fileless malware
Cryptocurrency mining malware
Tearing apart a sample!
Tearing apart a fileless malware sample
The cyber kill chain
5
Reconnaissance Delivery Installation
Action on
Objectives
Weaponization Exploitation
Command &
Control
Tearing apart a fileless malware sample
What will we talk about today
6
Introduction
Fileless malware
Cryptocurrency mining malware
Tearing apart a sample!
Tearing apart a fileless malware sample
What is fileless malware
7
Fileless malware is malicious computer code that exclusively exists in
memory and does not write any part of its activity to disk
Persistent Non-persistent
Tearing apart a fileless malware sample
Persistent fileless malware
• Fileless malware
8
Installation
Tearing apart a fileless malware sample
Combining best of both worlds
9
Installation
Tearing apart a fileless malware sample
How it works – deep dive
10
New process (exe) or existing process (DLL)
New process Existing process
Win32: CreateProcess Win32: LoadLibrary
AV
Tearing apart a fileless malware sample
How it works – deep dive
How does fileless malware work
• Inject code
11
Process
(ex. Explorer.exe)
Win32: CreateProcess
Custom loader
Malicious
code
Tearing apart a fileless malware sample
How it works – deep dive – Fileless code
12
• The code for fileless malware can take several forms:
• Shellcode
• VirtualAlloc
• WriteProcessMemory
• CreateThread/CreateRemoteThread
• DLL
• Custom loader
• Reflective loader
• …
• Advantage of coding a DLL
• Many powerful development tools (Visual Studio)
• Reusing code
Tearing apart a fileless malware sample
How it works – deep dive - PowerShell
13
• PowerShell is a very powerful programming language
• Win32 API
• .NET Framework
• ActiveX
• …
• Facilitates administration of Windows (legitimate application)
• So versatile and powerful that it is often used as loader and host for
fileless malware
• powershell –Command …
• Powershell –EncodedCommand …
Tearing apart a fileless malware sample
How it works – deep dive - PowerShell
14
Library .NET code
Tearing apart a fileless malware sample
How it works – deep dive - PowerShell
15
Encoded Command
Library .NET code
Tearing apart a fileless malware sample
How to detect?
16
No files you say?
Tearing apart a fileless malware sample
How to detect?
17
Tearing apart a fileless malware sample
How to detect?
18
HKLMSoftwareMicrosoftWindowsCurrentVersionRun
HKCU SoftwareMicrosoftWindowsCurrentVersionRun
HKLMSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorerRun
HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorerRun
Tearing apart a fileless malware sample
How to detect?
19
Tearing apart a fileless malware sample
How to detect?
20
Tearing apart a fileless malware sample
How to detect?
21
Hunt for suspicious registry run
keys and scheduled tasks
Behavior based detection
Look for known IOCs:
- C2 traffic
- Specific registry keys
- Specific scheduled tasks
Prevent known malicious items from
entering your environment
Tearing apart a fileless malware sample
What will we talk about today
22
Introduction
Fileless malware
Cryptocurrency mining malware
Tearing apart a sample!
Tearing apart a fileless malware sample
Cryptocurrency mining malware - What is it? What does it do?
23
Action on
Objectives
Tearing apart a fileless malware sample
In browser mining
24
Delivery
Source: blog.malwarebytes.com
Tearing apart a fileless malware sample
Evolution from ransomware to cryptocurrency mining malware
25
• Ransomware attacks are becoming
harder to execute
• Microsoft adding Controlled folder access feature to
Windows Defender Security for Windows 10 users
to prevent malicious (or unexpected) alteration of
important files.
• Everyone advises against paying
• Easily detected
• Countries and regions available that
cannot pay the ransom
• Cryptocurrency mining often flies
under the radar
Source: blog.fortinet.com
Tearing apart a fileless malware sample
Implications for companies
26
• Power
• Cost
• Might harm production environment
(CPU, stability, might kill processes, etc)
Tearing apart a fileless malware sample
What will we talk about today
27
Introduction
Fileless malware
Cryptocurrency mining malware
Tearing apart a sample!
Tearing apart a fileless malware sample
Detecting malware
• AV detection for files originally based on signatures (sequence
of bytes / heuristics)
• On disk, Windows has provided filters for the file system (intercept all
bytes accessed from disk)
• A similar mechanism does not exist for memory
•  AV detection bypass
• Next option to detect fileless malware: observe behavior
• Is this program encrypting files? Strange, this could be ransomware …
• Is this program mining crypto currency? OK, this could be benign …
• Not all AVs have (advanced) behavior analysis engines
Process
AV
Tearing apart a fileless malware sample
Our sample
• How did we know there was malware about?
• No AV alerts
• Observed TCP connections to a Monero mining pool
• Observed a PowerShell process consuming a lot of CPU
• How did we sample the malware?
• Specialized task managers like Process Explorer can inspect
the command line of processes
• powershell -EncodedCommand QQBkAGQALQBUAHk…
• … and show the parent process
• task scheduler
• The BASE64-decoded PowerShell script accessed a value in the registry
• {95EF38A4-95F9-55C1-55302E9FD8427349}=AAAId0wBAAOWAAADKWBNWpAA…
• Create mem dump of process & carve executables
Tearing apart a fileless malware sample
The loader
Registry
32-bit/64-bit
BASE64
Tearing apart a fileless malware sample
The loader
Win32 API
Win32 API
Tearing apart a fileless malware sample
The “package”
Embedded PE
file
Tearing apart a fileless malware sample
The “package”
The “package” is
known to
VirusTotal, and
triggers AV
Tearing apart a fileless malware sample
The “package”
“Trojan injector cvt”
does not yield
valuable information
Tearing apart a fileless malware sample
The “package”
The carved DLL has
been analyzed
before, without
success
Tearing apart a fileless malware sample
Dynamic analysis
• No useful info online: We had to analyze the sample ourselves
• Create a .ps1 file combining the loader and the “package”
• Focus dynamic analysis
• Submit it to sandboxes
• Run it on physical machine
Tearing apart a fileless malware sample
Mining activity
• Tearing apart a sample
Tearing apart a fileless malware sample
Mining activity
On 22/02/2018:
- 1 XMR = 255 EUR
- 600 XMR = 153 156 EUR
On 17/04/2018
- 1 XMR = 161 EUR
- 663 XMR = 106 743EUR
Tearing apart a fileless malware sample
Mining activity
Time in UTC
Tearing apart a fileless malware sample
Mining activity
• Tearing apart a sample
Tearing apart a fileless malware sample
Worm activity
Scanning port 445?
An EternalBlue worm?
Tearing apart a fileless malware sample
Worm activity
EternalBlue/Shellcode
Gitlab
“Package”
1) Persistence on Windows XP: file based
2) Persistence on > Windows XP: fileless
SMB1 = 0
Immunize!
Tearing apart a fileless malware sample
Worm activity
Active since
August 2017
A history of
versions
Tearing apart a fileless malware sample
Info stealing activity
Why is it accessing
these files?
Why is it
connecting
to Tor?
Tearing apart a fileless malware sample
Info stealing activity
FileZilla
storing
credentials
Tearing apart a fileless malware sample
Info stealing activity
FileZilla
credentials file
read into
memory
FileZilla credentials
decoded
Tearing apart a fileless malware sample
Concluding
51
Miner Worm
Info stealer
Q&A
@coenemichel
53

Más contenido relacionado

La actualidad más candente

BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
BlueHat Security Conference
 
Csw2016 freingruber bypassing_application_whitelisting
Csw2016 freingruber bypassing_application_whitelistingCsw2016 freingruber bypassing_application_whitelisting
Csw2016 freingruber bypassing_application_whitelisting
CanSecWest
 

La actualidad más candente (20)

Ch0 1
Ch0 1Ch0 1
Ch0 1
 
Taking Hunting to the Next Level: Hunting in Memory
Taking Hunting to the Next Level: Hunting in MemoryTaking Hunting to the Next Level: Hunting in Memory
Taking Hunting to the Next Level: Hunting in Memory
 
Hunting For Exploit Kits
Hunting For Exploit KitsHunting For Exploit Kits
Hunting For Exploit Kits
 
Anti-virus Mechanisms and Various Ways to Bypass Antivirus detection
Anti-virus Mechanisms and Various Ways to Bypass Antivirus detectionAnti-virus Mechanisms and Various Ways to Bypass Antivirus detection
Anti-virus Mechanisms and Various Ways to Bypass Antivirus detection
 
Automating Malware Analysis
Automating Malware AnalysisAutomating Malware Analysis
Automating Malware Analysis
 
Metasploit for Web Workshop
Metasploit for Web WorkshopMetasploit for Web Workshop
Metasploit for Web Workshop
 
SANS Windows Artifact Analysis 2012
SANS Windows Artifact Analysis 2012SANS Windows Artifact Analysis 2012
SANS Windows Artifact Analysis 2012
 
Malware Analysis 101 - N00b to Ninja in 60 Minutes at BSidesLV on August 5, ...
Malware Analysis 101 -  N00b to Ninja in 60 Minutes at BSidesLV on August 5, ...Malware Analysis 101 -  N00b to Ninja in 60 Minutes at BSidesLV on August 5, ...
Malware Analysis 101 - N00b to Ninja in 60 Minutes at BSidesLV on August 5, ...
 
Hunting Lateral Movement in Windows Infrastructure
Hunting Lateral Movement in Windows InfrastructureHunting Lateral Movement in Windows Infrastructure
Hunting Lateral Movement in Windows Infrastructure
 
Endpoint is not enough
Endpoint is not enoughEndpoint is not enough
Endpoint is not enough
 
Introduction to Dynamic Malware Analysis ...Or am I "Cuckoo for Malware?"
Introduction to Dynamic Malware Analysis   ...Or am I "Cuckoo for Malware?"Introduction to Dynamic Malware Analysis   ...Or am I "Cuckoo for Malware?"
Introduction to Dynamic Malware Analysis ...Or am I "Cuckoo for Malware?"
 
Automating malware analysis
Automating malware analysis Automating malware analysis
Automating malware analysis
 
Antivirus is hopeless
Antivirus is hopelessAntivirus is hopeless
Antivirus is hopeless
 
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
BlueHat v17 || Dyre to Trickbot: An Inside Look at TLS-Encrypted Command-And-...
 
Csw2016 freingruber bypassing_application_whitelisting
Csw2016 freingruber bypassing_application_whitelistingCsw2016 freingruber bypassing_application_whitelisting
Csw2016 freingruber bypassing_application_whitelisting
 
BlueHat v17 || Out of the Truman Show: VM Escape in VMware Gracefully
BlueHat v17 || Out of the Truman Show: VM Escape in VMware Gracefully BlueHat v17 || Out of the Truman Show: VM Escape in VMware Gracefully
BlueHat v17 || Out of the Truman Show: VM Escape in VMware Gracefully
 
Hunting Rootkit From the Dark Corners Of Memory
Hunting Rootkit From the Dark Corners Of MemoryHunting Rootkit From the Dark Corners Of Memory
Hunting Rootkit From the Dark Corners Of Memory
 
Investigating Hackers' Tools
Investigating Hackers' ToolsInvestigating Hackers' Tools
Investigating Hackers' Tools
 
CNIT 126 11. Malware Behavior
CNIT 126 11. Malware BehaviorCNIT 126 11. Malware Behavior
CNIT 126 11. Malware Behavior
 
Malware analysis - What to learn from your invaders
Malware analysis - What to learn from your invadersMalware analysis - What to learn from your invaders
Malware analysis - What to learn from your invaders
 

Similar a Sans london april sans at night - tearing apart a fileless malware sample

The Power of Malware Analysis and Development.pdf
The Power of Malware Analysis and Development.pdfThe Power of Malware Analysis and Development.pdf
The Power of Malware Analysis and Development.pdf
lior mazor
 
BSidesCharleston2014 - Ballin on a Budget: Tracking Chinese Malware Campaigns...
BSidesCharleston2014 - Ballin on a Budget: Tracking Chinese Malware Campaigns...BSidesCharleston2014 - Ballin on a Budget: Tracking Chinese Malware Campaigns...
BSidesCharleston2014 - Ballin on a Budget: Tracking Chinese Malware Campaigns...
Andrew Morris
 
Алексей Старов - Как проводить киберраследования?
Алексей Старов - Как проводить киберраследования?Алексей Старов - Как проводить киберраследования?
Алексей Старов - Как проводить киберраследования?
HackIT Ukraine
 
EMBA Firmware analysis - TROOPERS22
EMBA Firmware analysis - TROOPERS22EMBA Firmware analysis - TROOPERS22
EMBA Firmware analysis - TROOPERS22
MichaelM85042
 

Similar a Sans london april sans at night - tearing apart a fileless malware sample (20)

Malware analysis _ Threat Intelligence Morocco
Malware analysis _ Threat Intelligence MoroccoMalware analysis _ Threat Intelligence Morocco
Malware analysis _ Threat Intelligence Morocco
 
SANS Digital Forensics and Incident Response Poster 2012
SANS Digital Forensics and Incident Response Poster 2012SANS Digital Forensics and Incident Response Poster 2012
SANS Digital Forensics and Incident Response Poster 2012
 
The Power of Malware Analysis and Development.pdf
The Power of Malware Analysis and Development.pdfThe Power of Malware Analysis and Development.pdf
The Power of Malware Analysis and Development.pdf
 
CONFidence 2017: Hiding in plain sight (Adam Burt)
CONFidence 2017: Hiding in plain sight (Adam Burt)CONFidence 2017: Hiding in plain sight (Adam Burt)
CONFidence 2017: Hiding in plain sight (Adam Burt)
 
Intro2 malwareanalysisshort
Intro2 malwareanalysisshortIntro2 malwareanalysisshort
Intro2 malwareanalysisshort
 
Lecture 12 malicious software
Lecture 12 malicious software Lecture 12 malicious software
Lecture 12 malicious software
 
BSidesCharleston2014 - Ballin on a Budget: Tracking Chinese Malware Campaigns...
BSidesCharleston2014 - Ballin on a Budget: Tracking Chinese Malware Campaigns...BSidesCharleston2014 - Ballin on a Budget: Tracking Chinese Malware Campaigns...
BSidesCharleston2014 - Ballin on a Budget: Tracking Chinese Malware Campaigns...
 
Hacktrikz - Introduction to Information Security & Ethical Hacking
Hacktrikz - Introduction to Information Security & Ethical HackingHacktrikz - Introduction to Information Security & Ethical Hacking
Hacktrikz - Introduction to Information Security & Ethical Hacking
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
 
Security by Weston Hecker
Security by Weston HeckerSecurity by Weston Hecker
Security by Weston Hecker
 
Malware Static Analysis
Malware Static AnalysisMalware Static Analysis
Malware Static Analysis
 
Tech w23
Tech w23Tech w23
Tech w23
 
Deeplook into apt and how to detect and defend v1.0
Deeplook into apt and how to detect and defend v1.0Deeplook into apt and how to detect and defend v1.0
Deeplook into apt and how to detect and defend v1.0
 
Алексей Старов - Как проводить киберраследования?
Алексей Старов - Как проводить киберраследования?Алексей Старов - Как проводить киберраследования?
Алексей Старов - Как проводить киберраследования?
 
Advanced Persistent Threats
Advanced Persistent ThreatsAdvanced Persistent Threats
Advanced Persistent Threats
 
EMBA Firmware analysis - TROOPERS22
EMBA Firmware analysis - TROOPERS22EMBA Firmware analysis - TROOPERS22
EMBA Firmware analysis - TROOPERS22
 
Commodity malware means YOU
Commodity malware means YOUCommodity malware means YOU
Commodity malware means YOU
 
Building next gen malware behavioural analysis environment
Building next gen malware behavioural analysis environment Building next gen malware behavioural analysis environment
Building next gen malware behavioural analysis environment
 
Sandbox detection: leak, abuse, test - Hacktivity 2015
Sandbox detection: leak, abuse, test - Hacktivity 2015Sandbox detection: leak, abuse, test - Hacktivity 2015
Sandbox detection: leak, abuse, test - Hacktivity 2015
 
Keith J. Jones, Ph.D. - Crash Course malware analysis
Keith J. Jones, Ph.D. - Crash Course malware analysisKeith J. Jones, Ph.D. - Crash Course malware analysis
Keith J. Jones, Ph.D. - Crash Course malware analysis
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Sans london april sans at night - tearing apart a fileless malware sample

  • 1. Michel Coene Tearing apart a fileless malware sample SANS@Night
  • 2. Tearing apart a fileless malware sample About us 2 Michel Coene DFIR and Threat hunting @ NVISO SANS Instructor development program @coenemichel
  • 3. Tearing apart a fileless malware sample What will we talk about today 3 Introduction Fileless malware Cryptocurrency mining malware Tearing apart a sample!
  • 4. Tearing apart a fileless malware sample What will we talk about today 4 Introduction Fileless malware Cryptocurrency mining malware Tearing apart a sample!
  • 5. Tearing apart a fileless malware sample The cyber kill chain 5 Reconnaissance Delivery Installation Action on Objectives Weaponization Exploitation Command & Control
  • 6. Tearing apart a fileless malware sample What will we talk about today 6 Introduction Fileless malware Cryptocurrency mining malware Tearing apart a sample!
  • 7. Tearing apart a fileless malware sample What is fileless malware 7 Fileless malware is malicious computer code that exclusively exists in memory and does not write any part of its activity to disk Persistent Non-persistent
  • 8. Tearing apart a fileless malware sample Persistent fileless malware • Fileless malware 8 Installation
  • 9. Tearing apart a fileless malware sample Combining best of both worlds 9 Installation
  • 10. Tearing apart a fileless malware sample How it works – deep dive 10 New process (exe) or existing process (DLL) New process Existing process Win32: CreateProcess Win32: LoadLibrary AV
  • 11. Tearing apart a fileless malware sample How it works – deep dive How does fileless malware work • Inject code 11 Process (ex. Explorer.exe) Win32: CreateProcess Custom loader Malicious code
  • 12. Tearing apart a fileless malware sample How it works – deep dive – Fileless code 12 • The code for fileless malware can take several forms: • Shellcode • VirtualAlloc • WriteProcessMemory • CreateThread/CreateRemoteThread • DLL • Custom loader • Reflective loader • … • Advantage of coding a DLL • Many powerful development tools (Visual Studio) • Reusing code
  • 13. Tearing apart a fileless malware sample How it works – deep dive - PowerShell 13 • PowerShell is a very powerful programming language • Win32 API • .NET Framework • ActiveX • … • Facilitates administration of Windows (legitimate application) • So versatile and powerful that it is often used as loader and host for fileless malware • powershell –Command … • Powershell –EncodedCommand …
  • 14. Tearing apart a fileless malware sample How it works – deep dive - PowerShell 14 Library .NET code
  • 15. Tearing apart a fileless malware sample How it works – deep dive - PowerShell 15 Encoded Command Library .NET code
  • 16. Tearing apart a fileless malware sample How to detect? 16 No files you say?
  • 17. Tearing apart a fileless malware sample How to detect? 17
  • 18. Tearing apart a fileless malware sample How to detect? 18 HKLMSoftwareMicrosoftWindowsCurrentVersionRun HKCU SoftwareMicrosoftWindowsCurrentVersionRun HKLMSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorerRun HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorerRun
  • 19. Tearing apart a fileless malware sample How to detect? 19
  • 20. Tearing apart a fileless malware sample How to detect? 20
  • 21. Tearing apart a fileless malware sample How to detect? 21 Hunt for suspicious registry run keys and scheduled tasks Behavior based detection Look for known IOCs: - C2 traffic - Specific registry keys - Specific scheduled tasks Prevent known malicious items from entering your environment
  • 22. Tearing apart a fileless malware sample What will we talk about today 22 Introduction Fileless malware Cryptocurrency mining malware Tearing apart a sample!
  • 23. Tearing apart a fileless malware sample Cryptocurrency mining malware - What is it? What does it do? 23 Action on Objectives
  • 24. Tearing apart a fileless malware sample In browser mining 24 Delivery Source: blog.malwarebytes.com
  • 25. Tearing apart a fileless malware sample Evolution from ransomware to cryptocurrency mining malware 25 • Ransomware attacks are becoming harder to execute • Microsoft adding Controlled folder access feature to Windows Defender Security for Windows 10 users to prevent malicious (or unexpected) alteration of important files. • Everyone advises against paying • Easily detected • Countries and regions available that cannot pay the ransom • Cryptocurrency mining often flies under the radar Source: blog.fortinet.com
  • 26. Tearing apart a fileless malware sample Implications for companies 26 • Power • Cost • Might harm production environment (CPU, stability, might kill processes, etc)
  • 27. Tearing apart a fileless malware sample What will we talk about today 27 Introduction Fileless malware Cryptocurrency mining malware Tearing apart a sample!
  • 28. Tearing apart a fileless malware sample Detecting malware • AV detection for files originally based on signatures (sequence of bytes / heuristics) • On disk, Windows has provided filters for the file system (intercept all bytes accessed from disk) • A similar mechanism does not exist for memory •  AV detection bypass • Next option to detect fileless malware: observe behavior • Is this program encrypting files? Strange, this could be ransomware … • Is this program mining crypto currency? OK, this could be benign … • Not all AVs have (advanced) behavior analysis engines Process AV
  • 29. Tearing apart a fileless malware sample Our sample • How did we know there was malware about? • No AV alerts • Observed TCP connections to a Monero mining pool • Observed a PowerShell process consuming a lot of CPU • How did we sample the malware? • Specialized task managers like Process Explorer can inspect the command line of processes • powershell -EncodedCommand QQBkAGQALQBUAHk… • … and show the parent process • task scheduler • The BASE64-decoded PowerShell script accessed a value in the registry • {95EF38A4-95F9-55C1-55302E9FD8427349}=AAAId0wBAAOWAAADKWBNWpAA… • Create mem dump of process & carve executables
  • 30. Tearing apart a fileless malware sample The loader Registry 32-bit/64-bit BASE64
  • 31. Tearing apart a fileless malware sample The loader Win32 API Win32 API
  • 32. Tearing apart a fileless malware sample The “package” Embedded PE file
  • 33. Tearing apart a fileless malware sample The “package” The “package” is known to VirusTotal, and triggers AV
  • 34. Tearing apart a fileless malware sample The “package” “Trojan injector cvt” does not yield valuable information
  • 35. Tearing apart a fileless malware sample The “package” The carved DLL has been analyzed before, without success
  • 36. Tearing apart a fileless malware sample Dynamic analysis • No useful info online: We had to analyze the sample ourselves • Create a .ps1 file combining the loader and the “package” • Focus dynamic analysis • Submit it to sandboxes • Run it on physical machine
  • 37. Tearing apart a fileless malware sample Mining activity • Tearing apart a sample
  • 38. Tearing apart a fileless malware sample Mining activity On 22/02/2018: - 1 XMR = 255 EUR - 600 XMR = 153 156 EUR On 17/04/2018 - 1 XMR = 161 EUR - 663 XMR = 106 743EUR
  • 39. Tearing apart a fileless malware sample Mining activity Time in UTC
  • 40. Tearing apart a fileless malware sample Mining activity • Tearing apart a sample
  • 41. Tearing apart a fileless malware sample Worm activity Scanning port 445? An EternalBlue worm?
  • 42. Tearing apart a fileless malware sample Worm activity EternalBlue/Shellcode Gitlab “Package” 1) Persistence on Windows XP: file based 2) Persistence on > Windows XP: fileless SMB1 = 0 Immunize!
  • 43. Tearing apart a fileless malware sample Worm activity Active since August 2017 A history of versions
  • 44. Tearing apart a fileless malware sample Info stealing activity Why is it accessing these files? Why is it connecting to Tor?
  • 45. Tearing apart a fileless malware sample Info stealing activity FileZilla storing credentials
  • 46. Tearing apart a fileless malware sample Info stealing activity FileZilla credentials file read into memory FileZilla credentials decoded
  • 47. Tearing apart a fileless malware sample Concluding 51 Miner Worm Info stealer