少女祈祷中...

奶龙牌图片处理器2.0

1.看上去像是文件上传,测试一下过滤:

image-20250524103643031

过滤:

1
2
php					 #无论大小写
<?

发现.use.ini可以上传

补充:.use.ini怎么用

当我们上传的.use.ini文件有如下内容:

1
2
3
4
5
6
7
8
9
在我们可以上传php文件时候使用:
GIF89a //绕过exif_imagetype()
auto_prepend_file=a.jpg //指定在主文件之前自动解析的文件的名称,并包含该文件,就像使用require函 数调用它一样。它包含在所有php文件前先执行
auto_append_file=a.jpg //解析后进行包含,它包含在所有php文件执行后执行

如果猜测到文件名字和位置:
auto_prepend_file= /flag
auto_append_file= /flag
#两个最好一起写,都有可能

写入有什么用呢

auto_prepend_file=a.jpg当我们访问当前文件夹下的任意PHP文件时候,就会把结果一起输出到该文件

auto_prepend_file= /flag:可以直接输出flag(如果纯文本 or echo函数

性质:

image-20250526230805162

2.PHP的解析机制:

当通过 includerequire 或自动包含(.user.ini)加载文件时,PHP 会解析文件中的代码并执行而非显示源代码

前提

  • 路径权限:
    • /flag路径正确且Web用户有读取权限。
    • .user.ini与目标PHP文件在同一目录,且PHP支持.user.ini配置(通常需CGI/FastCGI模式)。
  • PHP配置:
    • allow_url_include=On(允许包含本地文件)。
    • 未设置open_basedir限制访问/flag

exp:

1
2
3
auto_prepend_file= /flag
auto_append_file= /flag
#放入.use.ini文件即可

外国山海经

考察点:js代码审核能力

扫描发现:

image-20250524124808632

打开robots.txt得到:

image-20250524124837018

1
#shu.php  sha.php  wa.php  flag.php  flag.php.swp

前三个返回都是404:

image-20250524125016251

访问/flag.php得到:

image-20250524125050766

访问/flag.php.swp

页面有点乱,叫ai提取出来

image-20250524130910101

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
<?php
header("Content-Security-Policy: default-src 'self';");

function validate_params($method = 'GET', $max = 5) {
global $content;
$raw = ($method === 'GET')
? $_SERVER['QUERY_STRING']
: file_get_contents('php://input');

parse_str($raw, $params);

if (count($params) > $max) {
http_response_code(400);
$content = "参数多了!";
}
$pattern = '/(?:^|&)(\w+)(?:=|&|$)/';
preg_match_all($pattern, $raw, $matches);

if (count($matches[1]) !== count(array_unique($matches[1]))) {
$duplicates = array_diff_assoc($matches[1], array_unique($matches[1]));
http_response_code(400);
$content = "有重复的,不准";
}
}
?>

<?php
$content = strtolower($_GET["keyword"]);

$filters = [
'/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/is' => '[no!no!no!]',
'/on\w+\s*=\s*(["\']).*?\1/is' => '[no!no!no!]',
'/(?:href|src)\s*=\s*(["\'])\s*javascript:.*?\1/is' => '[no!no!no!]',
'/(?:href|src)\s*=\s*(["\'])\s*data:.*?\1/is' => '[no!no!no!]',
'/style\s*=\s*(["\']).*?expression\([^>]*?\).*?\1/is' => '[no!no!no!]',
'/<\/?(?:iframe|object|embed|link|img|meta|base|source|form|input|video|audio|textarea|button|frame|frameset|applet)[^>]*?>/is' => '[no!no!no!]',
'/\b(?:style|srcset|formaction|xlink:href|contenteditable|xmlns)\s*=\s*(["\']).*?\1/is' => '[no!no!no!]',
'/(?:href|src)\s*=\s*(["\'])(?:\s*javascript:|vbscript:|file:|data:|filesystem:).*?\1/is' => '[no!no!no!]',
'/\b(?:eval|prompt|confirm|console\.log|Function)\s*\(/is' => '[no!no!no!]'
];


foreach ($filters as $pattern => $replacement) {
$content = $content ? preg_replace($pattern, $replacement, $content) : '';
}
validate_params('GET', 3);
validate_params('POST', 5);
echo $content;
echo "<h3 align=center>payload的长度:" . strlen($content) . "</h3>";
?>

misc

小小挑战:

1
binwalk -e '/home/flitar/桌面/MISC/小小挑战.png' 

image-20250527104639729

发现存在隐写