hi,欢迎访问本站!
当前位置: 首页学习笔记正文

vulnhub——XXE练习

用户投稿 学习笔记 20阅读

今天写一个关于vulnhub上的关于XXE漏洞利用的一个靶场练习

0x01 概述:

XXE(XML External Entity)是指xml外部实体攻击漏洞。XML外部实体攻击是针对解析XML输入的应用程序的一种攻击。当包含对外部实体的引用的XML输入被弱配置XML解析器处理时,就会发生这种攻击。这种攻击通过构造恶意内容,可导致读取任意文件、执行系统命令、探测内网端口、攻击内网网站等危害。

首先肯定得先下载啊,这里我就不多说了,自己到vulnhub官网下载即可(百度搜官网),然后进去后搜索XXE,下载第一个。解压,安装,靶场布置完成。

0x02

首先我们发现,靶机开启以后是要登录,但是本题并没有给我们登录的账号和密码,所以,别想着去登录了(哈哈哈),那怎么办? 你可能会有疑问,我连靶场IP地址都不知道! 那就扫呗。。。 所以第一步,nmap扫描所在网段,我扫描结果如下: 首先有4个IP地址,你不可能一眼就看出来,去找开放80端口的主机,因为XXE要通过网站利用,我找到了192.168.1.72,试着登录一下,结果如下: 所以,到这里,我们就锁定了目标,接下来就是要利用XXE了。

0x03

接下来就要从网站入手了,首先扫描探针目录。

有猫腻!试着去查看一下相关目录,看有没有新的发现 这个没有,下一个。 这个有东西~~~,你可能又有疑问,那接下来做什么呢?你看看这个网页有什么东西?能够提交数据啊,那账号密码不是输入然后提交吗?所以啊,你接下来抓包分析一下,看它提交的数据有什么特点。burpsuite上场。 你瞧瞧这是什么?这就是提示信息啊,不用多说,直接xxe代码利用,这里代码我不多解释,如果想了解,去网上搜XXE漏洞利用,好好看一下原理,我这里主要复现靶场夺取flag的思路和过程。 下面这个图是我改完之后的图。 接下来base64解码。得到下面的代码内容:

<?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>

这句话就是告诉你,flag在这里,哪里?这个目录下面去找找。好,那我们就去这个目录看看。 果然!base64解码,别我怎么知道base64解码,一般像这种有大小写的加密后的很多都是base64加密,做多了就有经验了。 它说,flag在这里,这啥啊?你会猜是不是又是base64加密了,我告诉你,不是,base64加密通常是都大写字母和小写字母,而这个里面只有大写字母,所以不是base64,那是什么呢?是base32,所以这里我们需要先将base32转换为base64,然后再解密base64,可得到我们能读懂的代码。

原来在这里,直接访问,看看有什么惊喜没有

接下来继续解码

$_[]++;$_[]=$_._;$_____=$_[(++$__[])][(++$__[])+(++$__[])+(++$__[])];$_=$_[$_[+_]];$___=$__=$_[++$__[]];$____=$_=$_[+_];$_++;$_++;$_++;$_=$____.++$___.$___.++$_.$__.++$___;$__=$_;$_=$_____;$_++;$_++;$_++;$_++;$_++;$_++;$_++;$_++;$_++;$_++;$___=+_;$___.=$__;$___=++$_^$___[+_];$À=+_;$Á=$Â=$Ã=$Ä=$Æ=$È=$É=$Ê=$Ë=++$Á[];$Â++;$Ã++;$Ã++;$Ä++;$Ä++;$Ä++;$Æ++;$Æ++;$Æ++;$Æ++;$È++;$È++;$È++;$È++;$È++;$É++;$É++;$É++;$É++;$É++;$É++;$Ê++;$Ê++;$Ê++;$Ê++;$Ê++;$Ê++;$Ê++;$Ë++;$Ë++;$Ë++;$Ë++;$Ë++;$Ë++;$Ë++;$__('$_="'.$___.$Á.$Â.$Ã.$___.$Á.$À.$Á.$___.$Á.$À.$È.$___.$Á.$À.$Ã.$___.$Á.$Â.$Ã.$___.$Á.$Â.$À.$___.$Á.$É.$Ã.$___.$Á.$É.$À.$___.$Á.$É.$À.$___.$Á.$Ä.$Æ.$___.$Á.$Ã.$É.$___.$Á.$Æ.$Á.$___.$Á.$È.$Ã.$___.$Á.$Ã.$É.$___.$Á.$È.$Ã.$___.$Á.$Æ.$É.$___.$Á.$Ã.$É.$___.$Á.$Ä.$Æ.$___.$Á.$Ä.$Á.$___.$Á.$È.$Ã.$___.$Á.$É.$Á.$___.$Á.$É.$Æ.'"');$__($_);

这啥东西?其实这是PHP代码,接下来网上找个php在线工具,运行一下,看看有什么惊喜没。 结果如下:

PHP Notice: Undefined variable: _ in /box/main.php on line 2PHP Notice: Use of undefined constant _ - assumed '_' in /box/main.php on line 2PHP Notice: Array to string conversion in /box/main.php on line 2PHP Notice: Undefined variable: __ in /box/main.php on line 2PHP Notice: Use of undefined constant _ - assumed '_' in /box/main.php on line 2PHP Notice: Use of undefined constant _ - assumed '_' in /box/main.php on line 2PHP Notice: Use of undefined constant _ - assumed '_' in /box/main.php on line 2PHP Notice: Use of undefined constant _ - assumed '_' in /box/main.php on line 2PHP Notice: Use of undefined constant _ - assumed '_' in /box/main.php on line 2PHP Notice: Undefined variable: Á in /box/main.php on line 2PHP Parse error: syntax error, unexpected '{', expecting ';' in /box/main.php(2) : assert code on line 1PHP Catchable fatal error: assert(): Failure evaluating code: SAFCSP{xxe_is_so_easy} in /box/main.php on line 2

箭头标的地方就是flag 这个靶场从开始到发现flag就是这么多。

总结

总结一下这个靶场的整个过程

1:扫描端口,发现主机 2:扫描探针目录 3:burpsuite抓包分析 4:加密解密的对抗 5:跟着作者的提示,一步步走
标签:
声明:无特别说明,转载请标明本文来源!
发布评论
正文 取消