本文最后更新于:2023年8月25日 下午
[TOC]
[vulnhub]XXE(XXE漏洞)
环境安装
首先在 vulnhub 下载文件:

将其解压为ovf
格式:

使用vmware
打开,新建一个虚拟机,然后开机,环境就搭好了
信息收集
由于我们打开了虚拟机,所以我们首先需要知道其ip
首先使用ifconfig
命令查看本机的ip所处的网段:
查询到本机ip:192.168.56.128
,为C段
网络,前24位为网络号
知道了网络号之后,我们可以使用nmap
工具扫描查询目标靶机ip开放情况
1 2
| nmap -sP 192.168.56.1/24
|
主机192.168.56.134
存活
接下来我们需要查看ip192.168.56.134
的端口开放情况:
1 2
| nmap -p 1-65535 192.168.56.134
|

端口80
、5355
开放,于是我们访问一下:

好像没什么东西,接下来的思路是使用目录扫描,扫描出来有哪些目录
这里可以使用dirb
命令
dirb是一个常用的命令行工具,用于在Web服务器上执行目录和文件扫描。它主要用于发现隐藏的目录、文件和其他资源
1
| dirb http://192.168.56.134
|
扫描出一个robots.txt
,访问:
访问/xxe/
:

是一个登录界面,我们再访问一下:/xxe/admin.php
:

是管理员的登录界面,我们不能简单的爆破,没效果这里
解题步骤
我们结合题目为XXE
,猜测是xxe漏洞,所以在/xxe/xxe.php
表单提交时抓包:

确实为XML
的格式,于是构造简单XXE读取文件的格式,读取/etc/passwd
:

成功读取,存在XXE
漏洞,于是我们读取一下:admin.php
:

base64解码:
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| <?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: } .form-signin { max-width: 330px; padding: 15px; margin: 0 auto; color: } .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: } .form-signin input[type="password"] { margin-bottom: 10px; border-top-left-radius: 0; border-top-right-radius: 0; border-color: } h2{ text-align: center; color: } </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>
|
可以看到:username=administhebest
& 密码的md5为:e6e061838856bf47e1de730719fb2609
密码md5解密一下:admin@123
登录admin.php
:
点击flag
啥也没有,再用xxe读取一下flagmeout.php

base64解密:
1 2 3 4
| <?php $flag = "<!-- the flag in (JQZFMMCZPE4HKWTNPBUFU6JVO5QUQQJ5) -->"; echo $flag; ?>
|
查看/etc/.flag.php
的内容:

解密:

看着像php自增的代码,我们使用在线网站运行一下得到flag

总结
其实这个xxe的靶场也不难,就一下常规步骤,之前没有写wp,以后要多总结,多写wp才能更好的复习