purple view

100
Purple View The recent trend of using Attack and Defense Together Not OUR idea - backed by many @raffertylaura | @haydnjohnson

Upload: haydn-johnson

Post on 07-Jan-2017

674 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: Purple View

Purple ViewThe recent trend of using Attack and Defense

Together

Not OUR idea - backed by many@raffertylaura | @haydnjohnson

Page 2: Purple View

Quick who are weHaydn Johnson

@haydnjohnson

OSCP

Offensive/Attack Interest

Enjoys presenting

Laura

@raffertylaura

MSc Computer Science (Security/Privacy)

Interested in both sides of security

Loooooves presenting

@raffertylaura | @haydnjohnson

Page 3: Purple View

Contents1. Basic Term Definition2. Introduction to Red, Blue and Purple3. Run through of an Attack

○ Gaining Access○ Lateral Movement○ Domain Admin○ Maintaining Access○ Data Exfiltration

4. For each attack:○ Attacking View○ Defenders View○ Possible Purple Team exercises

@raffertylaura | @haydnjohnson

Page 4: Purple View

DefinitionsExploit - The thing used to gain unauthorized access to a system

Payload - What is done after the access is gained (shell, command)

Metasploit - An open source exploit framework, modular

Meterpreter - an advanced, extensible payload that uses in-memory DLL injection

Shell - Gaining Terminal/CMD access remotely

https://www.offensive-security.com/metasploit-unleashed/about-meterpreter/http://www.metasploit.com/

Page 5: Purple View

Red Team - Penetration | Offensive● Scans● Exploits● Logic abuse● Access to things they shouldn’t

@raffertylaura | @haydnjohnson

Page 6: Purple View

Blue Team - Block, Prevent, Detect | Defensive● Logs● Emails● Events● Triggers● Networking● More Logs

@raffertylaura | @haydnjohnson

Page 7: Purple View

Red Team - Goals● Model recent threats and trends● Longer term● Highlight Gaps in Security Controls, detection etc● Escape and Evade for Persistence

@raffertylaura | @haydnjohnson

Page 8: Purple View

Blue Team - Goals

● Detect Attack● Respond and Recover● Produce Actionable Intelligence● Identify Gaps and investment needs

@raffertylaura | @haydnjohnson

Page 9: Purple View

Purple Team - Offensive & DefensiveWorking together to achieve the ultimate goal of making the organization more secure

● Exposes blue team to different threats & attacker mindset ● Test incident detection and response● Allows red team to sharpen skills● Policy and procedures tested● Tuning of controls

@raffertylaura | @haydnjohnson

Page 10: Purple View

Purple Team - Offensive & DefensiveDifferent types of Purple Teaming

● Read Team Sitting with Network Defense team● Adversary Simulation● Traffic Generation● cobaltstrike.com● Wargaming

Requires total picture involving all areas of the organization

@raffertylaura | @haydnjohnson

Page 11: Purple View

Purple Team - The difference● Using Security Posture and Weaknesses to find what is most valuable● Goal Oriented● Review attack● Test how teams use services and how they are managed

@raffertylaura | @haydnjohnson

Page 12: Purple View

Purple Team - The difference● Time to Domain Admin● Time to Data/Objective● Time to Respond● Time to Recover● Identify where there needs to be more investment● Measure Impact

Done right, the blue team should come out with better monitoring and response plans.

@raffertylaura | @haydnjohnson

Page 13: Purple View

Purple Team - The difference● Set up a fake scenario - Assume Breach● How will the attacker gain access?● Why have they attacked, what do they want?● How did they move through the network?● If they exfiltrated data, how?

Do not turn off servers, block IP addresses, make it realistic

@raffertylaura | @haydnjohnson

Page 14: Purple View

Purple Team - Exercise“In the beginning, it’s easy to challenge and exercise a network defense team. You will find that many network defenders do not have a lot of experience (actively) dealing with a sophisticated adversary.”

- Raphael Mudge

http://blog.cobaltstrike.com/2014/11/12/adversary-simulation-becomes-a-thing/

@raffertylaura | @haydnjohnson

Page 15: Purple View

Purple Team - DEMO (step by step)Our exercise

@raffertylaura | @haydnjohnson

Page 16: Purple View

Purple Team - Demo Architecture

@raffertylaura | @haydnjohnson

Domain: corp.test.com

Page 17: Purple View

Tools UsedRed Team:

● Kali Linux● Metasploit● Meterpreter● PowerSploit● Twittor

Blue Team:

● Wireshark● Windows Event Logs

