Auditing In SQL Server. SQL Saturday #486 - RVA Presented By Brad McKuhen

Similar documents
ecopy ShareScan 5.0 SQL installs guide

Chancery SMS Database Split

Dynamics NAV/SQL Server Configuration Recommendations

Jason S Wong Sr. DBA IT Applications Manager DBA Developer Programmer M.S. Rice 88, MBA U.H. 94(MIS)

RSA Security Analytics

How to schedule and automate backups of SQL Server databases in SQL Server Express Editions

SQL SERVER Anti-Forensics. Cesar Cerrudo

Microsoft SQL Server Integration Guide

Setup and configuration for Intelicode. SQL Server Express

Microsoft SQL Server Security Best Practices

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

Microsoft SQL Server OLTP Best Practice

Database Maintenance Guide

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

Print Audit 6 - How to Move Print Audit 6 and a SQL Server 2005 Express Database to a New Server

WhatsUp Gold v16.0 Database Migration and Management Guide Learn how to migrate a WhatsUp Gold database from Microsoft SQL Server 2005 Express

Dell InTrust Preparing for Auditing Microsoft SQL Server

MICROSTRATEGY 9.3 Supplement Files Setup Transaction Services for Dashboard and App Developers

Notes Transfer instructions INTRODUCTION More information

Microsoft SQL Server Staging

Sophos Enterprise Console Auditing user guide. Product version: 5.2

WHITE PAPER: ENTERPRISE SOLUTIONS. Symantec Backup Exec Continuous Protection Server Continuous Protection for Microsoft SQL Server Databases

WINDOWS AZURE SQL DATA SYNC

How to move a SQL database from one server to another

SQL Server Auditing. By Minette Steynberg. Audit all SQL Server activities using ApexSQL Comply

Tutorial: How to Use SQL Server Management Studio from Home

ilaw Server Migration Guide

Backup / migration of a Coffalyser.Net database

Upgrading from MSDE to SQL Server 2005 Express Edition with Advanced Services SP2

GO!NotifyLink. Database Maintenance. GO!NotifyLink Database Maintenance 1

SQL Server 2008 R2 Express Edition Installation Guide

TANDBERG MANAGEMENT SUITE 10.0

Quick Start Guide. User Manual. 1 March 2012

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

PIM SOFTWARE TR50. Configuring the Syslog Feature TECHNICAL REFERENCE page 1

Database Migration and Management Guide v15.0

These notes are for upgrading the Linko Version 9.3 MS Access database to a SQL Express 2008 R2, 64 bit installations:

Knowledge Base Article: Article 218 Revision 2 How to connect BAI to a Remote SQL Server Database?

Vault Project - Plant Database Replication. Contents. Software Requirements: AutoCAD Plant 3D 2016 and AutoCAD P&ID 2016

SQL Backup and Restore using CDP

EASRestoreService. Manual

Hunting flaws in Microsoft SQL Server

CONSOLIDATING SQL SERVER 2000 ONTO DELL POWEREDGE R900 AND POWEREDGE R905 USING MICROSOFT S HYPER-V

Siemens Teamcenter Oracle -to-sql Server 2008 Migration Guide

Automation Engine 14. Troubleshooting

ilaw Installation Procedure

DBMoto 6.5 Setup Guide for SQL Server Transactional Replications

Cello How-To Guide. Pickup List Management

Citrix EdgeSight for NetScaler Rapid Deployment Guide

for Networks Installation Guide for the application on the server July 2014 (GUIDE 2) Lucid Rapid Version 6.05-N and later

Only for Data Group Students Do not share with outsiders and do not use for commercial purposes.

1 of 10 1/31/2014 4:08 PM

Installation Guide. (June 2014)

Feature. Auditing SQL Server Databases Using CAATs

The Real MCTS SQL Server 2008 Exam 432

If a database is using the Simple Recovery Model, only full and differential backups of the database can be taken.

Getting Started with Telerik Data Access. Contents

$99.95 per user. SQL Server 2005 Database Administration CourseId: 152 Skill level: Run Time: 30+ hours (158 videos)

