Old Web Shells, New Tricks



Similar documents
Hunting for Indicators of Compromise

All Information is derived from Mandiant consulting in a non-classified environment.

Targeted Intrusion Remediation: Lessons From The Front Lines. Jim Aldridge

RSA Security Anatomy of an Attack Lessons learned

Targeted attacks: Tools and techniques

Penetration Testing Report Client: Business Solutions June 15 th 2015

How We're Getting Creamed

Performing Advanced Incident Response Interactive Exercise

Who DIT It? Detecting and Mitigating Privilege Escalation Attacks on the Active Directory Data Store

Beyond 'Check The Box': Powering Intrusion Investigations Jim Aldridge 11 March 2014

Alert (TA14-212A) Backoff Point-of-Sale Malware

Where every interaction matters.

EC-Council CAST CENTER FOR ADVANCED SECURITY TRAINING. CAST 619 Advanced SQLi Attacks and Countermeasures. Make The Difference CAST.

Persistence Mechanisms as Indicators of Compromise

Centre for the Protection of National Infrastructure Effective Log Management

2016 EMEA EDITION M-TRENDS MANDIANT CONSULTING SPECIAL REPORT / JUNE 2016 AUTHORS. Bill Hau Matt Penrose Tom Hall Matias Bevilacqua

What s Wrong with Information Security Today? You are looking in the wrong places for the wrong things.

Evolving Threat Landscape

Backoff: New Point of Sale Malware. 31 July National Cybersecurity and Communications Integration Center

ABC LTD EXTERNAL WEBSITE AND INFRASTRUCTURE IT HEALTH CHECK (ITHC) / PENETRATION TEST

5 Steps to Advanced Threat Protection

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Advice from the Trenches: Preparing for the Challenges and Pressures of a Security Incident Investigation

How we see malware introduced Phishing Targeted Phishing Water hole Download (software (+ free ), music, films, serialz)

Web Security School Final Exam

CS 356 Lecture 25 and 26 Operating System Security. Spring 2013

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

Stop the Maelstrom: Using Endpoint Sensor Data in a SIEM to Isolate Threats

Seven Strategies to Defend ICSs

Sophisticated Indicators for the Modern Threat Landscape: An Introduction to OpenIOC

For more information on SQL injection, please refer to the Visa Data Security Alert, SQL Injection Attacks, available at

Protecting Your Organisation from Targeted Cyber Intrusion

The Top Web Application Attacks: Are you vulnerable?

EITC Lessons Learned: Building Our Internal Security Intelligence Capability

APT Detection with Whitelisting and Log Monitoring

Additional Security Considerations and Controls for Virtual Private Networks

RSA Security Analytics

Concierge SIEM Reporting Overview

MITIGATING LARGE MERCHANT DATA BREACHES

Next-Generation Penetration Testing. Benjamin Mossé, MD, Mossé Security

INDUSTRIAL CONTROL SYSTEMS CYBER SECURITY DEMONSTRATION

LEVERAGING PROACTIVE DEFENSE TO DEFEAT MODERN ADVERSARIES. Jared Greenhill RSA Incident Response. September 17 th, 2015

Advanced Threat Protection with Dell SecureWorks Security Services

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Anatomy of a Breach: A case study in how to protect your organization. Presented By Greg Sparrow

Beyond Check The Box

Foundstone ERS remediation System

Security Awareness For Website Administrators. State of Illinois Central Management Services Security and Compliance Solutions

Agenda. Red Team Difference to a Pen Test Common RT Techniques Blue Team

FORENSIC ANALYSIS Aleš Padrta

September 20, 2013 Senior IT Examiner Gene Lilienthal

Rational AppScan & Ounce Products

Detecting Web Application Vulnerabilities Using Open Source Means. OWASP 3rd Free / Libre / Open Source Software (FLOSS) Conference 27/5/2008

CS 558 Internet Systems and Technologies

DRIVE-BY DOWNLOAD WHAT IS DRIVE-BY DOWNLOAD? A Typical Attack Scenario

Effective Log Management

Standard: Event Monitoring

CORE IMPACT AND THE CONSENSUS AUDIT GUIDELINES (CAG)

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

05 June 2015 A MW TLP: GREEN

Protect Your IT Infrastructure from Zero-Day Attacks and New Vulnerabilities

Post-Access Cyber Defense

Pass-the-Hash. Solution Brief

Still Aren't Doing. Frank Kim

Practice Good Enterprise Security Management. Presented by Laurence CHAN, MTR Corporation Limited

Security Threat Kill Chain What log data would you need to identify an APT and perform forensic analysis?

