DSInternals.SAM 6.3.0

Prefix Reserved
dotnet add package DSInternals.SAM --version 6.3.0
                    
NuGet\Install-Package DSInternals.SAM -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.SAM" Version="6.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DSInternals.SAM" Version="6.3.0" />
                    
Directory.Packages.props
<PackageReference Include="DSInternals.SAM" />
                    
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.SAM --version 6.3.0
                    
#r "nuget: DSInternals.SAM, 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.SAM@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.SAM&version=6.3.0
                    
Install as a Cake Addin
#tool nuget:?package=DSInternals.SAM&version=6.3.0
                    
Install as a Cake Tool

DSInternals SAM Library

Introduction

The DSInternals.SAM package implements clients for the Security Account Manager Remote Protocol (MS-SAMR) and Local Security Authority Remote Protocol (MS-LSAD/LSARPC). It enables remote manipulation of user accounts and LSA policies on Windows systems.

Key Features

  • Password Hash Injection: Set NT/LM password hashes directly on accounts
  • Account Management: Query and modify user account properties
  • LSA Policy Access: Read and modify Local Security Authority policies
  • DPAPI Backup Key Retrieval: Extract domain DPAPI backup keys via LSARPC

Usage Examples

Connecting to a SAM Server

using DSInternals.SAM;

string serverName = "dc01.contoso.com";

// Connect to the SAM server
using var samServer = new SamServer(serverName);

// List available domains
string[] domains = samServer.EnumerateDomains();

foreach (string domain in domains)
{
    Console.WriteLine($"Domain: {domain}");
}

Setting a Password Hash

using DSInternals.SAM;

string serverName = "dc01.contoso.com";
string domainName = "CONTOSO";
string userName = "testuser";

// NT hash to set (32 hex characters = 16 bytes)
byte[] ntHash = Convert.FromHexString("A4F49C406510BDCAB6824EE7C30FD852");

using var samServer = new SamServer(serverName);
using var domain = samServer.OpenDomain(domainName);
using var user = domain.OpenUser(userName);

// Set the NT hash directly
user.SetPasswordHash(ntHash);

Console.WriteLine($"Password hash set successfully for {userName}");

Connecting with Alternate Credentials

using DSInternals.SAM;
using System.Net;

string serverName = "dc01.contoso.com";

var credential = new NetworkCredential(
    userName: "admin",
    password: "P@ssw0rd",
    domain: "CONTOSO"
);

using var samServer = new SamServer(serverName, SamServerAccessMask.MaximumAllowed, credential);

// Now perform SAM operations...

Retrieving LSA Backup Key

using DSInternals.SAM;

string serverName = "dc01.contoso.com";

// Get the DPAPI backup key via LSARPC
var backupKey = LsaPolicy.GetDPAPIBackupKey(serverName);
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net9.0-windows7.0 is compatible.  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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.3.0 124 2/8/2026
6.1.0 1,638 8/17/2025
6.0.0 215 8/14/2025
5.3.0 347 4/11/2025
5.2.0 329 4/9/2025
5.0.0 258 3/3/2025
4.14.0 810 4/13/2024
4.13.0 420 12/20/2023
4.12.0 264 10/6/2023
4.8.0 2,221 12/6/2022
4.5.0 2,336 10/13/2021
4.3.0 1,703 4/2/2020
4.2.0 780 3/18/2020
4.0.0 814 12/4/2019
3.2.0 1,059 1/3/2019
3.1.0 1,068 12/29/2018
3.0.0 1,066 9/29/2018
2.21.2 2,892 4/19/2017
2.21.0 1,346 3/25/2017
2.20.0 1,810 11/15/2016
Loading failed

- Updated assembly dependencies.