DSInternals Replication implements a client for the Active Directory Replication Service Remote Protocol (DRS-R). It can be used to remotely extract password hashes from domain controllers.
$ dotnet add package DSInternals.ReplicationThe DSInternals.Replication package implements a client for the Active Directory Replication Service Remote Protocol (MS-DRSR). This is commonly known as DCSync and allows you to remotely extract password hashes and other sensitive data from domain controllers.
using DSInternals.Replication;
using System.Net;
string domainController = "dc01.contoso.com";
// Connect using current credentials
using var client = new DirectoryReplicationClient(domainController);
Console.WriteLine($"Connected to: {client.DomainNamingContext}");
Console.WriteLine($"NetBIOS Domain: {client.NetBIOSDomainName}");
using DSInternals.Replication;
using DSInternals.Common.Data;
string domainController = "dc01.contoso.com";
using var client = new DirectoryReplicationClient(domainController);
// Replicate a specific account by distinguished name
string userDn = "CN=Administrator,CN=Users,DC=contoso,DC=com";
DSAccount account = client.GetAccount(userDn);
Console.WriteLine($"Account: {account.SamAccountName}");
Console.WriteLine($"SID: {account.Sid}");
if (account.NTHash != null)
{
string ntHash = BitConverter.ToString(account.NTHash).Replace("-", "");
Console.WriteLine($"NT Hash: {ntHash}");
}
using DSInternals.Replication;
using DSInternals.Common.Data;
string domainController = "dc01.contoso.com";
using var client = new DirectoryReplicationClient(domainController);
// Enumerate all accounts in the domain
foreach (DSAccount account in client.GetAccounts())
{
Console.WriteLine($"Account: {account.SamAccountName}");
if (account.NTHash != null)
{
string ntHash = BitConverter.ToString(account.NTHash).Replace("-", "");
Console.WriteLine($" NT Hash: {ntHash}");
}
}
using DSInternals.Replication;
using System.Net;
string domainController = "dc01.contoso.com";
// Create credentials
var credential = new NetworkCredential(
userName: "admin",
password: "P@ssw0rd",
domain: "CONTOSO"
);
using var client = new DirectoryReplicationClient(domainController, credential);
// Now perform replication operations...
using DSInternals.Replication;
string domainController = "dc01.contoso.com";
using var client = new DirectoryReplicationClient(domainController);
// Get the domain DPAPI backup key
var backupKey = client.GetDPAPIBackupKey();
Console.WriteLine($"Key ID: {backupKey.KeyId}");
// Use the key to decrypt DPAPI-protected data
This library performs operations that require elevated privileges: