oracle ip欺骗,Oracle 在重要的表上限制某些IP、用户的恶意操作
1,問題描述
Oracle默認(rèn)賬號(hào)是沒有限制ip的,這樣的隱患就在于,如果我知道了oracle賬號(hào)用戶名密碼,我只要能連接到db,就可以對(duì)db進(jìn)行操作,這樣對(duì)于線上的db來(lái)說是很危險(xiǎn)的,因?yàn)橛行┓莇ba人員,比如開發(fā)人員、測(cè)試人員一不小心誤刪除了線上的數(shù)據(jù),就慘了,坑太大不敢看。所以查了查,找到一種辦法,在一些重要的表上加觸發(fā)器來(lái)限制用戶對(duì)線上db的表的操作。
2,觸發(fā)器編寫
如果開全局的sql審計(jì),消耗性能太大,不太合適,想來(lái)只有在某些重要的表上做限制,初步解決問題了。
1)? 驗(yàn)證ip:(sys_context('userenv','ip_address')not in('192.168.120.211')
2)? 驗(yàn)證用戶名:selects.USERNAME into v_username from v$session s where s.audsid=(selectuserenv('SESSIONID') from dual) and rownum<2
3)? 樣例存儲(chǔ)過程如下:
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,驗(yàn)證:
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增刪改都可以被限制住了,應(yīng)該暫時(shí)解決了問題所在,后續(xù)還是有很多問題需要一起解決的。
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的oracle ip欺骗,Oracle 在重要的表上限制某些IP、用户的恶意操作的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 阿里搞出脱口秀版GPT 把“鸟鸟”塞进去
- 下一篇: 双门四座纯电跑车哪吒 GT 首发亮相:跻