59
Using Bro to Hunt Persistent Threats Benjamin H. Klimkowski United States Military Academy 13 September 2017

13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Using Bro to Hunt Persistent Threats

Benjamin H. Klimkowski

United States Military Academy

13 September 2017

Page 2: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Agenda1. Goals2. Definitions3. Motivating problem4. Approach5. How Cobalt Strike works6. Traffic analysis7. Evaluation8. Results9. Detecting other sets of activity

10. Future directions11. Questions

Page 3: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Goals● Demonstrate how Bro supports analysis over different phases of hunting● Discuss how persistent threat actors manipulate traffic to be stealthy● Share insights about Bro in a live detection setting and part of larger security

architecture● Share some cool tools and techniques

Page 4: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

DisclaimersThe views expressed in this presentation are those of the author and do not reflect

the official policy or position of the Department of the Army, Department of Defense, or the US Government.

The focus of this presentation is the not pedagogical merit of defensive cyber exercises/competitions

This presentation is neither an indictment nor endorsement of Cobalt Strike

Page 5: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 6: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

who --all● Undergraduate Team

○ Mitch Deridder

○ Dale Lakes

○ Matt Shockley

Senior Faculty Advisor

○ W. Michael Petullo

Page 7: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

whoami● Professional

○ Cyber Protection Team Leader, Unites States Army Cyber Protection Brigade○ Assistant Professor, Computer Science, United States Military Academy○ Computer Network Operations Plans Officer, Army Cyber Command○ Network Watch Officer, Army Cyber Operations and Integration Center○ Infantry officer

● Education○ MS, Computer Science, University of Maryland○ MS, Telecommunications, University of Colorado Boulder○ BS, Mechanical Engineering, United States Military Academy

● Research Interests: machine learning/data mining, network and host security, traffic analysis

● Father of three● Weightlifting, MMA, reading

Page 8: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Definitions● Persistent threat

○ High tradecraft○ Well-resourced○ Leverages vectors that hide/obscure initial access

● Hunting○ “Proactive approach to identifying threats on network”○ Threat-focused○ Emphasis on data analysis to identify hard to find activity○ May or may not be done in conjunction with incident response

Page 9: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Motivating Problem● 2017 Cyber-Defense Exercise (CDX)

○ Sponsored by NSA○ Blue forces: US and Canadian service academies compete○ Participants design, build, and defend network

● NSA Red Team○ Simulated persistent threat compressed to four day○ Target blue user workstations and services via an automated scoring system○ Pre-compromised images○ White-cell induced client-side attacks○ Timed Injects/challenges

● Defenders○ Simulated SOC/NOSC/CERT○ Part of larger architecture○ Stiff availability penalties for loss of service and interaction with user workstations

during competition

Page 10: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Attack Cycle● Reconnaissance:

○ Passive and active reconnaissance● Scanning and enumeration:

○ Identify systems, services, topology, etc.● Gain initial access:

○ Software vulnerabilities○ Weak passwords or configurations○ Credential stealing, social engineering, insiders

● Escalation of privilege:○ Sniffing, keylogging, active attack

● Maintain access: ○ Compromised accounts, rootkits, remote access tools (RATs)

● Cover Tracks: ○ Delete logs/ history

Page 11: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Our Approach● Understand how the threat operates● Analyze how to distinguish it from normal● Implement detection techniques● Evaluate and refine detection techniques

Page 12: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Cobalt Strike● Commercial penetration testing platform● Evolved from Armitage● More than a front-end to Metasploit

○ Enables team offensive operations○ Has a sophisticated payload delivery mechanism○ Has a sophisticated callback mechanisms

■ A store-and-forward architecture via “beacons”■ Beacons for DNS, HTTP, HTTPS, SMB ■ SMB only for inter-beacon communication

Page 13: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

How Cobalt Strike Works

Page 14: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 15: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 16: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 17: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 18: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 19: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 20: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 21: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 22: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 23: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 24: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 25: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Traffic Analysis● Stateless

○ HTTP■ User agent string outlier detection■ High entropy payloads

○ DNS■ Nonce domains / high entropy subdomains■ Reserved IP use in answers

● Stateful○ HTTP

■ Post/Get ratios○ DNS

■ Excessive number of classful networks mappings to single base domain

Page 26: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Traffic Analysis● Stateless

○ HTTP■ User agent string outlier detection■ High entropy payloads

○ DNS■ Nonce domains / high entropy subdomains■ Reserved IP use in answers

● Stateful○ HTTP

■ Post/Get ratios○ DNS

■ Excessive number of classful networks mappings to single base domain

Page 27: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

broFreq isolated_http.log > isolated_http.freq; cat isolated_http.freq | bro-cut user_agent | uniq

https://github.com/spitfire55/MegaDev

Page 28: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 29: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 30: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Doesn’t seem legit….● cat isolated_http.log | bro-cut host | sort | uniq | wc -l

