DSInternals.SAM
6.5.0
Prefix Reserved
dotnet add package DSInternals.SAM --version 6.5.0
NuGet\Install-Package DSInternals.SAM -Version 6.5.0
<PackageReference Include="DSInternals.SAM" Version="6.5.0" />
<PackageVersion Include="DSInternals.SAM" Version="6.5.0" />
<PackageReference Include="DSInternals.SAM" />
paket add DSInternals.SAM --version 6.5.0
#r "nuget: DSInternals.SAM, 6.5.0"
#:package DSInternals.SAM@6.5.0
#addin nuget:?package=DSInternals.SAM&version=6.5.0
#tool nuget:?package=DSInternals.SAM&version=6.5.0
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 local and Active Directory 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 | Versions 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. |
-
.NETFramework 4.8
- DSInternals.Common (>= 6.5.0)
-
net8.0-windows7.0
- DSInternals.Common (>= 6.5.0)
-
net9.0-windows7.0
- DSInternals.Common (>= 6.5.0)
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.5.0 | 115 | 5/16/2026 |
| 6.4.0 | 453 | 3/28/2026 |
| 6.3.0 | 379 | 2/8/2026 |
| 6.1.0 | 1,721 | 8/17/2025 |
| 6.0.0 | 241 | 8/14/2025 |
| 5.3.0 | 369 | 4/11/2025 |
| 5.2.0 | 350 | 4/9/2025 |
| 5.0.0 | 282 | 3/3/2025 |
| 4.14.0 | 833 | 4/13/2024 |
| 4.13.0 | 440 | 12/20/2023 |
| 4.12.0 | 286 | 10/6/2023 |
| 4.8.0 | 2,239 | 12/6/2022 |
| 4.5.0 | 2,361 | 10/13/2021 |
| 4.3.0 | 1,811 | 4/2/2020 |
| 4.2.0 | 802 | 3/18/2020 |
| 4.0.0 | 835 | 12/4/2019 |
| 3.2.0 | 1,079 | 1/3/2019 |
| 3.1.0 | 1,090 | 12/29/2018 |
| 3.0.0 | 1,092 | 9/29/2018 |
| 2.21.2 | 2,913 | 4/19/2017 |
- Added optional named pipe (RPC/NP) transport support.
- Improved MS-SAMR authentication fallback for localhost and missing SPN scenarios.
- Fixed a missing throw in SafeUnicodeSecureStringPointer that silently ignored invalid password byte arrays.