`
java-mans
  • 浏览: 11436374 次
文章分类
社区版块
存档分类
最新评论

oracle-审计2

 
阅读更多

三、语句审计:
语句审计选项包括:


/*
语句审计选项 触发SQL语句
alter sequence alter sequence

alter tablealter table

comment tablecomment on table、comment on column

database linkcreate database link、drop database link

delete tabledelete

execute procedure执行任意一个过程、函数或对一个报中的任意一个游标或变量的访问

grant procedureone function or package or grant on procedure

grant sequencea grant on sequence(一个序列上的grant)

grant tablegrant of one table or view (一个表或视图上的grant)

indexcreate index

insert tableinsert of table or view(表或视图上的insert)

lock tablelock

not existsall sql(所有的SQL语句)

procedurecreate function;drop function;create package; create package body;
drop package;create procedure;drop procedure;


profilecreate profile;alter profile;drop profile;

rolecreate role;alter role;drop role; set role;


select sequenceselect of a sequence(一个序列上的select)

select tableselect from table or view(从表或视图上的select)


sequencecreate sequence; drop sequence

sessionlogon

synonymcreate synonym;drop synonym;


system auditaudit;noaudit

system grantgrant; revoke

tablecreate table;drop table; truncate table


tablespacecreate tablespace; alter tablespace; drop tablespace

triggercreate trigger;alter trigger;alter table;


update tableupdate of a table or view(一个表或视图上的update)


usercreate user; alter user; drop user;

view create view; drop view

*/


-- 3.1 查看数据库中已经启用审计的选项

SQL> select user_name, audit_option, success, failure
2 from dba_stmt_audit_opts;

未选定行

SQL> audit table;

审计已成功。

SQL> select user_name, audit_option, success, failure from dba_stmt_audit_opts;

USER_NAME AUDIT_OPTION
------------------------------ ---------------------------------------
SUCCESS FAILURE
---------- ----------
TABLE
BY ACCESS BY ACCESS


-- 3.2 启用指定语句审计

SQL> audit table;

审计已成功。

-- 3.3 启用指定用户审计

SQL> show parameters audit_trail

NAME TYPE VALUE
------------------------------------ ----------- ---------------
audit_trail string DB
SQL> audit table by scott;

审计已成功。


-- 3.4 启用针对用户失败时的审计

SQL> audit table by scott whenever not successful;

审计已成功。

SQL> select user_name, audit_option, success, failure from dba_stmt_audit_opts;

USER_NAME AUDIT_OPTION SUCCESS FAILURE
------------------------------ ---------------------------------------- ---------- ----------
SCOTT TABLE NOT SET BY ACCESS


-- 3.5 启用针对用户成功时的审计

SQL> audit table by scott whenever successful;

SQL> select user_name, audit_option, success, failure from dba_stmt_audit_opts;

USER_NAME AUDIT_OPTION SUCCESS FAILURE
------------------------------ ---------------------------------------- ---------- ----------
SCOTT TABLE BY ACCESS NOT SET

-- 3.6 启用非DDL审计
SQL> select user_name, audit_option, success, failure from dba_stmt_audit_opts;

USER_NAME AUDIT_OPTION SUCCESS FAILURE
------------------------------ ---------------------------------------- ---------- ----------

SQL> audit insert table by scott by access;

Audit succeeded

SQL> conn scott/tiger
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as scott

SQL> create table t1
2 (sid int);

Table created

SQL> insert into t1 values (1001);

1 row inserted

SQL> select * from t1;

SID
---------------------------------------
1001

SQL> update t1 set sid=2003 where sid=1001;

1 row updated

SQL> delete from t1;

1 row deleted

SQL> conn sys as sysdba
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as SYS

SQL> select user_name, audit_option, success, failure from dba_stmt_audit_opts;

USER_NAME AUDIT_OPTION SUCCESS FAILURE
------------------------------ ---------------------------------------- ---------- ----------
SCOTT INSERT TABLE BY ACCESS BY ACCESS


-- 3.7 关闭语句审计
SQL> noaudit table;

审计未成功。


SQL> noaudit insert table by scott;

Noaudit succeeded


----------------------------------------------------------------------------------------
****************************************************************************************
四、管理特权审计:
****************************************************************************************
----------------------------------------------------------------------------------------
管理特权审计包括监视和记录需要一个指定系统特权的SQL语句的执行;可以审计任意一个系统特权。


-- 4.1 启用审计特权

SQL> audit create any table;

Audit succeeded

-- 4.2 审计具体用户

/*
环境准备:

create user win identified by password
quota 100m on users;

grant create session, create table to win;


*/

--步骤1:检查已经启用特权审计

SQL> select user_name, privilege, success, failure from dba_priv_audit_opts ;


USER_NAME PRIVILEGE SUCCESS FAILURE
------------------------------ ---------------------------------------- ---------- ----------


--步骤2:启用特权审计
SQL> audit select any table by scott by access;

Audit succeeded

--步骤3:检查已经启用特权审计

SQL> select user_name, privilege, success, failure from dba_priv_audit_opts ;

USER_NAME PRIVILEGE SUCCESS FAILURE
------------------------------ ---------------------------------------- ---------- ----------
SCOTT SELECT ANY TABLE BY ACCESS BY ACCESS

--步骤4:连接到scott账户操作

SQL> conn scott/tiger
已连接。
SQL> select * from win.accp;

TID
----------
1001


--步骤5:检查审计跟踪

SQL> select username, to_char(timestamp,'yyyy:mm:dd:hh'), action_name
from dba_audit_trail where username= 'SCOTT';


USERNAME TIME ACTION_NAME
------------------------------ ------------- ----------------------------
SCOTT 2008:10:29:01 SELECT


--步骤6:清空审计记录


SQL> delete from sys.aud$ ;

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics