DSInternals PowerShell模块提供了一些非常易于使用的cmdlets命令,这些命令都是立在该框之上的。其主要功能包括通过目录复制服务(DRS)远程协议对域控制器进行操纵和查询。
源代码: https://github.com/MichaelGrafnetter/DSInternals
该方法仅适用于windows用户,要提取一个域控制器中的哈希值,然后将这个哈希值赋值到另外一个域控制器中相同用户名下。
支持系统:
Windows Server 2012 R2
Windows Server 2008 R2
Windows 10 64-bit
Windows 8.1 64-bit
Windows 7 64-bit
软件版本:
- Windows PowerShell 3+
- .NET Framework 4.5+
(此为官方说明)
安装方法
1、PowerShell 5.0:
Install-Module DSInternals
2、PowerShell 3.0、4.0
解压压缩包
cd C:\test\DSInternals
Import-Module .\DSInternals
功能模块
1、在线操作活动目录数据库
Get-ADReplAccount:读取账户信息
Set-SamAccountPasswordHash:设置账户的NTHash和LMHash
Get-ADReplBackupKey:读取DPAPI backup keys
2、离线操作活动目录数据库
Get-ADDBAccount:从ntds.dit文件读取账户信息
Get-BootKey:从SYSTEM文件读取BootKey
Get-ADDBBackupKey::从ntds.dit文件读取DPAPI backup keys
Add-ADDBSidHistory:向ntds.dit文件添加SIDHistory信息
Set-ADDBPrimaryGroup:修改ntds.dit文件的primaryGroupId属性
Get-ADDBDomainController:从ntds.dit文件读取域控信息,包括domain name, domain SID, DC name and DC site.
Set-ADDBDomainController:向ntds.dit文件添加域控信息
Get-ADDBSchemaAttribute:从ntds.dit文件读取AD schema,包括数据表的列名
Remove-ADDBObject:从ntds.dit文件移除特定对象
3、 Hash计算
ConvertTo-NTHash:给定密码,计算NT hash
ConvertTo-LMHash:给定密码,计算LM hash
ConvertTo-OrgIdHash:给定密码,计算OrgId hash
4、补充
对于Get-ADDBAccount读取到的账户信息,可将其中包含的Hash值按如下格式导出:
HashcatNT:支持Hashcat的NT hash
HashcatLM:支持Hashcat的LM hash
JohnNT:支持John the Ripper的NT hash
JohnLM:支持John the Ripper的LM hash
Ophcrack:支持Ophcrack的NT hash、LM hash
以下脚本为单向从一个域控制器同步相同用户名的用户密码至另一个域控制器中。
#Create your credentials with these commands
$credential = Get-Credential;
$credential | Export-CliXml -Path ‘C:\Temp\cred.xml’;
#Configure your Source Domain configuration
$sourceDomainNetBIOS = ‘DomainA’;
$sourceDomainFQDN = ‘DomainA.com’;
$sourceDomainDN = ‘DC=DomainA,DC=com’;
$sourceDomainCredential = Import-CliXml -Path ‘C:\Temp\DomainA.xml’;
#Configure your Target Domain configuration
$targetDomainNetBIOS = ‘DomainB’;
$targetDomainFQDN = ‘DomainB.com’;
$targetDomainDN = ‘DC=DomainB,DC=com’;
$targetDomainCredential = Import-CliXml -Path ‘C:\Temp\DomainB.xml’;
$syncGroup = ‘Some Group’;
#Get Source Domain hashes
$hashes = Get-ADReplAccount -All -NamingContext $sourceDomainDN -Server $sourceDomainFQDN -Credential $sourceDomainCredential;
#The group of users to sync passwords for
$users = Get-ADGroupMember $syncGroup -server $targetDomainFQDN -Credential $targetDomainCredential;
#Loop through these users
foreach ($user in $users)
{
#Get the hash of the user in the hashes collection
$currentUserHash = KaTeX parse error: Expected '}', got 'EOF' at end of input: hashes | ? {_.saMAccountName -eq $user.SamAccountName};
#Convert hash to string
$NTHash = ([System.BitConverter]::ToString($currentUserHash.NTHash) -replace '-','').ToLower();
#Set target domain password to the source domain hash
Set-SamAccountPasswordHash -SamAccountName $user.SamAccountName -Domain $targetDomainNetBIOS -NTHash $NTHash -Server $targetDomainFQDN -Credential $targetDomainCredential;
}
DSInternals PowerShell模块提供了一种在Windows环境下,针对域控制器进行远程操纵和查询的方法。该模块支持WindowsServer2012R2及更高版本,可用于在线和离线操作活动目录数据库,例如获取账户信息、设置密码哈希、读取DPAPI备份密钥等。此外,它还提供了计算NTHash、LMHash和OrgIdHash的功能。通过提供的脚本示例,可以实现从一个域控制器同步指定用户组的密码到另一个域控制器。

1546

被折叠的 条评论
为什么被折叠?