How To Use A Microsoft Microsoft Database Server 2012

Ontrack PowerControls V8.1 for SQL ReadMe

FmPro Migrator - FileMaker to SQL Server

Evaluate your Daily Checklist against 100+ instances of SQL Server while you get a cup of coffee

BlackBerry Enterprise Server Resource Kit

HP StorageWorks. HP PolyServe Software for Microsoft SQL Server administration guide. HP PolyServe Software for Microsoft SQL Server 4.0.

Data Compression in Blackbaud CRM Databases

How do I EVOLVE to Best Practice Software?

GUIDE TO SYBASE SECURITY

Database Server Migration Guide

How To Install A New Database On A 2008 R2 System With A New Version Of Aql Server 2008 R 2 On A Windows Xp Server 2008 (Windows) R2 (Windows Xp) (Windows 8) (Powerpoint) (Mysql

Sage Estimating. (formerly Sage Timberline Estimating) SQL Server Guide

mylittleadmin for MS SQL Server Quick Start Guide

Database Server Maintenance Plan

SQL EXPRESS INSTALLATION...

Microsoft Maintaining a Microsoft SQL Server 2008 Database

Remote Management System

Best Practices for Backup of Microsoft SQL 2000 Databases with Unitrends Backup Professional

Upgrade Guide. McAfee Vulnerability Manager Microsoft Windows Server 2008 R2

Migrating MSDE to Microsoft SQL 2008 R2 Express

Configuration Manager 2012 SC2012 ConfigMgr SP1 MP Replica Configuration Guide

Table of Contents. FleetSoft Installation Guide

Assured PackOut Best Practices: Create a Back-Up

for Networks Installation Guide for the application on a server September 2015 (GUIDE 2) Memory Booster version 1.3-N and later

Performance. Optimizing Performance. Microsoft Dynamics CRM 3.0. White Paper. Date: January 10,

Table of Contents. CHAPTER 1 About This Guide CHAPTER 2 Introduction CHAPTER 3 Database Backup and Restoration... 15

Move a VM 3.0 with AD Integration to a new server. Creation date: 17/06/2008 Last Review: 26/06/2008 Revision number: 1

Instructions for update installation of ElsaWin 5.00

Sitecore Ecommerce Enterprise Edition Installation Guide Installation guide for administrators and developers

General DBA Best Practices

Installing SQL Server Express 2008 Version /08/05 sdk

TMS Database Knowledge Tips

ATTACHMENT 6 SQL Server 2012 Programming Standards

Using SQL Server Management Studio

TECHNICAL NOTE. The following information is provided as a service to our users, customers, and distributors.

SmartConnect User Credentials 2012

OPTIMIZING QUERIES IN SQL SERVER 2008

Microsoft SQL Server 2008 Step by Step

Reporting Installation Checklist

TROUBLESHOOTING GUIDE

User Migration Tool. Note. Staging Guide for Cisco Unified ICM/Contact Center Enterprise & Hosted Release 9.0(1) 1

for Networks Installation Guide for the application on the server August 2014 (GUIDE 2) Lucid Exact Version 1.7-N and later

Transcription:

Auditing In SQL Server SQL Saturday #486 - RVA Presented By Brad McKuhen

Thank You Sponsors

About Me SQL Server DBA/Developer 13 years Lead DBA at Clutch Group Contact Me: Info at lakesidedba.com @bradmckuhen http://www.lakesidedba.com

"All it takes is one bad day to reduce the sanest man alive to lunacy...just one bad day."

From the top... Built In Logs C2 Common Criteria Compliance Default Trace Server Settings ExEv Server Audit Database Audit CDC TempDB Ransack WinMerge

Rotate Your Logs USE msdb ; -- agent log cycling must be run from MSDB EXEC dbo.sp_cycle_agent_errorlog ; -- both log cycling SP's are SYSADMIN role only EXEC sp_cycle_errorlog ; Image Credit: http://d2rormqr1qwzpz.cloudfront.net/photos/2013/02/01/44394-owl_head.jpg

Audit Using Your Logs

C2 - Setup From MSDN: Selecting this option will configure the server to record both failed and successful attempts to access statements and objects. -- turn it on sp_configure 'show advanced options', 1 ; RECONFIGURE WITH OVERRIDE ; sp_configure 'c2 audit mode', 1 ; RECONFIGURE WITH OVERRIDE ; All of them. Be very careful about using this. -- turn it off sp_configure 'c2 audit mode', 0 ; RECONFIGURE WITH OVERRIDE ; sp_configure 'show advanced options', 0 ; RECONFIGURE WITH OVERRIDE; A restart is required to implement this.

C2 - Results

C3 Common Criteria Compliance https://s-media-cache-ak0.pinimg.com/736x/b5/62/9a/b5629a9fc8a2de88160841a53384354f.jpg

C3 - Setup Criteria Residual Information Protection (RIP) The ability to view login statistics Description RIP requires a memory allocation to be overwritten with a known pattern of bits before memory is reallocated... Each time a user successfully logs in to SQL Server, information about the last successful login time, the last unsuccessful login time, and the number of attempts... is made available... query the sys.dm_exec_sessions DMV That column GRANT should not override table DENY After the common criteria compliance enabled option is enabled, a table-level DENY takes precedence over a column-level GRANT. When the option is not enabled, a column-level GRANT takes precedence over a table-level DENY. Important In addition to enabling the common criteria compliance enabled option, you also must download and run a script that finishes configuring SQL Server to comply with Common Criteria Evaluation Assurance Level 4+ (EAL4+). You can download this script from the Microsoft SQL Server Common Criteria Web site. https://msdn.microsoft.com/en-us/library/bb326650.aspx

C3 Common Criteria Compliance, Query

C3 Common Criteria Compliance, Results Tons More Information In This DMV Than We Can Cover

Default Trace - Setup SELECT * FROM sys.configurations WHERE configuration_id = 1568

Default Trace Get Results

Built In Logs C2 Common Criteria Compliance Default Trace Server Settings ExEv Server Audit Database Audit CDC TempDB Ransack WinMerge

Server Options - Setup

Extended Events - Setup CREATE EVENT SESSION [Get All Statements] ON SERVER ADD EVENT sqlserver.rpc_completed (ACTION(sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.is_system, sqlserver.nt_username, sqlserver.session_id, sqlserver.sql_text, sqlserver.username) WHERE ([sqlserver].[is_system] = (0))), ADD EVENT sqlserver.sql_batch_completed (ACTION(sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.is_system, sqlserver.nt_username, sqlserver.session_id, sqlserver.sql_text, sqlserver.username) WHERE ([sqlserver].[is_system] = (0))), ADD EVENT sqlserver.sql_statement_completed (ACTION(sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.is_system, sqlserver.nt_username, sqlserver.session_id, sqlserver.sql_text, sqlserver.username) WHERE ([sqlserver].[is_system] = (0))) ADD TARGET package0.event_file (SET filename = N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log\Get All Statements.xel') WITH (STARTUP_STATE = ON) ALTER EVENT SESSION [Get All Statements] ON SERVER STATE = START;

Extended Events - Results One way, quite manual: SELECT CAST(event_data AS XML) event_data, * FROM sys.fn_xe_file_target_read_file ('C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log\Get All Statements*.xel', NULL, NULL, NULL) Courtesy of https://www.brentozar.c om/archive/2014/03/ex tended-events-doesnthard/

Extended Events - Results

Extended Events - Results

Server Audit - Setup CREATE SERVER AUDIT [AuditForDemo] TO FILE (FILEPATH = 'C:\TEMP', MAXSIZE = 1 GB, MAX_ROLLOVER_FILES = 2, RESERVE_DISK_SPACE = OFF) WITH (QUEUE_DELAY = 1000, ON_FAILURE = CONTINUE); CREATE SERVER AUDIT SPECIFICATION [ServerAuditSpecificationForDemo] FOR SERVER AUDIT [AuditForDemo] ADD (APPLICATION_ROLE_CHANGE_PASSWORD_GROUP), ADD (AUDIT_CHANGE_GROUP), ADD (BACKUP_RESTORE_GROUP), ADD (BROKER_LOGIN_GROUP); -- START THEM ALTER SERVER AUDIT [AuditForDemo] WITH (STATE = ON); ALTER SERVER AUDIT SPECIFICATION [ServerAuditSpecificationForDemo] WITH (STATE = ON);

DDL Tracked The Table CREATE DATABASE AuditSampleDB; --EXEC AuditSampleDB.dbo.sp_changedbowner 'contoso\ironman'; EXEC AuditSampleDB.dbo.sp_changedbowner 'sa'; USE AuditSampleDB; CREATE TABLE dbo.ddlevents (EventDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, EventType NVARCHAR(64), EventDDL NVARCHAR(MAX), EventXML XML, DatabaseName NVARCHAR(255), SchemaName NVARCHAR(255), ObjectName NVARCHAR(255), [ObjectID] INT, HostName VARCHAR(64), IPAddress VARCHAR(32), ProgramName NVARCHAR(255), LoginName NVARCHAR(255));

DDL Tracked The Trigger CREATE TRIGGER ddl_trig_alter_db ON ALL SERVER FOR ALTER_DATABASE, CREATE_DATABASE, DROP_DATABASE AS BEGIN DECLARE @WhatHappened XML; SELECT @WhatHappened = EVENTDATA(); DECLARE @ip VARCHAR(32) = (SELECT client_net_address FROM sys.dm_exec_connections WHERE session_id = @@SPID); INSERT AuditSampleDB.dbo.DDLEvents (EventType, EventDDL, EventXML, DatabaseName, SchemaName, ObjectName, HostName, IPAddress, ProgramName, LoginName) SELECT @WhatHappened.value('(/EVENT_INSTANCE/EventType)[1]', 'NVARCHAR(100)'), @WhatHappened.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'NVARCHAR(MAX)'), @WhatHappened, DB_NAME(), @WhatHappened.value('(/EVENT_INSTANCE/SchemaName)[1]', 'NVARCHAR(255)'), @WhatHappened.value('(/EVENT_INSTANCE/ObjectName)[1]', 'NVARCHAR(255)'), HOST_NAME(), @ip, PROGRAM_NAME(), SUSER_SNAME(); END

DDL Tracked

Tracking A User Via Audit - Setup

Tracking A User Via Audit - Results

Database Audit - Setup CREATE DATABASE SampleDB; USE [SampleDB] CREATE DATABASE AUDIT SPECIFICATION [DatabaseAuditSpecificationForDemo] FOR SERVER AUDIT [AuditForDemo] ADD (APPLICATION_ROLE_CHANGE_PASSWORD_GROUP), ADD (AUDIT_CHANGE_GROUP), ADD (BACKUP_RESTORE_GROUP), ADD (DATABASE_CHANGE_GROUP), ADD (DATABASE_LOUT_GROUP), ADD (DATABASE_OBJECT_ACCESS_GROUP), ADD (DATABASE_OBJECT_CHANGE_GROUP); ALTER DATABASE AUDIT SPECIFICATION [DatabaseAuditSpecificationForDemo] WITH (STATE = ON);

Database Audit Get Results SELECT CAST(additional_information AS XML) AS ADDLINFOXML, * FROM sys.fn_get_audit_file('c:\temp\auditfordemo_44582e17-a397-4882- B30F-946F27B0B262_0_131024426446730000.sqlaudit', DEFAULT, DEFAULT) WHERE database_name = 'AdventureWorks2014' ORDER BY EVENT_TIME DESC;

CDC - Setup

CDC Get Results

What about BBanner?

CDC Results, Post-BBanner

What s In TempDB? Example Setup

What s In TempDB? Get Results

Agent Ransack File Search

Agent Ransack File Search

WinMerge Folder Compare

WinMerge File Compare

Questions? Contact Me: Info at lakesidedba.com @bradmckuhen http://www.lakesidedba.com