首页
社区
课程
招聘
[原创]HTB-ENST靶机记录
发表于: 2023-1-5 10:37 1958

[原创]HTB-ENST靶机记录

2023-1-5 10:37
1958

获得了 445 和 4386 的未知服务。

查看 445 端口共享了什么服务。

image

user 和 data 是可以访问的。

访问 user,发现不能执行任何命令

TempUser C.Smith L.Frost R.Thompson Administrator 获得了这么几个用户

但是我无法访问到任何资源文件

image

访问 data

image

对目录逐一浏览之后,发现有目录可以访问了。image

接下来逐级访问

image

这里发现一个 txt,下载的命令需要用“”包起来,要不然会如上图所示找不到命令。

image

image

这是一份邮件,意味着此账户和密码可以访问 Tempuser 的共享服务了。

此账户可以访问 data 和 secure 还有 users。

但是 users 依然没有权限访问,继续访问 data,发现比较之前多了一个 IT 文件夹可以访问了。

image

image

浏览到 DLink 目录没有任何的配置文件

在 notepad 文件夹里面发现了配置文件,导出。

在 RU Scanner 目录也发现了配置文件,导出。

image

RU_config.xml

获得了一个用户 c.smith 的密码,但是密文不知道是什么类型,也解密不了。

image

另外一份 notepad 的配置文件中给出了两个地址。

image

其中一个指向了 secure 目录。重新回到 SMB 去读一下这个共享。

刚开始就是显示这样权限不足,结果根据文件的指引我能访问 carl 目录。

image

刚开始看题目包含了 C# 的标签,凭感觉应该是要进到 VB 目录去。

image

在 RU 的目录发现了刚开始那个 RUscan 目录和源代码,我们之前已经获得了他的配置文件。

现在需要下载回来他的所有文件,smbclient 的递归下载是这样的:

image

导入 VS 丢丢之后,在 Module1 可以看到是加载了配置文件然后引用 utils 中的 DecryptString 函数进行加解密。

image

其中 utils 的代码如下:

先不管这解密代码。当我编译该 EXE 出来的时候,发现执行文件会报错。

image

image

用 CMD 后得到了一个异常报错,需要将配置文件放到此目录然后再去执行

image

添加后执行不会回显任何东西,寄了。

为什么不输出结果啊,仔细一看原来是缺少了打印代码。

那么最终代码就变成了:

结果也输出了:

image

获得了一个新的密码 xRxRxPANCAK3SxRxRx

但是还有另外一种简单的思路,就是直接从 EXE 入手,在了解完代码之后,知道他只是没有打印这个输出,最终的结果肯定要停留在系统的某个地方。

既然是 C# 的代码,直接用 dnspy 反编译 exe 即可。

image

思路就是,从这里开始调用解密算法然后输出结果,那么我们可以在

这一行给他打上断点,让他执行到这里然后断开,然后查看寄存器。

F9 打下断点之后,开始执行程序。

image

断点之后,可以看到在内存中的 password 参数就是配置文件中的密码,此处还没有进行解密,需要让他再执行一步。

单步执行 F11 可以看到解密是怎么执行的,逐过程 F10 就是单步执行,就会看到解密完成的密码存在了内存里面。

image

也可以获得密码

接上一步获得了 C.smith 的密码之后 使用 SMB 去连接

直接去访问自己名字文件下面的文件,获得了第一个 flag。

image

我继续搜索这台机器的文件,发现了一个 txt 文件

image

但是很奇怪的是 0 字节。

而另外一份配置文件是一个导出的备份配置。

image

4386 端口。。。。刚开始 nmap 扫描的不就是 4386 端口吗,猜想这里的信息应该和另外一个端口有关。

image

同时,另外一个目录存在一个 HqkLdap.exe。

用 Windows 打开 Hqkldap.exe 试试。

获得了两个提示。

1.命令行参数的数量无效

2.指定的配置文件不存在

说明运行这个程序 需要带配置文件

我想到用刚刚那个 0 字节的文件尝试一下

image

第三个报错,请确保安装了可选的数据库导入模块。

发现也是 C# 编译的,丢入 dnspy 看看

image

反编译之后,发现其中有如下提示:

除了之前提到的几个问题之外,还要有一个 HqkDbImport.exe

但是目前缺少配置文件和这个 exe 文件。

在我思考为什么 txt 是 0 字节的文件时候,搜索隐写的时候发现了一种叫 NTFS 数据流隐写的技术。

参考文章:https://joner11234.github.io/article/85357d8d.html

参考文章:https://www.cnblogs.com/linuxsec/articles/10423138.html

当我想到这里的的时候,用 allinfo 列出那个空的文件后,奇迹发生了。

image

获得了一个带隐写的流文件。按照文章的说法,带上 password 去访问。

带上密码再去下载文件

get "Debug Mode Password.txt:Password"

image

获得了最后一个密码,WBQ201953D8w。

那么,现在有密码了,有 EXE 了,只差配置文件了,别忘了之前的 4386 端口。

使用 telnet 连接一下

image

这里执行命令,输入你获得的调试密码。

image

然后 help 查看帮助

setdir 到上级目录后会发现刚开始在 SMB 里面发现的 config。

最终找到了该配置文件

image

获得了配置文件后,回到我们刚开始做 exe 分析那里。

要素都齐活了

1.配置文件

2.主 EXE

3.HqkDbImport.exe(缺少)

但是我还是没有找到 HqkDbImport.exe 在哪里,没有就给他编一个看看行不行,用 TXT 改一个后缀用。

image

image

看代码

此处是解密流程中分别对应的参数。

image

那么断点应该打在解密完成后的下一步,即 Ldap ldap = new Ldap();

image

F10 单步走

走到 username,解密结果为 administrator

image

image

HqkLdap.LdapSearchSettings.Password.get 返回 "XtH4nkS4Pl4y1nGX" string

获得密码

图片描述

获得域名。

直接使用 psexec 去连接就行。

└─# nmap -sV 10.129.157.43 -p 1-65535
Starting Nmap 7.93 ( https://nmap.org ) at 2022-12-20 22:27 EST
Nmap scan report for 10.129.157.43
Host is up (0.27s latency).
Not shown: 65533 filtered tcp ports (no-response)
PORT     STATE SERVICE       VERSION
445/tcp  open  microsoft-ds?
4386/tcp open  unknown
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
└─# nmap -sV 10.129.157.43 -p 1-65535
Starting Nmap 7.93 ( https://nmap.org ) at 2022-12-20 22:27 EST
Nmap scan report for 10.129.157.43
Host is up (0.27s latency).
Not shown: 65533 filtered tcp ports (no-response)
PORT     STATE SERVICE       VERSION
445/tcp  open  microsoft-ds?
4386/tcp open  unknown
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
# smbmap -H 10.129.157.43 -u null
[+] Guest session       IP: 10.129.157.43:445   Name: 10.129.157.43                                  
        Disk                                                    Permissions Comment
        ----                                                    ----------- -------
        ADMIN$                                                  NO ACCESS   Remote Admin
        C$                                                      NO ACCESS   Default share
        Data                                                    READ ONLY
        IPC$                                                    NO ACCESS   Remote IPC
        Secure$                                                 NO ACCESS
        Users                                                   READ ONLY
# smbmap -H 10.129.157.43 -u null
[+] Guest session       IP: 10.129.157.43:445   Name: 10.129.157.43                                  
        Disk                                                    Permissions Comment
        ----                                                    ----------- -------
        ADMIN$                                                  NO ACCESS   Remote Admin
        C$                                                      NO ACCESS   Default share
        Data                                                    READ ONLY
        IPC$                                                    NO ACCESS   Remote IPC
        Secure$                                                 NO ACCESS
        Users                                                   READ ONLY
 
 
└─# smbclient -N //10.129.157.43/users
Try "help" to get a list of possible commands.
smb: \> dir
  .                                   D        0  Sat Jan 25 18:04:21 2020
  ..                                  D        0  Sat Jan 25 18:04:21 2020
  Administrator                       D        0  Fri Aug  9 11:08:23 2019
  C.Smith                             D        0  Sun Jan 26 02:21:44 2020
  L.Frost                             D        0  Thu Aug  8 13:03:01 2019
  R.Thompson                          D        0  Thu Aug  8 13:02:50 2019
  TempUser                            D        0  Wed Aug  7 18:55:56 2019
└─# smbclient -N //10.129.157.43/users
Try "help" to get a list of possible commands.
smb: \> dir
  .                                   D        0  Sat Jan 25 18:04:21 2020
  ..                                  D        0  Sat Jan 25 18:04:21 2020
  Administrator                       D        0  Fri Aug  9 11:08:23 2019
  C.Smith                             D        0  Sun Jan 26 02:21:44 2020
  L.Frost                             D        0  Thu Aug  8 13:03:01 2019
  R.Thompson                          D        0  Thu Aug  8 13:02:50 2019
  TempUser                            D        0  Wed Aug  7 18:55:56 2019
 
 
 
 
 
└─# smbclient -N //10.129.157.43/data
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Wed Aug  7 18:53:46 2019
  ..                                  D        0  Wed Aug  7 18:53:46 2019
  IT                                  D        0  Wed Aug  7 18:58:07 2019
  Production                          D        0  Mon Aug  5 17:53:38 2019
  Reports                             D        0  Mon Aug  5 17:53:44 2019
  Shared                              D        0  Wed Aug  7 15:07:51 2019
 
                5242623 blocks of size 4096. 1840690 blocks available
smb: \>
└─# smbclient -N //10.129.157.43/data
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Wed Aug  7 18:53:46 2019
  ..                                  D        0  Wed Aug  7 18:53:46 2019
  IT                                  D        0  Wed Aug  7 18:58:07 2019
  Production                          D        0  Mon Aug  5 17:53:38 2019
  Reports                             D        0  Mon Aug  5 17:53:44 2019
  Shared                              D        0  Wed Aug  7 15:07:51 2019
 
                5242623 blocks of size 4096. 1840690 blocks available
smb: \>
 
 
 
 
 
 
 
 
 
# smbmap -H 10.129.157.43  -u TempUser -p welcome2019
[+] IP: 10.129.157.43:445       Name: 10.129.157.43                                  
        Disk                                                    Permissions Comment
        ----                                                    ----------- -------
        ADMIN$                                                  NO ACCESS   Remote Admin
        C$                                                      NO ACCESS   Default share
        Data                                                    READ ONLY
        IPC$                                                    NO ACCESS   Remote IPC
        Secure$                                                 READ ONLY
        Users                                                   READ ONLY
# smbmap -H 10.129.157.43  -u TempUser -p welcome2019
[+] IP: 10.129.157.43:445       Name: 10.129.157.43                                  
        Disk                                                    Permissions Comment
        ----                                                    ----------- -------
        ADMIN$                                                  NO ACCESS   Remote Admin
        C$                                                      NO ACCESS   Default share
        Data                                                    READ ONLY
        IPC$                                                    NO ACCESS   Remote IPC
        Secure$                                                 READ ONLY
        Users                                                   READ ONLY
 
 
 
 
 
 
 
 
 
<Username>c.smith</Username>
<Password>fTEzAfYDoz1YzkqhQkH6GQFYKp1XY5hm7bjOP86yYxE=</Password>
</ConfigFile>
<Username>c.smith</Username>
<Password>fTEzAfYDoz1YzkqhQkH6GQFYKp1XY5hm7bjOP86yYxE=</Password>
</ConfigFile>
 
 
 
 
 
└─# smbclient -U TempUser //10.129.157.43/Secure$
Password for [WORKGROUP\TempUser]:
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Wed Aug  7 19:08:12 2019
  ..                                  D        0  Wed Aug  7 19:08:12 2019
  Finance                             D        0  Wed Aug  7 15:40:13 2019
  HR                                  D        0  Wed Aug  7 19:08:11 2019
  IT                                  D        0  Thu Aug  8 06:59:25 2019
 
                5242623 blocks of size 4096. 1839742 blocks available
smb: \> cd IT
smb: \IT\> ls
NT_STATUS_ACCESS_DENIED listing \IT\*
smb: \IT\>
└─# smbclient -U TempUser //10.129.157.43/Secure$
Password for [WORKGROUP\TempUser]:
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Wed Aug  7 19:08:12 2019
  ..                                  D        0  Wed Aug  7 19:08:12 2019
  Finance                             D        0  Wed Aug  7 15:40:13 2019
  HR                                  D        0  Wed Aug  7 19:08:11 2019
  IT                                  D        0  Thu Aug  8 06:59:25 2019
 
                5242623 blocks of size 4096. 1839742 blocks available
smb: \> cd IT
smb: \IT\> ls
NT_STATUS_ACCESS_DENIED listing \IT\*
smb: \IT\>
 
 
 
 
 
 
 
 
 
 
 
 
 
Imports System.Text
Imports System.Security.Cryptography
Public Class Utils
 
    Public Shared Function GetLogFilePath() As String
        Return IO.Path.Combine(Environment.CurrentDirectory, "Log.txt")
    End Function
 
 
 
 
    Public Shared Function DecryptString(EncryptedString As String) As String
        If String.IsNullOrEmpty(EncryptedString) Then
            Return String.Empty
        Else
            Return Decrypt(EncryptedString, "N3st22", "88552299", 2, "464R5DFA5DL6LE28", 256)
        End If
    End Function
 
    Public Shared Function EncryptString(PlainString As String) As String
        If String.IsNullOrEmpty(PlainString) Then
            Return String.Empty
        Else
            Return Encrypt(PlainString, "N3st22", "88552299", 2, "464R5DFA5DL6LE28", 256)
        End If
    End Function
 
    Public Shared Function Encrypt(ByVal plainText As String, _
                                   ByVal passPhrase As String, _
                                   ByVal saltValue As String, _
                                    ByVal passwordIterations As Integer, _
                                   ByVal initVector As String, _
                                   ByVal keySize As Integer) _
                           As String
 
        Dim initVectorBytes As Byte() = Encoding.ASCII.GetBytes(initVector)
        Dim saltValueBytes As Byte() = Encoding.ASCII.GetBytes(saltValue)
        Dim plainTextBytes As Byte() = Encoding.ASCII.GetBytes(plainText)
        Dim password As New Rfc2898DeriveBytes(passPhrase, _
                                           saltValueBytes, _
                                           passwordIterations)
        Dim keyBytes As Byte() = password.GetBytes(CInt(keySize / 8))
        Dim symmetricKey As New AesCryptoServiceProvider
        symmetricKey.Mode = CipherMode.CBC
        Dim encryptor As ICryptoTransform = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes)
        Using memoryStream As New IO.MemoryStream()
            Using cryptoStream As New CryptoStream(memoryStream, _
                                            encryptor, _
                                            CryptoStreamMode.Write)
                cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length)
                cryptoStream.FlushFinalBlock()
                Dim cipherTextBytes As Byte() = memoryStream.ToArray()
                memoryStream.Close()
                cryptoStream.Close()
                Return Convert.ToBase64String(cipherTextBytes)
            End Using
        End Using
    End Function
 
    Public Shared Function Decrypt(ByVal cipherText As String, _
                                   ByVal passPhrase As String, _
                                   ByVal saltValue As String, _
                                    ByVal passwordIterations As Integer, _
                                   ByVal initVector As String, _
                                   ByVal keySize As Integer) _
                           As String
 
        Dim initVectorBytes As Byte()
        initVectorBytes = Encoding.ASCII.GetBytes(initVector)
 
        Dim saltValueBytes As Byte()
        saltValueBytes = Encoding.ASCII.GetBytes(saltValue)
 
        Dim cipherTextBytes As Byte()
        cipherTextBytes = Convert.FromBase64String(cipherText)
 
        Dim password As New Rfc2898DeriveBytes(passPhrase, _
                                           saltValueBytes, _
                                           passwordIterations)
 
        Dim keyBytes As Byte()
        keyBytes = password.GetBytes(CInt(keySize / 8))
 
        Dim symmetricKey As New AesCryptoServiceProvider
        symmetricKey.Mode = CipherMode.CBC
 
        Dim decryptor As ICryptoTransform
        decryptor = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes)
 
        Dim memoryStream As IO.MemoryStream
        memoryStream = New IO.MemoryStream(cipherTextBytes)
 
        Dim cryptoStream As CryptoStream
        cryptoStream = New CryptoStream(memoryStream, _
                                        decryptor, _
                                        CryptoStreamMode.Read)
 
        Dim plainTextBytes As Byte()
        ReDim plainTextBytes(cipherTextBytes.Length)
 
        Dim decryptedByteCount As Integer
        decryptedByteCount = cryptoStream.Read(plainTextBytes, _
                                               0, _
                                               plainTextBytes.Length)
 
        memoryStream.Close()
        cryptoStream.Close()
 
        Dim plainText As String
        plainText = Encoding.ASCII.GetString(plainTextBytes, _
                                            0, _
                                            decryptedByteCount)
 
        Return plainText
    End Function
 
 
 
 
 
 
