Bo's Oracle Station

查看: 1917|回复: 0

课程第7次(2018-10-16星期二)

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2018-10-16 19:32:13 | 显示全部楼层 |阅读模式
1. 强制性审计:
  1. /u01/app/oracle/admin/orcl/adump
复制代码
不能满。
  1. SQL> conn / as sysdba
  2. Connected.
  3. SQL> !ps
  4.   PID TTY          TIME CMD
  5. 14404 pts/2    00:00:00 sqlplus
  6. 14478 pts/2    00:00:00 ps

  7. SQL> select p.spid
  8.   2  from v$session s , v$process p
  9.   3  where s.paddr=p.addr
  10.   4  and s.terminal='pts/2';

  11. SPID
  12. ------------------------
  13. 14405

复制代码
  1. -rw-r----- 1 oracle asmadmin  781 10月 16 10:52 orcl_ora_25495_1.aud
  2. -rw-r----- 1 oracle asmadmin  781 10月 16 10:58 orcl_ora_9708_2.aud
  3. -rw-r----- 1 oracle asmadmin  781 10月 16 10:58 orcl_ora_9709_2.aud
  4. -rw-r----- 1 oracle asmadmin  770 10月 16 16:56 orcl_ora_6719_2.aud
  5. -rw-r----- 1 oracle asmadmin  777 10月 16 16:56 orcl_ora_6719_3.aud
  6. -rw-r----- 1 oracle asmadmin  783 10月 16 16:56 orcl_ora_6888_1.aud
  7. -rw-r----- 1 oracle asmadmin  778 10月 16 16:56 orcl_ora_6894_1.aud
  8. -rw-r----- 1 oracle asmadmin  817 10月 16 16:56 orcl_ora_7039_1.aud
  9. -rw-r----- 1 oracle asmadmin  819 10月 16 19:30 orcl_ora_14405_1.aud
复制代码
2. 标准审计:
  1. extended, xml, db_extended, false, true, none, os, db
复制代码

  1. select s.user_name,  s.audit_option  from dba_stmt_audit_opts  s
  2. minus
  3. select  p.user_name,p.privilege    from  dba_priv_audit_opts  p;

  4. select  * from dba_priv_audit_opts;

  5. select  * from dba_obj_audit_opts;

  6. audit select  on hr.employees by session whenever  successful;

  7. select  *   from dba_audit_trail  t
  8.   order by t.timestamp  desc ;

  9. select  * from dba_views v
  10. where v.view_name='DBA_AUDIT_TRAIL';

  11. select  t.tablespace_name
  12. from dba_tables t
  13.   where t.owner='SYS' and t.table_name='AUD








  14. ;


  15. create tablespace tbsaudit datafile size 120M autoextend on;

  16. alter table aud$ move tablespace  tbsaudit;

  17. noaudit  create session ;

  18. truncate table aud$;

  19. audit create session by hr by access whenever  successful;


  20. audit select  on hr.employees by session whenever  successful;

  21. audit update on hr.employees by access whenever successful;

  22. audit table by hr  whenever successful ;

  23. -------------------------------

  24. select  * from v$xml_audit_trail  order by 6 desc;


  25. select  * from dba_common_audit_trail  c
  26. where c.db_user='HR'
  27. order by 6 desc;
复制代码
  1. select  * from dba_audit_policies;

  2. select  * from dba_audit_policy_columns;


  3. create table tfga  (  a varchar2(200) ) tablespace tbsaudit;

  4. CREATE OR REPLACE PROCEDURE
  5. procfga  ( object_schema VARCHAR2, object_name VARCHAR2, policy_name VARCHAR2 )
  6. AS
  7. begin
  8. insert into   tfga values ( to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS')||' '||
  9.                                          sys_context('userenv','ip_address')||' '||
  10.                                          user||' '||
  11.                                          sys_context('userenv','current_user')||' '||
  12.                                          object_schema||' '||
  13.                                          object_name||' '||
  14.                                          policy_name);
  15. end;

  16. select  * from user_errors;
  17. select  * from dba_objects o where o.object_name='PROCFGA';

  18. begin
  19.    dbms_fga.add_policy(object_schema => 'HR',
  20.    object_name => 'EMPLOYEES',
  21.    policy_name => 'POLICY1',
  22.    audit_condition => 'department_id=20',
  23.    audit_column => 'SALARY,COMMISSION_PCT',
  24.    handler_schema => 'SYS',
  25.    handler_module => 'PROCFGA',
  26.    statement_types => 'SELECT,UPDATE',
  27.    audit_trail => dbms_fga.XML+dbms_fga.EXTENDED,
  28.    audit_column_opts => dbms_fga.ALL_COLUMNS);
  29. end;
  30.    
  31. select  * from dba_common_audit_trail  c
  32. where c.db_user='HR'
  33. order by 6 desc;

  34. select  * from tfga;



  35.    
  36.    

复制代码
基于值的审计:
  1. create table tvalue  (  a varchar2(200) ) tablespace tbsaudit;

  2. CREATE OR REPLACE trigger trgvalue
  3. after update  of salary  on hr.employees
  4. referencing new as new old as old
  5. for each row
  6. begin
  7.   if :old.salary <> :new.salary
  8.     then
  9.       insert into   tvalue values ( to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS')||' '||
  10.                                          sys_context('userenv','ip_address')||' '||
  11.                                          user||' '||
  12.                                          sys_context('userenv','current_user')||' '||
  13.                                          :old.salary||' '||
  14.                                           :new.salary
  15.                                         );
  16.        end if;
  17. end;

  18. select  * from user_errors;

  19. select  * from dba_triggers  t where t.trigger_name='TRGVALUE';

  20. select  * from tvalue;

  21. select  * from tfga;
复制代码

上完1Z0-052 第11章 审计(5/40)







回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-4-16 21:23 , Processed in 0.035043 second(s), 24 queries .

快速回复 返回顶部 返回列表