当前位置:   article > 正文

oracle数据库安全基线自动检测脚本_oracle 安全配置基线检测脚本

oracle 安全配置基线检测脚本
  1. #!/bin/bash
  2. #version 2.1 此脚本在rhel,centos,oel系统均已测试通过,适用于9i 10g 11g。但未在aix,solaris,unix测试,如果遇到问题请自行微调。
  3. #Author: jn
  4. #Date: 2016.8
  5. HOSTNAME=`hostname`
  6. echo $HOSTNAME > orack.res.lst
  7. SQLPLUS=$ORACLE_HOME/bin/sqlplus
  8. $SQLPLUS "/ as sysdba" << EOF
  9. ------- 设置行宽、叶宽 ----------
  10. set line 150
  11. set pagesize 1000
  12. set feed off
  13. spool orack.res.lst
  14. ------- 脚本开始运行的时间 ------------
  15. select 'Started On ' || to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') started_time from dual;
  16. ------- Oracle的版本 ------------
  17. select banner from v\$version;
  18. #select banner from v$version;
  19. ------- 查看Oracle登录认证方式 ----------
  20. show parameter remote_login_passwordfile
  21. ------- 查看 oracle 用户密码HASH值 -----------
  22. select name,password from user\$;
  23. select name,password from user\$ where name in ( select username from dba_users where account_status='OPEN');
  24. ------- 查看出于Active状态的帐号 ------------
  25. col username for a20
  26. col profile for a20
  27. select username,profile from dba_users where account_status='OPEN';
  28. set line 150
  29. set pagesize 1000
  30. col profile for a20
  31. col resource_name for a30
  32. col resource for a25
  33. col limit for a30
  34. select * from dba_profiles;
  35. select * from dba_profiles where profile='DEFAULT';
  36. ------- 查看是否开启了资源限制 ------------
  37. show parameter resource_limit
  38. -------查看审计开启情况-----
  39. show parameter audit
  40. ------- 查看密码方面的限制 ------------
  41. col resource_name for a40
  42. col limit for a20
  43. col profile for a40
  44. select resource_name,limit,profile from dba_profiles where resource_type='PASSWORD';
  45. ------- 查看哪些用户具有DBA权限 ---------------
  46. col grantee for a15
  47. col granted_role for a15
  48. col admin_option for a15
  49. col default_role for a15
  50. select * from dba_role_privs where grantee in ( select username from dba_users where account_status='OPEN') and granted_role='DBA' order by grantee;
  51. ------- 查询视图dba_tab_privs被授予了public角色和执行权限表的数量 -------
  52. select count(*) table_name from dba_tab_privs where grantee='PUBLIC' and privilege='EXECUTE' and table_name in ('UTL_FILE', 'UTL_TCP', 'UTL_HTTP', 'UTL_SMTP', 'DBMS_LOB', 'DBMS_SYS_SQL', 'DBMS_JOB');
  53. ------- 查看激活用户的配置情况 -------
  54. select * from dba_profiles where profile in (select profile from dba_users where account_status='OPEN') and limit NOT IN('DEFAULT','UNLIMITED','NULL');
  55. ------- 查看第三方审计工具的安装情况 -------
  56. SELECT * FROM V\$OPTION WHERE PARAMETER = 'Oracle Database Vault';
  57. #SELECT * FROM V$OPTION WHERE PARAMETER = 'Oracle Database Vault';
  58. ------- 查看oracle最大连接数-------
  59. show parameter processes;
  60. ------- 查看非系统用户角色被授予dba的用户的数量 -------
  61. select count(a.username) from dba_users a left join dba_role_privs b on a.username = b.grantee where granted_role = 'DBA' and a.username not in ('SYS','SYSMAN','SYSTEM');
  62. ------- 查看数据库会话 -------
  63. show parameter sessions;
  64. ------- 当sql92_security被设置成TRUE时,对表执行UPDATE/DELETE操作时会检查当前用户是否具备相应表的SELECT权限 --------
  65. show parameter sql92_security;
  66. ------- O7_DICTIONARY_ACCESSIBILITY参数控制对数据字典的访问.设置为true,如果用户被授予了如select any table等any table权限,用户即使不是dba或sysdba用户也可以访问数据字典,建议为false -------
  67. show parameter O7_DICTIONARY_ACCESSIBILITY;
  68. spool off
  69. EOF
  70. # Oracle Port Number
  71. echo -e "\n\n" >> orack.res.lst
  72. echo "----------Port 1521 in listener.ora----------" >> orack.res.lst
  73. echo "" >> orack.res.lst
  74. LISTEN_ORA=$ORACLE_HOME/network/admin/listener.ora
  75. SQLNET_ORA=$ORACLE_HOME/network/admin/sqlnet.ora
  76. if [ -f $LISTEN_ORA ];then
  77. grep 1521 $LISTEN_ORA >> orack.res.lst
  78. else
  79. echo "File $LISTEN_ORA Is Not Exists!!!" >> orack.res.lst
  80. fi
  81. # Listener Password
  82. echo -e "\n" >> orack.res.lst
  83. echo "----------Listener Password in listener.ora----------" >> orack.res.lst
  84. echo "" >> orack.res.lst
  85. if [ -f $LISTEN_ORA ];then
  86. grep -i PASSWORDS_LISTENER $LISTEN_ORA >> orack.res.lst
  87. else
  88. echo "File $LISTEN_ORA Is Not Exists!!!" >> orack.res.lst
  89. fi
  90. # SQLNET TIMEOUT
  91. echo -e "\n" >> orack.res.lst
  92. echo "----------sqlnet timeout in sqlnet.ora----------" >> orack.res.lst
  93. echo "" >> orack.res.lst
  94. if [ -f $SQLNET_ORA ];then
  95. grep -i SQLNET.EXPIRE_TIME $SQLNET_ORA >> orack.res.lst
  96. else
  97. echo "File $SQLNET_ORA Is Not Exists!!!" >> orack.res.lst
  98. fi
  99. # SQLNET Trusted IP
  100. echo -e "\n" >> orack.res.lst
  101. echo "----------sqlnet trusted IP in sqlnet.ora----------" >> orack.res.lst
  102. echo "" >> orack.res.lst
  103. if [ -f $SQLNET_ORA ];then
  104. egrep -i "tcp.validnode_checking|tcp.invited_nodes|tcp.excluded_nodes" $SQLNET_ORA >> orack.res.lst
  105. else
  106. echo "File $SQLNET_ORA Is Not Exists!!!" >> orack.res.lst
  107. fi
  108. echo -e "\n\n" >> orack.res.lst
  109. echo "========================== End On `date` ==========================" >> orack.res.lst

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/954650
推荐阅读
相关标签
  

闽ICP备14008679号