Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, &...

55
Hacking the Cloud Gerald Steere Microsoft C+E Red Team (@Darkpawh) Sean Metcalf CTO Trimarc (@pyrotek3)

Transcript of Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, &...

Page 1: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Hacking the CloudGerald Steere – Microsoft C+E Red Team (@Darkpawh)

Sean Metcalf – CTO Trimarc (@pyrotek3)

Page 2: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Gerald Steere - @darkpawh

10+ years experience as a penetration tester and red team operatorMember of C+E Red Team since 2014Speaker at BlueHat and Bsides SeattleSpends work days happily smashing atoms in Azure

Abou

t Us

Page 3: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Sean Metcalf - @pyrotek3

Founder Trimarc, a security company. Microsoft Certified Master (MCM) Directory ServicesSpeaker: Black Hat, BSides, DEF CON, DerbyCon, Shakacon, Sp4rkConSecurity Consultant / Security Researcher Own & Operate ADSecurity.org(Microsoft platform security info)

Abou

t Us

+

Page 4: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Cloud FTW!

What’s in it for me?Staying clean while being meanBuzzword bingo with cloud lingoPathfinding, recon, and targeting in multiple dimensionCurrency exchange – what do I do with all these hashes?Happy fun exploit time (with demos)Countermeasures and proper protection

Clou

d? W

ho c

ares

!

Page 5: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

What’s in it for me?

Page 6: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Cloud matters for business

Your client probably uses it, whether you (or they) realize it or notMany traditional techniques do not workSame concepts but new ways of thinkingW

hat’s

in it

for m

e?

Page 7: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

When we last saw our intrepid red team

Hired to red team SithCoHave domain admin on a subsidiary domainSithCo uses public cloud resources to host web applications

Hack

er Q

uest

How do we leverage access to get into SithCo corporate?

Page 8: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Staying clean while being meanCause pissing off The Net is bad for business

Page 9: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Can I really go after my client’s cloud deployments?

We are not lawyers.

If you’re a professional you need one of those to talk to ALWAYS.

Stay

ing

Clea

n

Page 10: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Lawful Evil is a perfectly valid alignment

Scope & Access will be more limitedSpell out enforced limitations in your reportingCloud providers typically require an approval process be followed

Stay

ing

Clea

n

Page 11: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Attacking Azure, AWS, or Google Cloud DeploymentsRequires preapproval by account owner (Azure and AWS)Standard Rules of Engagement (RoE) stuffLimited to customer owned resourcesNo DoSCan include attempts to break isolation (Azure)

Stay

ing

Clea

n

Page 12: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Buzzword BingoDo you have your card ready?

Page 13: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Accessibility modifiers

Public couldPrivate cloudHybrid cloudBu

zzwo

rd B

ingo

https://www.stickermule.com/marketplace/3442-there-is-no-cloud

Page 14: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

All the aaSBu

zzwo

rd B

ingo

Albert Barron – https://www.linkedin.com/pulse/20140730172610-9679881-pizza-as-a-service

Page 15: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

It’s not domain, but it’s still admin

Cloud assets are managed under an account or subscriptionGetting access to that layer is often equivalent to DABu

zzwo

rd B

ingo

Page 16: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

CloudOS - Same ideas, different wordsBu

zzwo

rd B

ingo

Server

Domain

Domain Admin

Pass the Hash

Private IPs

RDP / SSH

Services

Subscription

Subscription Admin

Credential Pivot

Public IPs

Management APIs

Faust and Johnson – Cloud Post Exploitation Techniques Infiltrate 2017 https://vimeo.com/214855977

Page 17: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Where’s the data?

Cloud services rely on data storage for nearly everythingHow is data stored in the cloud?Do I need to attack the service or is the data my real goal?

Buzz

word

Bin

go

Image: ©MITRE

Page 18: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

SithCo’s app hostingW

hat a

re w

e lo

okin

g at

?

Page 19: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Pathfinding, recon, and targeting in multiple dimensionHow do I figure out I even need to look at the cloud?

Page 20: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Identifying Cloud Deployments

In the public cloud –

DNS is your best friend

Path

findi

ng

Page 21: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Cloud Recon: DNS MX Records• Microsoft Office 365:

DOMAIN-COM.mail.protection.outlook.com• Google Apps (G Suite):