@raffertylaura | @haydnjohnson

Page 18: Purple View

Setting up Windows GP

@raffertylaura | @haydnjohnson

Page 19: Purple View

Gaining AccessHacking Team Flash Exploit

@raffertylaura | @haydnjohnson

Page 20: Purple View

Flash Exploits

@raffertylaura | @haydnjohnson

● Flash plugins are vulnerable ○ You can embed a javascript/binary within a Flash file○ ActionScript to define events to redirect to landing page

● Most exploit kit landing pages redirect to pages containing Flash exploits○ Angler○ Nuclear○ Fiesta

● Installed by default on browser● New vulnerabilities are identified on almost a weekly basis

Page 21: Purple View

Gaining Access

@raffertylaura | @haydnjohnson

Flash 18.0.0.194

Page 22: Purple View

A: Flash Exploit from SecurityFocus

Hacking Team Flash Exploit: http://downloads.securityfocus.com/vulnerabilities/exploits/75568.rb

Page 23: Purple View

A: Start Flash Exploit from Kali

@raffertylaura | @haydnjohnson

Page 24: Purple View

A: Start Flash Exploit from Kali

@raffertylaura | @haydnjohnson

Page 25: Purple View

Client1 User navigates to malicious site which redirects to the exploit

A: Redirect Victim

@raffertylaura | @haydnjohnson

Page 26: Purple View

A: Client1 is exploited

@raffertylaura | @haydnjohnson

Page 27: Purple View

A: A session is now established with Client1We can now run Meterpreter

@raffertylaura | @haydnjohnson

Page 28: Purple View

B: Wireshark: Landing Page and Redirect

@raffertylaura | @haydnjohnson

Page 29: Purple View

B: Wireshark: Shell

@raffertylaura | @haydnjohnson

Page 30: Purple View

B: What can you take awaySecurity Onion, implement it, free

Has snort rules for Flash exploits (need to install)

Confirm if flash is needed for business reasons

Keep flash updated

2811962 - ETPRO TROJAN APT HTTPBrowser dropped by CVE-2015-5119 SSL Cert (trojan.rules) 2811963 - ETPRO TROJAN APT HTTPBrowser dropped by CVE-2015-5119 CnC Beacon (trojan.rules)

@raffertylaura | @haydnjohnson

https://www.security-database.com/detail.php?alert=CVE-2015-5119https://security-onion-solutions.github.io/security-onion/

Page 31: Purple View

Purple Team - Exercise● Blue team understands how attackers can gain initial access● Flash exploits - ongoing issue ● Helps blue team to identify suspicious traffic and what is happening from the

attacker perspective● Red team sees how attacks are visible by blue team and think of ways to

make it more stealthy

@raffertylaura | @haydnjohnson

Page 32: Purple View

Privilege EscalationNot Shown

@raffertylaura | @haydnjohnson

Page 33: Purple View

Privilege Escalation● We are skipping privilege escalation from Domain User to Local Admin

@raffertylaura | @haydnjohnson

Page 34: Purple View

Lateral MovementPowerSploit

@raffertylaura | @haydnjohnson

Page 35: Purple View

A: PowerSploitAvailable on Github

Open Source

https://github.com/mattifestation/PowerSploit@raffertylaura | @haydnjohnson

Page 36: Purple View

A: PowerSploit

More than 1 script!

PowerShell Modules

@raffertylaura | @haydnjohnson

Page 37: Purple View

PowerViewPart of PowerShell Empire

Very advanced

https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerView @raffertylaura | @haydnjohnson

Page 38: Purple View

A: Lateral MovementThe same local Administrator account passwords on multiple computers.

by Sean Metcalf

https://adsecurity.org/?p=1684@raffertylaura | @haydnjohnson

Page 39: Purple View

Same Passwords for All Local Admins

Page 40: Purple View

A: Lateral Movement

@raffertylaura | @haydnjohnson

Page 41: Purple View

A: Lateral MovementPowersploit

Remote Powershell

Using Invoke--Shellcode.ps1

@raffertylaura | @haydnjohnson

Page 42: Purple View

A: Base64 Encoding PayloadRemove issues with whitespace

The Hacker Playbook 1 (now 2)

@raffertylaura | @haydnjohnsonhttp://thehackerplaybook.com/dashboard/

Page 43: Purple View

A: Hosting Powersploit Invoke--Shellcode.ps1PowerSploit code hosted on local Kali machine

@raffertylaura | @haydnjohnson

Page 44: Purple View

