oracle ip欺骗,Oracle 在重要的表上限制某些IP、用户的恶意操作
1,問題描述
Oracle默認賬號是沒有限制ip的,這樣的隱患就在于,如果我知道了oracle賬號用戶名密碼,我只要能連接到db,就可以對db進行操作,這樣對于線上的db來說是很危險的,因為有些非dba人員,比如開發人員、測試人員一不小心誤刪除了線上的數據,就慘了,坑太大不敢看。所以查了查,找到一種辦法,在一些重要的表上加觸發器來限制用戶對線上db的表的操作。
2,觸發器編寫
如果開全局的sql審計,消耗性能太大,不太合適,想來只有在某些重要的表上做限制,初步解決問題了。
1)? 驗證ip:(sys_context('userenv','ip_address')not in('192.168.120.211')
2)? 驗證用戶名:selects.USERNAME into v_username from v$session s where s.audsid=(selectuserenv('SESSIONID') from dual) and rownum<2
3)? 樣例存儲過程如下:
create or replace triggerpri_stu_test_limit
before update or delete or insert on stu.zzz_test
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
v_username varchar2(200) default '';
BEGIN
select s.USERNAME into v_username from v$session s wheres.audsid=(select userenv('SESSIONID') from dual) and rownum<2;
IFdeleting
AND (sys_context('userenv','ip_address') not in('192.168.120.211')? ? OR 'stuuser' like v_username)
THEN
RAISE_APPLICATION_ERROR(-20001, 'can not delete the table ');
ELSIF inserting
AND (sys_context('userenv','ip_address') not in('192.168.120.211')? ? OR 'stuuser' like v_username)
THEN
RAISE_APPLICATION_ERROR(-20001, 'can not insert the table ');
ELSIF updating
AND (sys_context('userenv','ip_address') not in('192.168.120.211')? ? OR 'stuuser' like v_username)
THEN
RAISE_APPLICATION_ERROR(-20001, 'can not update the table ');
END IF;
END;
3,驗證:
SQL>
SQL> insert into stu.zzz_testvalues(3,'zhuren33');
insert into stu.zzz_testvalues(3,'zhuren33')
ORA-20001: can not insert the table
ORA-06512: at"stuuser.PRI_STU_ACCT_LIMIT", line 18
ORA-04088: error during execution oftrigger 'stuuser.PRI_STU_ACCT_LIMIT'
SQL> commit;
Commit complete
SQL>
SQL> update stu.zzz_test setremark='zhuren33_up' where id=3;
update stu.zzz_test setremark='zhuren33_up' where id=3
ORA-20001: can not update the table
ORA-06512: at"stuuser.PRI_STU_ACCT_LIMIT", line 22
ORA-04088: error during execution oftrigger 'stuuser.PRI_STU_ACCT_LIMIT'
SQL> commit;
Commit complete
SQL>
SQL> delete from? stu.zzz_test where id=3;
delete from stu.zzz_test where id=3
ORA-20001: can not delete the table
ORA-06512: at"stuuser.PRI_STU_ACCT_LIMIT", line 14
ORA-04088: error during execution oftrigger 'stuuser.PRI_STU_ACCT_LIMIT'
SQL> commit;
Commit complete
SQL>
OK增刪改都可以被限制住了,應該暫時解決了問題所在,后續還是有很多問題需要一起解決的。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的oracle ip欺骗,Oracle 在重要的表上限制某些IP、用户的恶意操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 阿里搞出脱口秀版GPT 把“鸟鸟”塞进去
- 下一篇: oracle system表空间扩容,O