End Class
Imports System.Text
Imports System.Security.Cryptography
Public Class Utils
 
    Public Shared Function GetLogFilePath() As String
        Return IO.Path.Combine(Environment.CurrentDirectory, "Log.txt")
    End Function
 
 
 
 
    Public Shared Function DecryptString(EncryptedString As String) As String
        If String.IsNullOrEmpty(EncryptedString) Then
            Return String.Empty
        Else
            Return Decrypt(EncryptedString, "N3st22", "88552299", 2, "464R5DFA5DL6LE28", 256)
        End If
    End Function
 
    Public Shared Function EncryptString(PlainString As String) As String
        If String.IsNullOrEmpty(PlainString) Then
            Return String.Empty
        Else
            Return Encrypt(PlainString, "N3st22", "88552299", 2, "464R5DFA5DL6LE28", 256)
        End If
    End Function
 
    Public Shared Function Encrypt(ByVal plainText As String, _
                                   ByVal passPhrase As String, _
                                   ByVal saltValue As String, _
                                    ByVal passwordIterations As Integer, _
                                   ByVal initVector As String, _
                                   ByVal keySize As Integer) _
                           As String
 

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

最后于 2023-1-5 10:45 被毅种循环编辑 ,原因: 缺少图片
收藏
免费 2
支持
分享
最新回复 (1)
游客
登录 | 注册 方可回帖
返回
//