COORDINATED THREAT CONTROL

Penetration Testing: Lessons from the Field

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

SQL Injection January 23, 2013

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

KEY STEPS FOLLOWING A DATA BREACH

ICS-CERT Incident Response Summary Report

A more comprehensive version of this material was published in the October issue of the Virus Bulletin magazine [3].

Websense Support Webinar: Questions and Answers

Implementation of Web Application Firewall

Who Drives Cybersecurity in Your Business? Milan Patel, K2 Intelligence. AIBA Quarterly Meeting September 10, 2015

How To Create Situational Awareness

What IT Auditors Need to Know About Secure Shell. SSH Communications Security

INDUSTRY OVERVIEW: HEALTHCARE

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Secure Messaging Server Console... 2

Comprehensive Advanced Threat Defense

Exploiting Fundamental Weaknesses in Command and Control (C&C) Panels

The monsters under the bed are real World Tour

Strategies to Mitigate Targeted Cyber Intrusions Mitigation Details

Operating Systems Forensics

Department of Homeland Security

Application Security Policy

GFI White Paper PCI-DSS compliance and GFI Software products

CHAPTER 3 : INCIDENT RESPONSE FIVE KEY RECOMMENDATIONS GLOBAL THREAT INTELLIGENCE REPORT 2015 :: COPYRIGHT 2015 NTT INNOVATION INSTITUTE 1 LLC

W16 INTEGRATING SECURITY INTO THE DEVELOPMENT LIFECYCLE. Ryan English SPI Dynamics Inc BIO PRESENTATION 6/28/2006 3:00 PM

Software that provides secure access to technology, everywhere.

IDENTITY & ACCESS. Privileged Identity Management. controlling access without compromising convenience

After the Attack: RSA's Security Operations Transformed

Why The Security You Bought Yesterday, Won t Save You Today

SQL Injection 2.0: Bigger, Badder, Faster and More Dangerous Than Ever. Dana Tamir, Product Marketing Manager, Imperva

Client logo placeholder XXX REPORT. Page 1 of 37

Shellshock. Oz Elisyan & Maxim Zavodchik

Advanced Endpoint Protection

Transcription:

Ryan Kazanciyan Principal Consultant Old Web Shells, New Tricks AppSec DC 2012

Standard Disclaimer All information is derived from MANDIANT observations in non-classified environments Some information has been sanitized to protect our clients interests 2

whoami RYAN KAZANCIYAN [ kah-zan-see-yan ] Principal Consultant Joined Mandiant in 2009 Focus on incident response investigations and forensics Previous background in penetration testing, application security Instructor 3

Reviewing the Basics

Web Shells Defined Malicious web page that provides attacker functionality: File transfer Command execution Network reconnaissance Database connectivity Server-side scripting PHP, ASP, ASPX, JSP, CFM, etc 5

Usage Scenarios Get a file on a web server External attack vectors RFI SQL injection File upload Exposed admin interface Low barrier to entry Lots of publicly available malware Lots of web app vulnerabilities Trivial to use 6

Classic Web Shell Attacks cmd.asp HTTP Internet Attacker Network DMZ abc.com Internal Network DB Servers DCs File Servers Employees Attacker uploads a malicious dynamic web page to a vulnerable web server Attacker uses the web shell to browse files, upload tools, and run commands Attacker escalates privileges and pivots to additional targets as allowed 7

Threat Actors Type of malware!= attribution Most frequently seen used by: Financial Crime / Cardholder Data Theft groups Hacktivists Script kiddies 8

Traditional Detection Methods Network monitoring Web attack vectors Known bad source IPs / domains Signatures for web shell traffic (can be limited) Log review Proactive vs. reactive? Anti-virus Very poor detection rates Post-incident host-based forensics Driven by some other indicator of compromise Tracing attack timeline to Internet-facing server 9

Example: ASPXSpy Very popular Make in China Full-featured ~60KB Hashed password Lots of tell-tale strings in serverside source and rendered output 10

ASPXSpy Client Usage 11

Example: China Chopper < 100 bytes Relies on a thick-client for remote access Simple password mechanism Easily hidden References: www.maicaidao.com, www.webshell.cc 12

Chopper Client Usage 13

What About Web Logs? Not always very helpful 14

Old Shells, New Tricks It s 2012. Why is this still relevant? What happens if an attacker deploys a web shell from within a compromised environment? using legitimate, administrator credentials? without exploiting any application or web server vulnerabilities? without generating any web requests for the shell? 15

Case Study