○ 15177● cat isolated_http.log | bro-cut host user_agent | grep "Mozilla/4.0 (compatible;

MSIE 8.0; Windows NT 6.1)" | uniq■ sosorry.ca Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)

● cat isolated_http.log | bro-cut host method > hostVmethod.txt; getPostCompare hostVmethod.txt

https://github.com/spitfire55/MegaDev

Page 31: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

cat isolated_http.log | bro-cut host method > hostVmethod.txt; getPostCompare hostVmethod.txt

Hostname Number of Gets

Number of Posts Get/Post Ratio

rubberneck.hq.bluenet 2057.0 3705.0 0.5552

...

www.mtg.com 51.0 49.0 1.041

10.2.109.174 40.0 8.0 5.0

hammer.com 40.0 8.0 5.0

sosorry.ca 57792.0 323.0 178.92

Page 32: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

domainParser● Takes in a listing of domain names to frequencies and parses them into useful

formats for analysis● A Trie based data structure● 3 modes

○ “tree” for ■ A hierarchical representation■ Can set desired branch depth

○ “text” output■ Tabular listing of statistics for each domain name■ Can set the desired level of subdomains to analyze, ie, www.foo.bar has

three levels■ Can set a minimum threshold of child subdomains for a domain

● https://github.com/spitfire55/MegaDev

Page 33: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

domainParser cdx_query_freq.dns --text 3 50 > text_to_display_textout_3_50.txt

Page 34: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 35: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 36: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 37: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Doesn’t seem legit...

Page 38: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 39: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 40: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Evaluation--CDX 2017 ● Part of larger defense-in-depth strategy

○ Elasticsearch-Logstash-Kibana (ELK) SIEM■ Filebeat ingest from DMZ, firewall and Linux clients■ Winbeat ingest from Windows clients

○ Snort IDS○ Cisco ASA○ Squid Proxy○ VisorFlow: https://www.flyn.org/projects/VisorFlow/index.html

● Bro server○ CentOS 7, 12 Core, 20 GB RAM○ PF_RING, full capture○ Initially co-located with ELK SIEM○ Move to be co-located with Snort IDS

Page 41: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Results● Reduction of compromises

○ 1035 “token events” during the 2016 CDX ○ 15 “token events” during the 2017 CDX

● Score○ Highest live competition score○ 1st Place in confidentiality/integrity category and availability category○ 8% higher in confidentiality/integrity category than other competitors

● Issues○ Low number of HTTP/HTTPS events○ ELK performance

■ High CPU and memory consumption■ Kibana front-end limitations

○ Not fully leveraging Bro

Page 42: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Evaluation--Performance testing● Xubuntu 14.04 VM

○ Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz○ 4 Core○ 9.6 GB RAM

● Data Samples from 2016 and 2017 CDX competition for benchmark purposes

Page 43: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 44: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 45: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Detecting Other Activity--DNSCAT● DNS-based exfil tool● Uses MX, CNAME, TXT records● Enables tunneling● Much noisier than Cobalt Strike

○ Very long nonce domains○ Shows up almost immediately in weird.log

● Similar techniques used for Cobalt Strike apply○ High number of answers to one three-level domain name ○ High entropy subdomains

Page 46: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Take-aways on persistent threats● Packing exfil data into protocols

○ Trade-off between amount of information transmitted per message and concealment ■ More information, less concealment■ Less information, more concealment

○ Traffic profile potentially uncharacteristic● HTTPS is tough

○ SSL with legitimate certificates is hard to detect○ Must be a deliberate focus

● Importance of understanding “normal”● Importance of defense-in-depth● Need to be dynamic/not static

Page 47: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Future Work● Continuation of this work

○ Database connections/memory management to scale○ Other entropy measures for string/domain name characterization

● Other directions○ Instrumenting more signs of persistence/covert exfil○ Tool fingerprinting○ Benchmarking

■ Stateful scripts■ Performance evaluations for different backend storage solutions

● Potential new features to the Bro framework○ ssl / x509 anomalies to weird.log○ Additional data structures

Page 48: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Questionshttps://github.com/spitfire55/MegaDev

Page 49: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

References

● CrowdStrike. “Adversary Hunting And Incident Response: Network Edition.” BlackHat 2016

● Zeltser, Lenny. “Tunneling Data and Commands Over DNS to Bypass Firewalls.” https://zeltser.com/c2-dns-tunneling/

● Iagox86. “dnscat2.” https://github.com/iagox86/dnscat2● Mudge, Raphael. Advanced Threat Tactics for Penetration Testers.

https://www.cobaltstrike.com/training

Page 50: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Backup

Page 51: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 52: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive

Implementation

Page 53: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 54: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 55: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 56: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 57: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 58: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive
Page 59: 13 September 2017 United States Military Academy Using ......Commercial penetration testing platform Evolved from Armitage More than a front-end to Metasploit Enables team offensive