Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AddUser-SAMR

Create local administrators using the SAMR API, operating at a lower level than net.exe, PowerShell's New-LocalUser or NetUserAdd API.

It requires Administrator privileges and if the user exists, it gets added to the group but the password is not updated.

There are 7 implementations in this repo (C#, Python, Rust, Crystal, Deno, Golang and Nim), but there are public versions in other languages such as C++ by @M0nster3 or BOF file by @AgeloVito.

This code serves as complement to this blog post about different techniques to create local accounts.



Usage

The arguments are:

  • -u, --username - Username to create (required)

  • -p, --password - Password for the user (required)

  • -g, --group - Group name (default: "Administrators")

  • -v, --verbose - Enable verbose

  • -h, --help - Show help message

# Basic usage
adduser.exe -u <username> -p <password>

# Specify group
adduser.exe -u <username> -p <password> -g <group>

# Verbose output
adduser.exe -u testuser -p MyPass123 -g Administrators -v

img1



SAMR functions

The tool uses the following SAMR protocol calls:



Compilation (for Windows)

C#

Compile using Visual Studio or msbuild.

Crystal

cd Crystal
crystal build adduser.cr --release
.\adduser.exe -u testuser -p MyPass123 -v

Python

You can use the Python script:

cd Python
python adduser.py -u testuser -p MyPass123 -v

Or create a stand-alone binary with:

cd Python
pip install pyinstaller
pyinstaller -F adduser.py
.\dist\adduser.exe -u testuser -p MyPass123 -v

Deno

cd Deno
deno run --allow-ffi adduser.js -u testuser -p MyPass123 -v

Or run it directly from the repo without cloning:

deno run --allow-ffi https://raw.githubusercontent.com/ricardojoserf/AddUser-SAMR/main/Deno/adduser.js -u testuser -p MyPass123 -v

Rust

cd Rust && mkdir target
cargo build --release
.\target\release\adduser.exe -u testuser -p MyPass123 -v

Golang

cd Golang
go build -o adduser.exe -ldflags="-s -w" adduser.go
.\adduser.exe -u testuser -p MyPass123 -v

Nim

cd Nim
nim c -d:release adduser.nim
.\adduser.exe -u testuser -p MyPass123 -v

About

Create local administrators in Windows using the SAMR API. In C#, Crystal, Python, Rust, Golang, Nim and Deno (Javascript)

Topics

Resources

Stars

96 stars

Watchers

0 watching

Forks

Contributors

Languages