標籤:audit 審核 審核層級 審核組件 伺服器審核規範
SQL Server
審核(Audit
)--
建立伺服器層級的審核
任務1
:建立審核
步驟1:開啟SSMS,登入到指定的執行個體,展開“Security”,“Audits”節點。
步驟2:在“Audits”節點上,右鍵選擇“New Audit…”選項。
步驟3:在“Create Audit”視窗,輸入以下的參數。
l 在“Audit name”輸入Audit-Login-Create/Alter/Drop。
l 在“Audit destination”選擇“File”
l 在“File path”輸入D:\MSSQL\DATA\Audit_logs。
步驟4:單擊“OK”完成設定。
650) this.width=650;" title="clip_image001" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" alt="clip_image001" src="http://s3.51cto.com/wyfs02/M01/57/84/wKiom1ScuXrBmMQRAAP-Q746DLc304.jpg" border="0" height="674" />
步驟5:右鍵點擊剛剛建立的審核“Audit-Login-Create/Alter/Drop”,選擇“Enable Audit”選項。
650) this.width=650;" title="clip_image002" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" alt="clip_image002" src="http://s3.51cto.com/wyfs02/M01/57/82/wKioL1ScuinjOzySAAC8foYJuLU918.jpg" border="0" height="268" />
注意:新建立完成的“Audits”、“Server Audit Specifications”等對象,預設是禁用的,所以不會消耗系統資源。需要啟用後,才能讓它們發揮功能。
任務2
:建立伺服器層級的審核規範 –
監控賬戶的建立、修改與刪除。
步驟1:在“Object Explorer”視窗,展開“Security”,“Server Audit Specifications”節點。
步驟2:右鍵點擊“Server Audit Specifications”,選擇“Create Server Audit Specification”選項。
步驟3:在“Create Server Audit Specification”視窗,輸入以下的參數。
l 在“Name”輸入ServerAuditSpecification-Login-Create/Alter/Drop。
l 在“Audit”選擇先前建立的審核對象“Audit-Login-Create/Alter/Drop”。
l 在“Actions”地區,在“Audit Action Type”下的第一行,選擇“SERVER_PRINCIPAL_CHANGE_GROUP”。
650) this.width=650;" title="clip_image003" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" alt="clip_image003" src="http://s3.51cto.com/wyfs02/M02/57/84/wKiom1ScuX_h3f52AAPZEx_m_Dg366.jpg" border="0" height="674" />
“SERVER_PRINCIPAL_CHANGE_GROUP”是屬於伺服器層級的審核操作組,當建立、改變或是刪除伺服器主體時,就會引發這個事件。例如,執行以下的預存程序或是語句,就會引發此事件,包括sp_defaultdb、sp_defaultlanguage、sp_addlogin、sp_droplogin、sp_grantlogin、sp_revokelogin、sp_denylogin等預存程序,或是ALTER LOGIN語句。
步驟4:單擊“OK”,完成設定。
步驟5:右鍵點擊剛才建立的伺服器級審核規範“ServerAuditSpecification-Login-Create/Alter/Drop”,選擇“Enable Server Audit Specification”。
650) this.width=650;" title="clip_image004" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" alt="clip_image004" src="http://s3.51cto.com/wyfs02/M02/57/84/wKiom1ScuX_Q2k3LAAC_zzrW09I933.jpg" border="0" height="264" />
任務3
:測試審核功能 –
建立、修改、刪除登入賬戶。
步驟1:開啟SSMS,展開“Security”,“Logins”節點,建立登入賬戶,例如:UltraSQL。
步驟2:更改此登入賬戶的“Default database”為AdventureWorks2012。
步驟3:再將此登入賬戶刪除。
任務4
:查看稽核線索。
步驟1:展開“Security”,“Audits”節點。
步驟2:在剛才建立的“Audit-Login-Create/Alter/Drop”對象上,右鍵選擇“View Audit Logs”。
步驟3:在“Log File Viewer”視窗左上方的“Select logs”地區中,確認有勾選“Audit Collection”,“Audit-Login-Create/Alter/Drop”。
步驟4:在右邊窗格“Log file summary”地區內的“Action ID”框下,選擇“CREATE”。
步驟5:在下方窗格“Statement”地區,可以看到建立賬戶的程式碼,密碼特別以“*****”保護。
650) this.width=650;" title="clip_image005" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" alt="clip_image005" src="http://s3.51cto.com/wyfs02/M00/57/84/wKiom1ScuYGzUbnyAAbPaSCYBdk758.jpg" border="0" height="644" />
在“Action ID”列下,可以看到所記錄的每個事件的類型,例如CREATE、CHANGE、DROP等,可逐筆查看這些審核資訊。
本文出自 “SQL Server Deep Dives” 部落格,請務必保留此出處http://ultrasql.blog.51cto.com/9591438/1596117
SQL Server 審核(Audit)-- 建立伺服器層級的審核