﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>FranklinFaces.com - Oracle &amp; SQL Server Database Forums for all IT Professionals / Oracle Forum / Oracle Database Administration  / Turning on Audit in Oracle database / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>FranklinFaces.com - Oracle &amp; SQL Server Database Forums for all IT Professionals</description><link>http://www.franklinfaces.com/</link><webMaster>no-reply@FranklinFaces.com</webMaster><lastBuildDate>Fri, 10 Feb 2012 23:24:37 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Turning on Audit in Oracle database</title><link>http://www.franklinfaces.com/Topic163-97-1.aspx</link><description>Turning off Audit and Privilege Auditing&lt;/P&gt;&lt;P class=BP&gt;The following statements turn off the corresponding audit options:&lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=1670&gt;&lt;/A&gt;NOAUDIT session;&lt;A name=6272&gt;&lt;/A&gt;NOAUDIT session BY scott, lori;&lt;A name=6273&gt;&lt;/A&gt;NOAUDIT DELETE ANY TABLE;&lt;A name=6274&gt;&lt;/A&gt;NOAUDIT SELECT TABLE, INSERT TABLE, DELETE TABLE,&lt;A name=6275&gt;&lt;/A&gt;    EXECUTE PROCEDURE;&lt;A name=6276&gt;&lt;/A&gt;&lt;/PRE&gt;&lt;A name=1680&gt;&lt;/A&gt;&lt;P class=BP&gt;The following statement turns off all statement audit options:&lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=1682&gt;&lt;/A&gt;NOAUDIT ALL;&lt;A name=12740&gt;&lt;/A&gt;&lt;/PRE&gt;&lt;A name=12733&gt;&lt;/A&gt;&lt;P class=BP&gt;The following statement turns off all privilege audit options:&lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=6277&gt;&lt;/A&gt;NOAUDIT ALL PRIVILEGES;&lt;A name=6278&gt;&lt;/A&gt;&lt;/PRE&gt;&lt;A name=1686&gt;&lt;/A&gt;&lt;P class=BP&gt;To disable statement or privilege auditing options, you must have the &lt;CODE&gt;AUDIT SYSTEM&lt;/CODE&gt; system privilege.&lt;/P&gt;&lt;P class=BP&gt; &lt;/P&gt;&lt;P class=BP&gt;The following statements turn off the corresponding auditing options:&lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=1698&gt;&lt;/A&gt;NOAUDIT DELETE&lt;A name=6279&gt;&lt;/A&gt;   ON emp;&lt;A name=6280&gt;&lt;/A&gt;NOAUDIT SELECT, INSERT, DELETE&lt;A name=6281&gt;&lt;/A&gt;   ON jward.dept;&lt;A name=6282&gt;&lt;/A&gt;&lt;/PRE&gt;&lt;A name=1706&gt;&lt;/A&gt;&lt;P class=BP&gt;Furthermore, to turn off all object audit options on the &lt;CODE&gt;emp&lt;/CODE&gt; table, enter the following statement:&lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=1708&gt;&lt;/A&gt;NOAUDIT ALL&lt;A name=10170&gt;&lt;/A&gt;   ON emp;&lt;A name=10171&gt;&lt;/A&gt;&lt;/PRE&gt;&lt;A name=10174&gt;&lt;/A&gt;&lt;P class=BP&gt;To turn off all default object audit options, enter the following statement:&lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=1718&gt;&lt;/A&gt;NOAUDIT ALL&lt;A name=6285&gt;&lt;/A&gt;   ON DEFAULT;&lt;A name=6286&gt;&lt;/A&gt;&lt;/PRE&gt;&lt;A name=1722&gt;&lt;/A&gt;&lt;P class=BP&gt;All schema objects created before this &lt;CODE&gt;NOAUDIT&lt;/CODE&gt; statement is issued continue to use the default object audit options in effect at the time of their creation, unless overridden by an explicit &lt;CODE&gt;NOAUDIT&lt;/CODE&gt; statement after their creation.&lt;/P&gt;&lt;A name=1724&gt;&lt;/A&gt;&lt;P class=BP&gt;To disable object audit options for a specific object, you must be the owner of the schema object. To disable the object audit options of an object in another user's schema or to disable default object audit options, you must have the &lt;CODE&gt;AUDIT ANY&lt;/CODE&gt; system privilege. A user with privileges to disable object audit options of an object can override the options set by any user.&lt;/P&gt;&lt;P class=BP&gt;Thanks,</description><pubDate>Wed, 28 Oct 2009 16:34:58 GMT</pubDate><dc:creator>Admin</dc:creator></item><item><title>Turning on Audit in Oracle database</title><link>http://www.franklinfaces.com/Topic163-97-1.aspx</link><description>The standard audit commands allow all system privileges to be audited along with access at the object level to any table or &lt;/P&gt;&lt;P&gt;view on the database for select, delete, insert or update. Audit can be run for either successful or unsuccessful attempts or both. &lt;/P&gt;&lt;P&gt;It can be for each individual user or for all users and it can also be done at the session level or access level. At action level a single&lt;/P&gt;&lt;P&gt; record is created per action and at session level one record is created for all audit actions per session. &lt;/P&gt;&lt;P&gt;Here are some commands to set auditing on:&lt;/P&gt;&lt;P class=BP&gt;To audit all successful and unsuccessful connections to and disconnections from the database, regardless of user, &lt;/P&gt;&lt;P class=BP&gt;&lt;CODE&gt;BY SESSION&lt;/CODE&gt; (the default and only value for this option), enter the following statement:&lt;/P&gt;&lt;P class=BP&gt; &lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=9990&gt;&lt;/A&gt;AUDIT SESSION;&lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;P class=BP&gt;You can set this option selectively for individual users also, as in the next example:&lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=9993&gt;&lt;/A&gt;AUDIT SESSION&lt;A name=9994&gt;&lt;/A&gt;BY scott, lori;&lt;/PRE&gt;&lt;P class=BP&gt;Privilege audit options exactly match the corresponding system privileges. For example, the option to audit use of the &lt;/P&gt;&lt;P class=BP&gt;&lt;CODE&gt;DELETE ANY TABLE&lt;/CODE&gt; privilege is &lt;CODE&gt;DELETE ANY TABLE&lt;/CODE&gt;. To turn this option on, you use a statement similar to the following example:&lt;/P&gt;&lt;P class=BP&gt; &lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=10070&gt;&lt;/A&gt;AUDIT DELETE ANY TABLE&lt;A name=10071&gt;&lt;/A&gt;    BY ACCESS&lt;A name=10072&gt;&lt;/A&gt;    WHENEVER NOT SUCCESSFUL;&lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt;&lt;P class=BP&gt;To audit all successful and unsuccessful uses of the &lt;CODE&gt;DELETE ANY TABLE&lt;/CODE&gt; system privilege, enter the following statement:&lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=10111&gt;&lt;/A&gt;AUDIT DELETE ANY TABLE;&lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt;&lt;/PRE&gt;&lt;PRE class=CE&gt;To audit all unsuccessful &lt;CODE&gt;SELECT&lt;/CODE&gt;, &lt;CODE&gt;INSERT&lt;/CODE&gt;, and &lt;CODE&gt;DELETE&lt;/CODE&gt; statements on all tables and unsuccessful uses of the &lt;/PRE&gt;&lt;PRE class=CE&gt;&lt;CODE&gt;EXECUTE PROCEDURE&lt;/CODE&gt; system privilege, by all database users, and by individual audited statement, &lt;/PRE&gt;&lt;PRE class=CE&gt;issue the following statement:&lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt;AUDIT SELECT TABLE, INSERT TABLE, DELETE TABLE, EXECUTE PROCEDURE&lt;A name=10116&gt;&lt;/A&gt;      BY ACCESS&lt;A name=10117&gt;&lt;/A&gt;      WHENEVER NOT SUCCESSFUL;&lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt;&lt;P class=BP&gt;To audit all successful and unsuccessful &lt;CODE&gt;DELETE&lt;/CODE&gt; statements on the &lt;CODE&gt;scott.emp&lt;/CODE&gt; table, &lt;/P&gt;&lt;P class=BP&gt;&lt;CODE&gt;BY SESSION&lt;/CODE&gt; (the default value), enter the following statement:&lt;/P&gt;&lt;P class=BP&gt; &lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=1601&gt;&lt;/A&gt;AUDIT DELETE ON scott.emp;&lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt;&lt;A name=6261&gt;&lt;/A&gt;&lt;/PRE&gt;&lt;A name=1603&gt;&lt;/A&gt;&lt;P class=BP&gt;To audit all successful &lt;CODE&gt;SELECT&lt;/CODE&gt;, &lt;CODE&gt;INSERT&lt;/CODE&gt;, and &lt;CODE&gt;DELETE&lt;/CODE&gt; statements on the &lt;CODE&gt;dept&lt;/CODE&gt; table owned by user &lt;CODE&gt;jward&lt;/CODE&gt;, &lt;/P&gt;&lt;P class=BP&gt;&lt;CODE&gt;BY ACCESS&lt;/CODE&gt;, enter the following statement:&lt;/P&gt;&lt;P class=BP&gt; &lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=1605&gt;&lt;/A&gt;AUDIT SELECT, INSERT, DELETE&lt;A name=6262&gt;&lt;/A&gt;     ON jward.dept&lt;A name=6263&gt;&lt;/A&gt;     BY ACCESS&lt;A name=6264&gt;&lt;/A&gt;     WHENEVER SUCCESSFUL;&lt;/PRE&gt;&lt;PRE class=CE&gt;&lt;A name=6265&gt;&lt;/A&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt;&lt;/PRE&gt;&lt;A name=1619&gt;&lt;/A&gt;&lt;P class=BP&gt;To set the default object auditing options to audit all unsuccessful &lt;CODE&gt;SELECT&lt;/CODE&gt; statements, &lt;/P&gt;&lt;P class=BP&gt;&lt;CODE&gt;BY SESSION&lt;/CODE&gt; (the default), enter the following statement:&lt;/P&gt;&lt;P class=BP&gt; &lt;/P&gt;&lt;PRE class=CE&gt;&lt;A name=1621&gt;&lt;/A&gt;AUDIT SELECT&lt;A name=6266&gt;&lt;/A&gt;     ON DEFAULT&lt;A name=12973&gt;&lt;/A&gt;     WHENEVER NOT SUCCESSFUL;&lt;/PRE&gt;&lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;PRE class=CE&gt; &lt;/PRE&gt;&lt;/PRE&gt;&lt;P&gt;You can check the following to see audit settings in oracle.&lt;/P&gt;&lt;P&gt;set serveroutput on size 1000000&lt;BR&gt;&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- SQL to check if the audit has been enabled in the database and where the output will be&lt;BR&gt;-- written to.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;select name,value from v$parameter&lt;BR&gt;where name like 'audit%'&lt;BR&gt;/&lt;BR&gt;&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- Test to see what audit actions are defined. Note:- doesn't include object audit actions.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;select * from dba_stmt_audit_opts&lt;BR&gt;union&lt;BR&gt;select * from dba_priv_audit_opts&lt;BR&gt;/&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- Turn on audit for capturing logon and logoff attemempts for all users except&lt;BR&gt;-- privileged attempts.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;audit create session&lt;BR&gt;/&lt;BR&gt;&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- check what audit privileges have been granted and to what users and roles.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;select *&lt;BR&gt;from dba_sys_privs&lt;BR&gt;where privilege like '%AUDIT%'&lt;BR&gt;&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- SQL to test for failed logon attempts, grouped per day.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;select count(*),username,terminal,to_char(timestamp,'DD-MON-YYYY')&lt;BR&gt;from dba_audit_session&lt;BR&gt;where returncode&amp;lt;&amp;gt;0&lt;BR&gt;group by username,terminal,to_char(timestamp,'DD-MON-YYYY')&lt;BR&gt;/&lt;BR&gt;&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- SQL to check for attempts to access the database with non existant users. This could&lt;BR&gt;-- indicate someone trying to guess user names and passwords.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;select username,terminal,to_char(timestamp,'DD-MON-YYYY HH24:MI:SS')&lt;BR&gt;from dba_audit_session&lt;BR&gt;where returncode&amp;lt;&amp;gt;0&lt;BR&gt;and not exists (select 'x'&lt;BR&gt;   from dba_users&lt;BR&gt;   where dba_users.username=dba_audit_session.username)&lt;BR&gt;/&lt;BR&gt;&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- Check for access attempts to the database at unusual hours. The two times should&lt;BR&gt;-- be altered or passed in and if detail is needed for multiple days then group by &lt;BR&gt;-- the date as well.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;select username,&lt;BR&gt;terminal,&lt;BR&gt;    action_name,&lt;BR&gt;    returncode,&lt;BR&gt;    to_char(timestamp,'DD-MON-YYYY HH24:MI:SS'),&lt;BR&gt;    to_char(logoff_time,'DD-MON-YYYY HH24:MI:SS')&lt;BR&gt;from dba_audit_session&lt;BR&gt;where to_date(to_char(timestamp,'HH24:MI:SS'),'HH24:MI:SS') &amp;lt; to_date('08:00:00','HH24:MI:SS')&lt;BR&gt;or to_date(to_char(timestamp,'HH24:MI:SS'),'HH24:MI:SS') &amp;gt; to_date('19:30:00','HH24:MI:SS')&lt;BR&gt;/&lt;BR&gt;&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- Check for users sharing database logons.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;select count(distinct(terminal)),username&lt;BR&gt;from dba_audit_session&lt;BR&gt;having count(distinct(terminal))&amp;gt;1&lt;BR&gt;group by username&lt;BR&gt;/&lt;BR&gt;&lt;/P&gt;&lt;P&gt;--&lt;BR&gt;-- Check for multiple database accounts being used from one terminal. This could indicate&lt;BR&gt;-- wrong doing as each terminal should in theory be used by one person and one account?&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;select count(distinct(username)),terminal&lt;BR&gt;from dba_audit_session&lt;BR&gt;having count(distinct(username))&amp;gt;1&lt;BR&gt;group by terminal&lt;BR&gt;/&lt;BR&gt;&lt;BR&gt;--&lt;BR&gt;-- Check the audit trail for any changes being made to the structure of the database schema.&lt;BR&gt;--&lt;BR&gt;&lt;BR&gt;col username for a8&lt;BR&gt;col priv_used for a16&lt;BR&gt;col obj_name for a22&lt;BR&gt;col timestamp for a17&lt;BR&gt;col returncode for 9999&lt;BR&gt;select  username,&lt;BR&gt;        priv_used,&lt;BR&gt;        obj_name,&lt;BR&gt;        to_char(timestamp,'DD-MON-YYYY HH24:MI') timestamp,&lt;BR&gt;        returncode&lt;BR&gt;from dba_audit_trail&lt;BR&gt;where priv_used is not null&lt;BR&gt;and priv_used&amp;lt;&amp;gt;'CREATE SESSION'&lt;BR&gt;/&lt;BR&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;BR&gt;</description><pubDate>Wed, 28 Oct 2009 16:29:31 GMT</pubDate><dc:creator>Admin</dc:creator></item></channel></rss>