The Scenario Engineering and manufacturing firm ~3000 systems Compromised since early 2009 Initial attack vector: spear phishing Attacker objectives: Espionage, IP theft 17

Attacker s Remote Access Attacker C2 Infrastructure Corporate Network 4.5.6.7 8.9.1.2 Backdoor C2 (HTTPS) 3.4.5.6 Key VPN Server Backdoored Hosts Accessed Hosts Single-factor VPN Access Attacker Systems Attacker Client 18

Host of Interest Hostname: beta Win2k3 web server in DMZ Initial indicator of compromise: Evidence that file psexec.exe had executed from path C:\RECYCLER Analysis identified IIS Spy web shell at C:\Inetpub\wwwroot\iisstart.aspx How d it get there? How was it used? 19

File Metadata Path: C:\Inetpub\wwwroot\iisstart.aspx Size: 72,574 Standard Information Timestamps: Created Accessed Modified Entry Modified 2008-02-14 2011-07-22 2005-03-24 2011-04-20 21:29:18Z 08:19:30Z 22:19:08Z 06:06:51Z Earliest logged HTTP request: First recorded access in web logs: 2010-01-04 04:37:51 1.2.3.4 GET /iisstart.aspx - 443 4.5.6.7 20

Tampering Time Standard Information Timestamps: Created Accessed Modified Entry Modified 2008-02-14 2011-07-22 2005-03-24 2011-04-20 21:29:18Z 08:19:30Z 22:19:08Z 06:06:51Z Filename Information Timestamps (from $MFT) FN Created FN Accessed FN Modified FN Changed 2010-01-04 2010-01-04 2010-01-04 2010-01-04 04:37:33Z 04:37:33Z 04:37:33Z 04:37:33Z 2010-01-04 04:37:51 1.2.3.4 GET /iisstart.aspx - 443 4.5.6.7 21

How d It Get There? No clues from IIS logs file just shows up File owner: BUILTIN\Administrators What if it were NT AUTHORITY\NETWORK SERVICE? Preceding network login event: Time Event Detail 2010-01-04 04:30:01 Security Event Log Entry Successful Network Logon: User Name: CorpDomain\adminUser Domain: CorpDomain Logon ID: (0x0,0x1AFF1293) Logon Type: 3 Logon Process: NtLmSsp Authentication Package: NTLM Workstation Name: alpha Indicates lateral access to the server from another compromised system, alpha 22

Validating 1 st Access Time ASP.NET compiler output and assemblies Time Event Detail 2010-01-04 04:37:33 2010-01-04 04:37:51 2010-01-04 04:37:51 File Name Created File Created IIS Log Entry C:\Inetpub\wwwroot\iisstart.aspx C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727 \Temporary ASP.NET Files\root\e22c2559\92c7e946\iisstart.aspx.cdca b7d2.compiled GET /iisstart.aspx Created upon first access (unless precompiled deployment) Reference: http://msdn.microsoft.com/en-us/library/ms227430(v=vs.85).aspx 23

What Happened Next? Time Event Detail 2010-01-05 05:28:28Z File Created C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\ Temporary ASP.NET Files\root\e22c2559\92c7e946\uploads uploads directory created in existing.net compiler output directory for web shell Time Event Detail File Owner 2010-01-05 05:28:32Z File Created C:\RECYCLER\psexec.exe File owner indicates uploaded through web shell NT AUTHORITY\NETWORK SERVICE Time Event Detail Associated User 2010-01-05 05:33:02Z System EVT Log Entry The PsExec service was successfully sent a start control. CorpDomain\adminUser Indicates lateral access to host using psexec (note associated user) 24

Review: Attack Sequence alpha net use y: \\beta\c$ /u:localadmin passwd Mount share to beta from alpha using local admin account beta alpha copy evil.aspx y:\inetpub\wwwroot\iisstart.aspx Copy web shell to beta web root beta iisstart.aspx attacker.c2.com GET /iistart.aspx Access web shell over Internet as a test beta iisstart.aspx 25

Review: Attack Sequence attacker.c2.com POST /iisstart.aspx psexec.exe upload via web shell beta iisstart.aspx alpha psexec.exe \\beta cmd.exe Establish cmd line access to beta beta iisstart.aspx beta psexec.exe \\??? Test lateral access from beta to other hosts 26

Remote Access (Revisited) Attacker C2 Infrastructure Corporate Network 4.5.6.7 8.9.1.2 Backdoor C2 (HTTPS) 3.4.5.6 VPN Server Key Backdoored Hosts Corporate DMZ Single-factor VPN Access Accessed Hosts Attacker Systems Web Shell Access Attacker Client 27

