Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

59
Beyond the Pentest How C2, Internal Pivoting, and Data Exfiltration Show True Risk Beau Bullock

Transcript of Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Page 1: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Beyond the Pentest

How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Beau Bullock

Page 2: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Beyond the PentestWhat does a standard internal network pentest already cover?

Port scans

Vulnerability scanning

Manual validation

Provide recommendations

Page 3: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

What is Wrong With ThisAttackers don’t vulnerability scan - too noisy

Misses some very critical vulnerabilities

Doesn’t account for domain systems already compromised

Page 4: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

whoamiBeau Bullock

Pentester at Black Hills Information Security

Host of Hack Naked TV

Previously an enterprise defender

OSCP, GXPN, GPEN, GCIH, GCFA, OSWP and GSEC

Page 5: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

What Are We Missing

Three major things

Command and Control

Internal Pivoting

Data Exfiltration

Page 6: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

How Do We Test TheseStart with the basics

Standard domain user account

Lowest level of access typically provisioned

Standard system build

Anyone on leave? Steal their system

Standard network access

Page 7: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Command and Control

Page 8: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Command and ControlThree focus areas

Payload delivery

Email, web, etc.

Client-based protections

AV, application whitelisting, HIDS, etc.

Network-based protections

Egress filtering, IDS/IPS, inline payload detonation

Page 9: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Payload DeliveryWhat can be emailed to your employees?

Executable

PDF

Word DOC or XLS w/ macro

Batch file

Encrypted ZIP

Extensionless files?

Page 10: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Payload DeliveryProtip:

Many webmail services scan attachments for malware

Some don’t allow EXE’s altogether

Yahoo’s MTA does not scan, and allows EXE’s

Use a third-party mail client to send through Yahoo

Page 11: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Payload Delivery

What can be downloaded?

How about browser or Java or Adobe exploits?

Are users allowed to insert USB drives?

Page 12: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Client-Based Protections

Did anything detect the payload after entry?

Anti-Virus

Application whitelisting

SIEM alerts

Page 13: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Client-Based Protections

Payload types

Non-encoded EXE

Encoded EXE

ShellCode injection

Word Doc w/ macro

Software exploit

Physical access (rubber ducky)

Page 14: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Client-Based Protections

Bypassing Client-based protections

Veil-Evasion

Framework for creating custom malware

PowerSploit

Shellcode injection directly into memory

Obfuscation

Page 15: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Network-Based Protections

Was the C2 channel detected?

Firewall block

IDS/IPS detection

Inline Detonation

Page 16: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Network-Based Protections

What does an outbound portscan reveal?

open.zorinaq.com

Weak egress filtering provides more legroom for C2

DLP might miss items not sent over standard ports

Page 17: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: Some Typical C2 Channels

Standard TCP

HTTP/HTTPS

DNS

ICMP

Page 18: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: C2 Through A Web Proxy

Meterpreter Reverse_https

Uses proxy settings on system

PowerShell Empire!!!

Same as above but in PowerShell

Appears as web traffic through your web proxy

Page 19: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk
Page 20: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: C2 Over Social Media

Can your users get to any social media sites?

Twittor - Uses Twitter direct messages as a C2 channel

GCAT - Uses Gmail as a C2 channel

Sneaky-Creeper - Uses Twitter, Tumblr, and Soundcloud as a C2 channel

Page 21: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk
Page 22: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: C2 over DNS

DNScat

Tunnels traffic through DNS requests

C2 channel through NS Records

C2 even with EVERY port blocked outbound from the client

https://github.com/iagox86/dnscat2

Page 23: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk
Page 24: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

C2: C2 over ICMP

Invoke-PowerShellICMP

Tunnels traffic through ICMP echo-requests and echo-replys

ICMP is commonly allowed through firewalls

https://github.com/samratashok/nishang/tree/master/Shells

Page 25: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk
Page 26: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Internal Pivoting

Page 27: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Internal Pivoting

Use built-in tools as a low level user to compromise a network

No vuln scans needed

Less noise

Escalate privileges; locate sensitive data

Page 28: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: GPP PasswordsMay 13, 2014 – MS14-025

Passwords of accounts set by GPP are trivially decrypted!

…by ANY authenticated user on the domain

Located in groups.xml files on SYSVOL

https://msdn.microsoft.com/en-us/library/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be.aspxhttp://blogs.technet.com/b/srd/archive/2014/05/13/ms14-025-an-update-for-group-policy-preferences.aspxhttps://dirteam.com/sander/2014/05/23/security-thoughts-passwords-in-group-policy-preferences-cve-2014-1812/

Page 29: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: GPP PasswordsFirst thing I check for on an internal assessment

Almost always find an admin password here

Find it with:

PowerSploit - Get-GPPPassword

Metasploit GPP Module

Or…C:>findstr /S cpassword %logonserver%\sysvol\*.xml

Page 30: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: Privilege EscalationLocal privilege escalation

Are we already a local admin?

PowerUp

Invoke-AllChecks looks for potential privilege escalation vectors

