+ All Categories
Home > Documents > Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault...

Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault...

Date post: 21-Jun-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
68
Mind The Gap Exploit Free Whitelisting Evasion Tactics Casey Smith @subTee
Transcript
Page 1: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Mind  The  GapExploit  Free  Whitelisting  Evasion  TacticsCasey  Smith  @subTee

Page 2: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

C:\>  whoami  /all

USER  INFORMATION  -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐Banker  By  Day  

Red  Team  Lead

Page 3: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

This  talk  seeks  to  explore  the  gaps  in  Application  Whitelisting.    

Page 4: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Trusted  Applications  Can  Circumvent  Whitelisting  Constraints

Page 5: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Architecture

Path  Rules

.NET

Scripting

Emerging  Strengths

Page 6: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Understand:

How  Your  Defenses  Work

&  Where  They  Fail

Page 7: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Why  Exploit  Free?

Exploits  can  be  patched…

Architecture  flaws  cannot.

Page 8: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

“…designed  to  protect  against  unauthorized  and  malicious  programs  executing  on  a  computer.”

Page 9: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

How  is  this  implemented?

Page 10: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Kernel  Mode  Minifilter  Drivers

Page 11: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute
Page 12: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Minifilter/Event  Monitor

Decision  Support/Approval

User  Mode

Kernel  Mode

Page 13: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Trust  DecisionsPathPublisher  (Certificate)Hash

Page 14: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Attacking  Weak  Path  Rules

Page 15: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Vote  For  Your  Favorite  Path  Rule

C:\Windows\*

C:\Windows\TempC:\Windows\Tasks

Page 16: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Vote  For  Your  Favorite  Path  Rule

C:\Windows\System32\*

C:\Windows\System32\Spool\Drivers\Color

Page 17: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Test  and  Validate  &  Limit/Avoid  Path  Rules

Page 18: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

J

Page 19: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Demonstration  One:

AppLocker  Default  Rules

Page 20: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

.NET  Utilities  &  Tactics

Page 21: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Installed  by  default

All  Signed  Microsoft  binaries  trusted  as  a  matter  of  convenience…

Page 22: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

“…An  attacker,  on  the  other  hand,  is  more  interested  in  what  an  application  can  be  made  to  do  and  operates  on  the  principle  that  "any  action  not  specifically  denied,  is  allowed".”  – OWASP  Secure  Coding  Practices  

Page 23: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

See  Also:  Kernel-­‐‑based  monitoring  on  Windows  (32/64  bit)  – Florian  Rienhardthttp://www.bitnuts.de/KernelBasedMonitoring.pdf

Page 24: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Proof  of  Concept  Driver“Soteria”

Page 25: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

The  guidance  provided  is  simply  NOT  going  to  catch  some  .NET  execution  events.

Page 26: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Installed  By  Default

•InstallUtil.exe•Regasm.exe

Signed  By  MicrosoftNo  Admin  Rights  Required  To  Execute

Page 27: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

These  Utilities  Accept  ANYAssembly  as  Input

This  is  the  designed  behavior

Page 28: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Regasm.exe

MyBad.dll

Page 29: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

In  order  to  raise  awareness…

I  wrote  some  tools,  Proof  Of  Concept

Page 30: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

InstallUtil.exe

Page 31: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute
Page 32: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe  /U  katz.exe

C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe  /out:katz.exe  /unsafe  katz.cs

Page 33: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Demonstration  Two:

Mimikatz  Inside  InstallUtil.exe

Page 34: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

InstallUtil  Bypass  in  Metasploit  J

Page 35: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

RegAsm.exe

Page 36: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute
Page 37: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

You  need  Admin  rights  to  register  an  assembly

If  not?

Unregister  function  works  J

Page 38: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Demonstration  Three:

Shellcode  Via  Regasm.exe

Page 39: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Scripting  Languages

Page 40: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Dllhost.exe

Page 41: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Admin  Rights  Required  For  This

Blend  in  with  the  noise…