A: Invoke-WmiMethodUse powershell to connect remotely, create a new process and launch the IEX cradle.

Calls Windows Management Instrumentation (WMI) methods.

The Win32_Process WMI class allows creation of a process.

@raffertylaura | @haydnjohnson

Page 45: Purple View

A: Execute Remote commandExecute command from Client1 to tell Client2 to download and execute shellcode

@raffertylaura | @haydnjohnson

Page 46: Purple View

A: Client1 gives same passwordSame password across multiple clients

@raffertylaura | @haydnjohnson

Page 47: Purple View

A: Receive Shell

@raffertylaura | @haydnjohnson

Page 48: Purple View

B: WireShark trafficTCP Hand Shake

Bind Requests

@raffertylaura | @haydnjohnson

Page 49: Purple View

B: Client1 requests remote instance on Client2

@raffertylaura | @haydnjohnson

Page 50: Purple View

B: Client2 eventually asks where is Kali

@raffertylaura | @haydnjohnson

Page 51: Purple View

B: Client2 downloads Invoke--Shellcode.ps1

@raffertylaura | @haydnjohnson

Page 52: Purple View

B: Client1 logs into Client2

@raffertylaura | @haydnjohnson

Page 53: Purple View

B: PowerShell Process Created

@raffertylaura | @haydnjohnson

Page 54: Purple View

B: PowerShell connects to KaliClient2 reaches out to Kali on port 80

@raffertylaura | @haydnjohnson

Page 55: Purple View

B: What can you take awayEvent Correlation - based on event ID, source and destination for remote connections

Implement alerting based on Security Events together

SIEM can/SHOULD do this

Use Log MD - really great logging tool, especially for powershell

@raffertylaura | @haydnjohnson

http://brakeingsecurity.com/2015-042-log_md-more-malware-archaeology-and-sifting-through-the-junk

http://malwarearchaeology.squarespace.com/log-md/

Page 56: Purple View

Purple Team - Benefits● Identify ways to move around the network● Identify and confirm Defensive Controls in Place● Identify what worked, what did not● Implement changes● Justification for resources

@raffertylaura | @haydnjohnson

Page 57: Purple View

Privilege EscalationLocal Admin to Domain Admin

@raffertylaura | @haydnjohnson

Page 58: Purple View

A: Local Admin to Domain Admin

@raffertylaura | @haydnjohnson

● Why escalate privileges from Local Admin to Domain Admin?● Domain admin - control over active directory!● Access IT resources● Create accounts● Propagate malware

Page 59: Purple View

A: Local Admin to Domain Admin

@raffertylaura | @haydnjohnson

Page 60: Purple View

A: Local Admin to Domain AdminFrom Client1, map the admin$ share on Client2 and copy over sekurlsa.dll

@raffertylaura | @haydnjohnson

Page 61: Purple View

A: Local Admin to Domain AdminUse psexec to run mimikatz.exe on Client2

@raffertylaura | @haydnjohnson

Page 62: Purple View

A: Local Admin to Domain AdminUse sekurlsa::logonpasswords to dump the Domain Admin logon credentials from Client2!

@raffertylaura | @haydnjohnson

Page 63: Purple View

B: Wireshark:

@raffertylaura | @haydnjohnson

Page 64: Purple View

B: Event LogsClient1 logs into Client2 local admin

Page 65: Purple View

B: Event LogsClient1 runs mimikatz

on Client2

@raffertylaura | @haydnjohnson

Page 66: Purple View

B: Event Logs

Sensitive privilege use from Client1

to Client2

Page 67: Purple View

B: What can you take away

● Prevention:○ Access control for shared drive○ Limit access to psexec and monitor use○ Active Directory best practices

● Detection:○ IDS signatures ○ SIEM use case - Event correlation between system logs and network proxy logs○ For lateral movement: enable file level auditing○ Canary accounts

Page 68: Purple View

Purple Team - Benefits● Blue team observes vulnerabilities/threats which may not have been

considered○ Learns how attacker could escalate privileges from local admin to domain admin

● Red team observes the footprint left behind from this attack and possibly how to minimize it

○ Can identify potential weaknesses in blue team monitoring/response processes○ Provide more thorough recommendations

@raffertylaura | @haydnjohnson

Page 69: Purple View

TwittorBackdoor using Twitter

@raffertylaura | @haydnjohnson

Page 70: Purple View

A: Twittor● Easy to install● Easy to Use● Easy to add

Shellcode

https://github.com/PaulSec/twittor @raffertylaura | @haydnjohnson

Page 71: Purple View