http://www.verisgroup.com/2014/06/17/powerup-usage/

Page 31: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: Misconfigured Systems

Occasionally, admins get lazy… and do things like add “Domain Users” group to the “Local Administrators” group

Page 32: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: Misconfigured Systems

This means EVERY domain user is now is an administrator of that system

Veil-PowerView Find-LocalAdminAccess

Veil-PowerView Invoke-ShareFinder

http://www.harmj0y.net/blog/penetesting/finding-local-admin-with-the-veil-framework/

Page 33: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: Password Spraying

Domain locks out accounts after a certain number of failed logins

Can’t brute force

Solution:

Try a number of passwords less than the domain lockout policy against EVERY account in the domain

Page 34: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: Password SprayingLockout Policy = Threshold of five

Let’s try one password across every account

What passwords do we try?

Password123

Companyname123

SeasonYear

C:\>@FOR /F %n in (users.txt) DO @FOR /F %p in (pass.txt) DO @net use \\DOMAINCONTROLLER\IPC$ /user:DOMAIN\%n %p 1>NUL 2>&1 && @echo [*] %n:%p && @net use /delete \\DOMAINCONTROLLER\IPC$ > NUL

Page 35: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: Password Spraying

Page 36: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: LLMNR & NBTNS Poison

LLMNR = Link-Local Multicast Name Resolution

NBT-NS = NetBIOS over TCP/IP Name Service

Both help hosts identify each other when DNS fails

Page 37: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: LLMNR & NBTNS Poison

http://www.sternsecurity.com/blog/local-network-attacks-llmnr-and-nbt-ns-poisoning

Page 38: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Pivot: LLMNR & NBTNS Poison

SpiderLabs Responder

Inveigh PowerShell Script

The result is that we obtain NTLM challenge/response hashes

Crack hashes

https://www.trustwave.com/Resources/SpiderLabs-Blog/Introducing-Responder-1-0/

Page 39: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Sensitive Data Hunt

Page 40: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Sensitive Data: Info Disclosure on Shares

Sensitive files on shares?

Find them with PowerView

ShareFinder then FileFinder

FileFinder will find files with the following strings in their title:

‘*pass*’, ‘*sensitive*’, ‘*admin*’, ‘*secret*’, ‘*login*’, ‘*unattend*.xml’, ‘*.vmdk’, ‘*creds*’, or ‘*credential*’ 

Page 41: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Sensitive Data: Locate RDP Jump Hosts

Where are users RDP’ing to?

Can provide insight into where critical systems are

Get-NetComputers | Get-NetRDPSessions | Export-Csv –NoTypeInformation rdpsessions.csv

http://www.harmj0y.net/blog/powershell/powerquinsta/

Page 42: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Sensitive Data: Virtualization Hypervisors

Page 43: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Data Exfiltration

Page 44: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Data ExfiltrationWhat are organizations concerned about leaving their networks? 

PCI data

Patient health information

Personally Identifying Information

Intellectual property

Page 45: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Data Exfiltration

How can attackers get data out of your network? 

Email

Web Access

USB Drive

Photo

Page 46: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Data Exfil: Email

For email is DLP being enforced on the following?

Cleartext in email body

Encoded in email body

Attachments

Optical Character Recognition

Page 47: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Data Exfil: Web

Is all web traffic subject to DLP inspection?

Same types of tests as email are performed but tracking over standard and non-standard web ports

Page 48: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Data Exfil: USB Drives

Are files allowed to be copied to a USB drive?

Encryption

DLP

Blocked completely

Page 49: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Putting It All Together

Page 50: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Attack ScenarioTarget Organization Setup

Firewall only allows outbound traffic through web proxy

AV up to date on clients

Email gateway allows Doc files

Local Administrator account is widespread with same credentials

Page 51: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Attack Scenario

Phishing email is crafted with Word doc attachment

Word doc is weaponized with a Macro

Email is sent to target employee

Page 52: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Attack ScenarioEmployee opens email

Downloads attached .doc

Enables content

Macro runs PowerSploit PowerShell script to inject Meterpreter Reverse_https into memory

Meterpreter C2 channel is established

Page 53: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Attack Scenario

Password spray from the command line

Spring2016?

Run Find-LocalAdminAccess to find where the users are local admin

Pivot using psexec

Page 54: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Attack ScenarioAttacker dumps local user hashes (including local admin)

Local administrator credential is not randomized

Using PowerView UserHunter the attacker finds where Domain Admins are located

Page 55: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Attack ScenarioAttacker pivots to DA workstation

Runs Mimikatz to dump creds from memory

Locates sensitive data with PowerView ShareFinder

Exfils data

Page 56: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk
Page 57: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Summary

Page 58: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Summary

What are the benefits of this style of testing?

Real test of detection and incident response

Shows how an attacker can go from low access to owning the environment

Shows true risk to the organization

Page 59: Beyond the Pentest: How C2, Internal Pivoting, and Data Exfiltration Show True Risk

Thank You!

[email protected]

[email protected]

@dafthack