On Other Hosts One internal server with web shells staged in C:\RECYCLER\iis.zip Two DMZ web servers with web shells deployed laterally Each web shell was Installed during the first several months of the compromise Only accessed a handful of times post-deployment 28

At Other Victims Seeing web shells used in an increasing number of our APT cases Majority deployed laterally, post-intrusion Majority were publicly available tools Main purpose seems to be resilience to remediation efforts 29

Investigating and Mitigating

Challenges: Network Indicators Attacker can connect from any source address Shell may only be used as a backup mechanism Signature detection relies on client-transmitted web page elements 31

Challenges: Host-Based Indicators Needles in haystacks Lots of servers Lots of web roots Lots of web shell variants Internal attacker has full visibility to targets Single-line shells easy to create echo ^<%eval request( sb )%\^> > test.asp Difficult to trace all lateral movement Availability of event logs Local vs. domain account usage Duration of compromise 32

Which path? Can t just look in defaults like inetpub\wwwroot! Lots of application-specific paths C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\template C:\Program Files\Exchsrvr\ExchWeb C:\Program Files (x86)\business Objects\Tomcat55\webapps\Plat formservices\jsp\ 33

All is not lost! 34

Mitigation: Network Contain the attacker DMZ Isolation: Still a common problem!! Traffic from DMZ to internal network Traffic from internal network to DMZ Limiting joined domains, crossforest trusts jump boxes for admin access Corporate DMZ Corporate Network VPN Server Web Shell Access Attacker Client 35

Mitigation: Host Application Whitelisting, HIDS May detect what an attacker does with a web shell May not detect latent web shells Monitoring all file system changes within all web roots on all servers may generate a lot of noise Least-privilege for web server & application user context Host-based controls are likely to fail if the attacker already has admin privileges 36

Host-Based Artifacts: Static File Analysis Harder than hunting for PEs No fixed structure No need for persistence mechanism Keyword searches, statistical analysis Limitations Multitude of scripting languages False positive rate False negative rate Number of servers Free tools NeoPI: https://github.com/neohapsis/neopi RIPS: http://rips-scanner.sourceforge.net/ IOC Finder: http://www.openioc.org Commercial forensic tools Enterprise-scale vs. one-hostat-a-time analysis Keyword searches across 1000s of machines, files 37

Host-Based Artifacts: Static File Analysis Keywords & regex can be surprisingly effective (net user, cmd.exe, cmdshell, HKEY_, command_interpreter,...) Need to limit search scope Encoding and obfuscation False positives on legit but badly-written code Used less frequently than I d expect Hassle for attackers to edit, maintain? 38

Host-Based Artifacts: Tracking Lateral Movement Laterally installed web shells typically on Windows servers Attackers leverage existing credentials Local vs. domain account usage and impact on logging Certain directions of Windows logins with certain accounts may be suspicious Internal subnets to DMZ web servers DMZ web servers to internal subnets 39

Host-Based Artifacts: Tracking Lateral Movement alpha net use y: \\beta\c$ /u:localadmin passwd beta Logon Type 3 User: domain\admin Password: ******* gamma Domain Controller Logon Type 10 Logon Type 10 40

This can get messy Phishing Campaigns Compromised Hosts Accessed Hosts 41

Host-Based Artifacts: Interactive Access Shellbags (in NTUSER.DATs) HKEY_USERS\{USERID}\Software\ Microsoft\Windows\Shell\ HKEY_USERS\{USERID}\Software\ Microsoft\Windows\ ShellNoRoam\ HEKY_USERS\{USERID}\Local Settings\Software\Microsoft\ Windows\Shell\ Other registry keys MRU keys UserAssist LNK files IE history (Explorer usage) Focus on attacker accounts, timeline analysis shellbags.py Tool & Reference: http://www.williballenthin.com/forensics/shellbags/index.html 42

Scoping Your Investigation Scale and impact of compromise Can t just hunt for malware How d they get in? What was taken? How can we kick them out? Attacker Tools All Systems Unauthorized Access Malware Backdoors Staged Data 43

Conclusion

Takeaways Lateral installation of web shells is a new twist on an old concept Increasingly used in targeted attacks and by a broader set of actors Easy way to re-compromise a remediated environment Challenging to find in large compromised networks Sound network architecture is the foremost mitigation approach 45

Questions ryan [dot] kazanciyan [at] mandiant [dot] com Twitter: @ryankaz42 46

Ryan Kazanciyan Principal Consultant Old Web Shells, New Tricks AppSec DC 2012