数据库等保测评命令
Oracle测评命令
版本号
SELECT * FROM v$version;
密码复杂度
select limit from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_VERIFY_FUNCTION';
密码长度
cat utlpwdmg.sql | grep length
密码定期周期
select limit from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';
登陆失败限制策略
select limit from dba_profiles where profile='DEFAULT' and resource_name='FAILED_LOGIN_ATTEMPTS';
登陆失败锁定策略
select limit from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_LOCK_TIME';
登陆超时退出策略
select limit from dba_profiles where profile='DEFAULT' and resource_name='IDLE_TIME';
查看范例数据库账号
select username, account_status from dba_users;
是否创建了策略
select policy_name, status from DBA_SA_POLICIES;
是否创建了级别
select * from dba_sa_level order by level_num;
查看标签创建情况
select * from dba_sa_labels;
查看策略与模式、表的对应关系
select * from dba_sa_tables_policies;
是否开启审计功能
select value from v$parameter where name='audit_trail';
查询日志文件的位置
show parameter dump_dest;
查看数据库、表空间、对象的日志记录模式
select log_mode,force_logging from v$database;
select tablespace_name, logging,force_logging from dba_tablespaces;
select table_name,logging from user_tables;
检查审计权限是否被严格限制
alter system set audit_trail=none
查看oracle补丁安装情况
opatch lspatches
MySQL测评命令
进入数据库
mysql -u root -p
版本号
mysql --version;
SELECT VERSION();
查询账号
select user,host from mysql.user;
查询是否存在空口令用户
MySQL5.7之前:
select * from mysql.user where length(password) = 0 or password is null;
MySQL5.7之后:
select * from mysql.user where length(authentication_string)= 0 or authentication_string is null;
查看用户口令复杂度配置
show variables like 'validate%';
SHOW VARIABLES LIKE '%password%';
检查口令定期更换
select host,user,password_lifetime from mysql.user
检查配置登录失败处理参数
show variables like ‘connction_control’;
检查连接超时
show variables like ‘%timeout’;
查看登陆失败处理功能
show variables like '%max_connect_errors%';
show variables like '%timeout%';
查看远程管理是否启用加密
show variables like '%have_ssl%';
查看账户分配和权限
select user,host from mysql.user;
show grants for 'xxxx'@'localhost';
查看root账户是否被重命名或删除
select user,host from mysql.user;
查看访问控制权限
select * from mysql.user\G; #查看用户权限列
select * from mysql.db\G; #查看数据库权限列
select * from mysql.tables_priv\G; #查看用户表权限列
select * from mysql.columns_priv\G; #查看列权限列管理员
查看日志内容
show variables like 'log_%';
查看补丁安装情况
show variables where variable_name like "version";
SQL Sever测评命令
待续…