csrv2022-wp

本文最后更新于:2024年4月6日 下午

V1rusCheckor3000

题目给了源代码

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

if (isset($_FILES["file"])) {
$size = $_FILES["file"]['size'];

if ($size > 100) {
echo "For such large files, buy premium";
} else {
$target_dir = "uploads/";
$target_file = $target_dir . $_FILES["file"]["name"];

move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);

function hasVirus($file_path) {
# Check for Virus
$argument = escapeshellarg($file_path);
exec("clamscan $argument", $output, $retval);

if ($retval != 0) {
return true;
}
return false;
}

if (hasVirus($target_file)) {
echo "The file contains a virus!";
} else {
echo "The file is safe to use!";
}

unlink($target_file);
}

}

if (isset($_GET["source"])) {
highlight_file(__FILE__);
}
?>

一开始审计我是打算escapeshellarg绕过然后命令注入利用–move把我上传的马移动到根目录躲unlink然后getshell,但是没有成功,不知道是否有可行性。

看了wp学到了有个东西叫条件竞争,大概就是利用服务器的多线程问题去攻击的

用burp的intruder重复上传,再开一个低线程去重复请求uploads/shell.php,就能访问到,php还有文件锁,一直被访问的文件不会被删除,这是一个很有意思的trick,mark了。


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!