A: Twittor - insidesSimple Subprocess execution

Stored as base64 encoded message

Page 72: Purple View

A: PyinstallerOn Github

Turn Python file into EXE

@raffertylaura | @haydnjohnsonhttps://github.com/pyinstaller/pyinstaller

Page 73: Purple View

A: Pyinstaller Python File becomes Executable

@raffertylaura | @haydnjohnson

Page 74: Purple View

@raffertylaura | @haydnjohnson

Twittor: Backdoor Using Twitter

Page 75: Purple View

A: Twittor Python file used as C2 Server Python file used as backdoor

EXE - Pyinstaller

@raffertylaura | @haydnjohnson

Page 76: Purple View

A: Twittor - Retrieving commandSend Command to execute

Retrieve command

@raffertylaura | @haydnjohnson

Page 77: Purple View

B: Twittor - Network TrafficReaching out to API

Normal User Traffic??

@raffertylaura | @haydnjohnson

Page 78: Purple View

B: Twittor - Client systemBackdoor as Python Executable compiled with --no-console flag to hide output

@raffertylaura | @haydnjohnson

Page 79: Purple View

B: Traffic from ClientReaches out to twitter

Src and Destination are internal IPs, sends to API

@raffertylaura | @haydnjohnson

Page 80: Purple View

B: What can you take awayCheck if there are any remote connections after hours, is it against policy?

Again, Correlate logs with known C2 addresses

See if AV picks it up

@raffertylaura | @haydnjohnson

Page 81: Purple View

Purple Team - BenefitsTest if a C2 can reach out to twitter.

Social Media may be blocked via the browser, but some sites can still be accessed via API etc.

If it is not blocked, why not, can your blue team help to stop this and others.

@raffertylaura | @haydnjohnson

Page 82: Purple View

Data ExfiltrationClear Text FTP

@raffertylaura | @haydnjohnson

Page 83: Purple View

@raffertylaura | @haydnjohnson

A: Data Exfiltration Through Clear Text FTP

Page 84: Purple View

A: FTP ExtractionFinding Data to extract

@raffertylaura | @haydnjohnson

Page 85: Purple View

A: Finding dataImportant data identified

@raffertylaura | @haydnjohnson

Page 86: Purple View

A: Downloading data

@raffertylaura | @haydnjohnson

Page 87: Purple View

A: Data Transferred

@raffertylaura | @haydnjohnson

Page 88: Purple View

B: Meterpreter connection DLL injection

Lots of chatter

@raffertylaura | @haydnjohnson

Page 89: Purple View

B: FTP connection Clear Text

@raffertylaura | @haydnjohnson

Page 90: Purple View

B: Successful Transfer

@raffertylaura | @haydnjohnson

Page 91: Purple View

B: What can you take away?

@raffertylaura | @haydnjohnson

Disable FTP - should not have a business need for it really

If there is a business need whitelist those IP addresses | Create a group of users specifically for FTP

Page 92: Purple View

Purple Team - ExerciseClear Text

Will any alarms trigger?

Understand potential holes in alerting

Measure time to detect and respond

@raffertylaura | @haydnjohnson

Page 93: Purple View

ConclusionPurple Teaming is Good

@raffertylaura | @haydnjohnson

Page 94: Purple View

Purple Team - ReiterationProvides more value than a Penetration Test

Should be implemented into a regular schedule

Helps train security personnel

Helps make sure your boxes are tuned

@raffertylaura | @haydnjohnson

Page 95: Purple View

Limitations and Future Work● So far we have limited detection tools to Windows Server event logs and

Wireshark, (and a bit of Snort)● Could be extended for enterprise security tools such as SIEM/IDS● Powershell/WMI for blue team● More advanced attacks, persistence using Powershell Empire

@raffertylaura | @haydnjohnson

Page 96: Purple View

Obligatory Cute Kat Picture

Page 97: Purple View

References are in following slides

@raffertylaura | @haydnjohnson

Page 98: Purple View

Microsoft - 8 minute Videohttps://azure.microsoft.com/en-us/documentation/videos/red-vs-blue-internal-security-penetration-testing-of-microsoft-azure/

@raffertylaura | @haydnjohnson

Page 99: Purple View

Seeing Purple: Hybrid Security Teams for the Enterprise - BSides Jackson 2013

http://www.slideshare.net/beltface/hybrid-talk@raffertylaura | @haydnjohnson

Page 100: Purple View

A: Downloads PowerShell fileClient2 reaches out to Kali machine

@raffertylaura | @haydnjohnson