*.google OR *.googlemail.com• Proofpoint (pphosted)• Cisco Email Security (iphmx)• Cyren (ctmail)• GoDaddy (secureserver)• CSC (cscdns)

Path

findi

ng

Page 22: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Cloud Recon: DNS TXT RecordsMS = Microsoft Office 365Google-Site-Verification = G SuiteAmazonses = Amazon Simple EmailOSIAGENTREGURL = Symantec MDMAzureWebsites = Microsoft AzurePaychex = Paychex financial servicesDocusign = Docusign digital signaturesAtlassian-* = Atlassian services

Path

findi

ng

Page 23: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Cloud Recon:SPF RecordsSalesForce (salesforce.com, pardot.com, & exacttarget.com)MailChimp (mcsv.net)Mandrill (MailChimp paid app)Q4Press (document collaboration)Zendesk (support ticket)Oracle Marketing (Eloqua.com)Constant Contact (email marketing)Postmark (mtasv.net)

Path

findi

ng

Page 24: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Discover Federation Servers

No standard naming for FS.DNS query for:

• adfs• auth• fs• okta• ping• sso

Path

findi

ng

Page 25: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Federation Web Page DetailPa

thfin

ding

Page 26: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

OWA Version Discovery

Check for autodiscover subdomain (autodiscover.domain.com)Connect to autodiscover web page (https://autodiscover.domain.com)Copyright date effectively provides Exchange version:2006 = Microsoft Exchange 2007

Path

findi

ng

Page 27: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Cloud and FederationAttackers go after Identity since that provides access to resources.

Page 28: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Modern auth

Cloud authentication and authorization is typically independent from the on-premises domain, though Federation may provide a path…How you authenticate will depend on the specific cloud providerMore Buzzword Bingo:

• OAUTH• OpenID• SAML• WS-Federation• WS-Trust

Iden

tity

Page 29: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Iden

tity

Page 30: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

ADFS Federation Server ConfigId

entit

y

Federation server typically lives on the internal network with a proxy server in the DMZ.Certificates installed on Federation server

Service communicationToken-decryptingToken-signing

Relying party trusts: cloud services and applications Claim rules: determine what type of access and from where access is allowed.

Page 31: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Federation Key PointsId

entit

y

Federation: trust between organizations leveraging PKI (certificates matter)Cloud SSO often leverages temporary or persistent browser cookies (cookies provide access)Several protocols may be supported, though typically SAML. (protocols and versions matter)Federation server (or proxy) is on public internet via port 443 (HTTPS).

Page 32: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

How to steal identities – federated styleId

entit

y

Federation is effectively Cloud Kerberos.Own the Federation server, own organizational cloud services.Token & Signing certificates ~= KRBTGT (think Golden Tickets)Steal federation certificates to spoof access tokens (Mimikatz fun later).

Page 33: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

On-Premises Cloud ComponentsHow do we get those identities into the cloud anyways?

Page 34: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Active Directory & the CloudId

entit

y

Active Directory provides Single Sign On (SSO) to cloud services.Some directory sync tools synchronizes all users and their attributes to cloud service(s).Most sync engines only require AD user rights to send user and group information to cloud service.Most organizations aren’t aware of all cloud services active in their environment.

Page 35: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Express Permissions for Azure AD Connect Id

entit

y

https://docs.microsoft.com/en-us/azure/active-directory/connect/active-directory-aadconnect-accounts-permissions

Page 36: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Custom Permissions for Azure AD ConnectId

entit

y

https://docs.microsoft.com/en-us/azure/active-directory/connect/active-directory-aadconnect-accounts-permissions

Page 37: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Currency exchange – what do I do with all these hashes?I never liked buying tokens, but that’s all these things take

Page 38: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Spending our horde

I’ve got all these hashes and no where to goNo matter how many times you’ve popped the KRBTGT account, your cloud provider really doesn’t careCu

rrenc

y ex

chan

ge

Page 39: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Creds, creds never changeCertificates, certificates, certificates!Popping dev boxes has never been more productiveYou do know mimikatz can also export certificates, right?

Curre

ncy

exch

ange

Page 40: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

What is old is new again

Password Spraying involves attempting authentication with a single password against all users before moving on to the next password.Works against Cloud services: email, IM, etc.Low & Slow: 1 to 2 per hourOften works against VPN as well.

Curre

ncy

exch

ange

Page 41: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Password spraying tools

OWA-Toolkit: https://github.com/johnnyDEP/OWA-ToolkitMailSniper: Invoke-PasswordSprayOWAhttps://github.com/dafthack/MailSniper

Patator: https://github.com/lanjelot/patatorLyncSniper: https://github.com/mdsecresearch/LyncSniperhttps://www.mdsec.co.uk/2017/04/penetration-testing-skype-for-business-exploiting-the-missing-lync/

The authors have not evaluated these tools. Always test before use.

Curre

ncy

exch

ange

Page 42: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

DevOopsDevOps probably has what you are looking for

API keys and shared secrets for the winSource code access for fun and profitHow are these deployments done anyways?

Curre

ncy

exch

ange

Page 43: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Where Are API Keys? GitHub!Cu

rrenc

y ex

chan

ge

https://hackernoon.com/how-to-use-environment-variables-keep-your-secret-keys-safe-secure-8b1a7877d69c

https://github.com/jjenkins/node-amazon-ses/issues/9

Page 44: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

The circle of access

Access between on-premises and cloud deployments often a two way street

On-premises -> cloud typically involves identifying credentials

Is there a way back?

Are there shared authentication methods?

Curre

ncy

exch

ange

Page 45: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

The circle of access

What is the likelihood this cloud service needs to access resources from on-premises?Cu

rrenc

y ex

chan

ge

Page 46: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Happy fun exploit timePray to the demo gods, pray I say!

Page 47: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Demo stuff hereCu

rrenc

y ex

chan

ge

There should be a fun live demo here if everything goes right

Page 48: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Countermeasures and proper protectionClosing my eyes and hoping it goes away isn’t going to work, is it?

Page 49: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Giving useful advice

Telling your client to close up shop and moving back into the basement is probably a non-starter

Clouds do provide real business benefits and can improve security when done right

How can the “cloud” be secured?

Coun

term

easu

res

Page 50: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Giving useful advice: The BasicsProperly handle, store, and mange credentials and secrets

You aren’t storing those access keys in GIT are you?Clouds do provide managed secret storesMake it easy for DevOps to do the right thing

Enforce MFA on all accountsIf it can’t have MFA, limit it as much as possible and monitor it

Coun

term

easu

res

Page 51: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Giving useful advice: Securing Federation

Protect Federation servers at the same level as Domain Controllers.Use a proxy server to limit communication directly with federation server inside the network.Audit cloud authentication by logging Federation auth events & send to SIEM.Enable multifactor authentication for all admin accounts & preferably all cloud accounts.Control Cloud authentication via Federation rules. Example:

Internal network access provides single sign-onExternal access requires username, password, and two-factor authentication

Coun

term

easu

res

Page 52: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Giving useful advice

Many of the basics remain the sameLeast privilege is key and poorly understood in many cloud implementationsLeast access, use the security features provided by the cloud

Credential management is hard in a connected world – this is an massive opportunity for attackersCo

unte

rmea

sure

s

Page 53: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

Monitoring and alertingIt’s not just for your network any moreDefenders need to work with DevOps to make sure that cloud resources and data are considered in defensive designsDifferent cloud providers provide different tools for managing securityDefenders must be familiar with the tools from cloud providers used by their clientLog collection and management needs to include cloud assetsYou do know what your assets are, right?Assume breach!

Coun

term

easu

res

Page 54: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

ConclusionAre we there yet?

Page 55: Hacking the Cloud - DEF CON CON 25/DEF CON 25... · SalesForce (salesforce.com, pardot.com, & exacttarget.com) MailChimp (mcsv.net) Mandrill (MailChimp paid app) Q4Press (document

References

Infiltrate 2017: Cloud Post Exploitation Techniques - Andrew Johnson & Sacha Faust https://vimeo.com/214855977Azure Security: https://portal.msrc.microsoft.com/en-us/engage/pentestAWS Security: https://aws.amazon.com/security/penetration-testing/Google Cloud Security: https://cloud.google.com/security/MailSniper: https://github.com/dafthack/MailSniperPatator: https://github.com/lanjelot/patator

Conc

lusio

n