admin 管理员组

文章数量: 1184232

VulnHub

简介

本以为该靶机是利用XXE获取权限,做的过程中才发现该靶机不已拿权限为目的,该靶机为CTF题,目的在于学习XXE漏洞。
靶机下载地址:,254/

信息收集

使用nmap --min-rate 10000 192.168.142.136 --script=vuln -sV扫描目标主机发现开启80和5355端口,80端口中间件为Apache 2.4.27,存在robots.txt文件,如图:

访问80端口为Apache默认页面,查看robots.txt文件,如图:

访问/xxe目录为登录页面,如图:

提交用户名和密码发现提交的数据是xml格式,如图:

扫描网站目录及文件发现admin.php文件,如图:

漏洞发现

根据靶机名称及提交的数据格式猜测存在XXE漏洞,直接利用主动扫描发现存在XXE漏洞,如图:

读取到/etc/passwd文件内容,如图:

漏洞利用

利用XXE读取admin.php文件,如图:

Base64解码之后如下:

<?phpsession_start();
?>
<html lang = "en"><head><title>admin</title><link href = "css/bootstrap.min.css" rel = "stylesheet"><style>body {padding-top: 40px;padding-bottom: 40px;background-color: #ADABAB;}.form-signin {max-width: 330px;padding: 15px;margin: 0 auto;color: #017572;}.form-signin .form-signin-heading,.form-signin .checkbox {margin-bottom: 10px;}.form-signin .checkbox {font-weight: normal;}.form-signin .form-control {position: relative;height: auto;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;padding: 10px;font-size: 16px;}.form-signin .form-control:focus {z-index: 2;}.form-signin input[type="email"] {margin-bottom: -1px;border-bottom-right-radius: 0;border-bottom-left-radius: 0;border-color:#017572;}.form-signin input[type="password"] {margin-bottom: 10px;border-top-left-radius: 0;border-top-right-radius: 0;border-color:#017572;}h2{text-align: center;color: #017572;}</style></head><body><h2>Enter Username and Password</h2><div class = "container form-signin"><?php$msg = '';if (isset($_POST['login']) && !empty($_POST['username']) && !empty($_POST['password'])) {if ($_POST['username'] == 'administhebest' && md5($_POST['password']) == 'e6e061838856bf47e1de730719fb2609') {$_SESSION['valid'] = true;$_SESSION['timeout'] = time();$_SESSION['username'] = 'administhebest';echo "You have entered valid use name and password <br />";$flag = "Here is the <a style='color:FF0000;' href='/flagmeout.php'>Flag</a>";echo $flag;}else {$msg = 'Maybe Later';}}?></div> <!-- W00t/W00t --><div class = "container"><form class = "form-signin" role = "form"action = "<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method = "post"><h4 class = "form-signin-heading"><?php echo $msg; ?></h4><input type = "text" class = "form-control"name = "username"required autofocus></br><input type = "password" class = "form-control"name = "password" required><button class = "btn btn-lg btn-primary btn-block" type = "submit"name = "login">Login</button></form>Click here to clean <a href = "adminlog.php" tite = "Logout">Session.</div></body>
</html>

从源码中发现用户名:administhebest,密码MD5值:e6e061838856bf47e1de730719fb2609,解密后为:admin@123
登录之后,如图:

点击Flag之后跳转到flagmeout.php文件,但显示404,访问xxe/ flagmeout.php后页面空白,查看源码:

读取flagmeout.php文件如图:

Base64解码后如下:

<?php
$flag = "<!-- the flag in (JQZFMMCZPE4HKWTNPBUFU6JVO5QUQQJ5) -->";
echo $flag;
?>

读取xxe.php内容,然后Base解码,如下:

<?php
libxml_disable_entity_loader (false);
$xmlfile = file_get_contents('php://input');
$dom = new DOMDocument();
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
$info = simplexml_import_dom($dom);
$name = $info->name;
$password = $info->password;echo "Sorry, this $name not available!";
?>

由于靶机没有开始ssh服务,因此不考虑读取ssh私钥文件,探测内网端口无果,通过搜索后发现该靶机无法getshell,需要解密flag。
通过Base32解码再Base64解码flagmeout.php文件返回的信息后为:/etc/.flag.php,读取该文件内容,如图:

在线运行后报错信息中不包含flag,需要自行搭建环境运行。

本文标签: VulnHub