Page 42: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute
Page 43: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Poweliks  Emulation:

rundll32.exe  javascript:"\..\mshtml,RunHTMLApplication  ";o=new%20ActiveXObject("JS");o.Exec();

Page 44: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute
Page 45: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Whitelisting  does  NOT  prevent  exploitation  of  trusted  applications

Page 46: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Examples:

BrowserOfficeJavaPDF  Readers

Page 47: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Consider  Exploit  Mitigation:

Microsoft  EMET  Can  Be  Highly  Effective

Enhanced  Mitigation  Experience  Toolkit

Page 48: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Demonstration  Four  – Part  1:

EMET  Protecting  Excel  Spreadsheet

Page 49: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

MSHTA.EXE

An  HTA  executes  without the  constraints  of  the  browser  security  model;  in  fact,  it  executes  as  a  "fully  trusted"  application.

Page 50: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

MSHTA.exe

Spawns  Excel

Executes  Macro

Page 51: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Demonstration  Four  – Part  2:  EMET  5.5  Evasion  via  HTA/VBA  Custom  Shellcode

Thanks  To:  Josh  Pitts@midnite_runr  

Page 52: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

EAF  =  Export  Address  Table  Filtering

I’m  running  a  macro.  

I  do  not  need  to  scan  EAT  to  locate  addresses  for  LoadLibraryA,  GetProcAddress

Page 53: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Evasion  Internals  – If  We  Have  Time.

Page 54: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Base  Address GetProcAddress LoadLibraryA

Page 55: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Memory  Base:          089a0000

Page 56: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

GetProcAddress:    76d1cc94

Page 57: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

LoadLibraryA:    76d1dc65

Page 58: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Just  move  lookups  into  VBA  instead  of  ASM.

Page 59: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Conclusion  – 7  Slides  Remaining  

Page 60: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Why  Should  We  Consider  Application  Whitelisting  at  all?

What  does  all  this  mean?

Page 61: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Whitelisting  Works

•Forces  Adversaries  to  Re-­‐Tool/  Burn  Tradecraft• Increases  visibility• Increases  Noise/Tracks  Attackers  Generate•Removes  an  entire  class  of  attacks

Download  and  Execute    For  Example

Page 62: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

New  Directions  – Emerging  Strengths

•Windows  10  Device  Guard• Virtualization  Based  Security  |  Hypervisor  Layer• Provides  For  User  Mode  Code  Integrity  (UMCI)• Caveat…  Not  Trivial  To  Configure/Deploy

• PowerShell   ConstrainedLanguage  Mode

Page 63: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

http://www.alex-­‐ionescu.com/blackhat2015.pdf

References:  http://blogs.technet.com/b/ash/archive/2016/03/02/windows-­‐10-­‐device-­‐guard-­‐and-­‐credential-­‐guard-­‐demystified.aspx

Page 64: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Understand  Where  Gaps  Exist:

•Script  Engines•“Living  Off  The  Land”  –•Misuse  of  trusted  ApplicationsOffice,  .NET,  WMI,  PowerShell  etc…

•Memory  Residence/Injection

Page 65: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Common  Arguments  AgainstWhitelisting  Defenses

•Too  difficult…• Take  it  in  steps,  start  with  your  most  static  machines.  

• It  does  not  stop  everything…• No  defense  is  perfect.  None.  • Run  it  in  Log  Mode  if  nothing  else…• Get  the  visibility  on  Endpoint  executions  and  new  binaries.

Page 66: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Thank  You!

Page 67: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

References

•https://github.com/subTee/Troopers2016

Special  Thanks:•Florian  Rienhardthttp://bitnuts.de/

Page 68: Mind The Gap - Final - Troopers IT-Security Conference · 2019-09-03 · InstalledByDefault •InstallUtil.exe •Regasm.exe Signed(By(Microsoft No(Admin(Rights(Required(To(Execute

Questions?  Feedback?

Please  don’t  hesitate  to  contact  me

Casey  Smith@subTee


Recommended