mirror of
https://github.com/sresarehumantoo/wsmancer.git
synced 2026-11-24 05:49:16 +01:00
2f1dbda6e1
An interactive WinRM shell for offensive Windows work, speaking the
PowerShell Remoting Protocol end to end. Command results come back as typed
objects (structured JSON on demand), and it authenticates against stock,
locked-down listeners: NTLM and Kerberos with WinRM message sealing that is
integrity-checked in both directions, pass-the-hash, and certificate auth.
Highlights:
- -o json structured output; -x one-shot and -x - batch/session mode over
one connection, built for automation as well as a prompt
- context-aware Tab completion (local/remote paths, the target's own cmdlet
names, and parameters/values via the target's TabExpansion2), ghost text
- a session that recovers a dropped connection, and detects a shell the
target has forgotten
- the full evil-winrm post-ex set: -s scripts + menu, services,
invoke-binary, donut-loader, bypass-4msi
- SOCKS5 pivoting, TLS verification (--ca-cert / --accept-fingerprint /
--insecure), client certs / mutual TLS
Every claim is live-verified against a real WinRM target; see
docs/verification.md. A Go port of Hackplayers/evil-winrm (LGPL-3.0), with all
20 of its flags and every post-ex command; PSRP transport builds on a patched
smnsjas/go-psrp (MIT), vendored under go-psrp-fork/.
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
package shell
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/sresarehumantoo/wsmancer/internal/cli"
|
|
)
|
|
|
|
func TestIsScriptLoad(t *testing.T) {
|
|
dir := t.TempDir()
|
|
for _, n := range []string{"Recon.ps1", "Upper.PS1"} {
|
|
if err := os.WriteFile(filepath.Join(dir, n), []byte("function Get-Foo{}"), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
sh := &Shell{o: &cli.Options{Scripts: dir}}
|
|
cases := []struct {
|
|
line string
|
|
want bool
|
|
}{
|
|
{"Recon.ps1", true}, // bare name in the -s dir
|
|
{"Upper.PS1", true}, // .PS1 extension accepted (EqualFold)
|
|
{"Missing.ps1", false}, // not present in the dir
|
|
{"Recon.ps1 -Verbose", false}, // extra args => a command, not a load
|
|
{`.\Recon.ps1`, false}, // path-qualified => run on the target
|
|
{`C:\tools\x.ps1`, false}, // remote path
|
|
{"whoami", false}, // not a .ps1
|
|
}
|
|
for _, c := range cases {
|
|
if _, ok := sh.isScriptLoad(c.line); ok != c.want {
|
|
t.Errorf("isScriptLoad(%q) = %v, want %v", c.line, ok, c.want)
|
|
}
|
|
}
|
|
|
|
// With no -s directory, nothing is ever a script load.
|
|
none := &Shell{o: &cli.Options{}}
|
|
if _, ok := none.isScriptLoad("Recon.ps1"); ok {
|
|
t.Error("isScriptLoad should be false when -s is unset")
|
|
}
|
|
}
|
|
|
|
func TestScriptNames(t *testing.T) {
|
|
dir := t.TempDir()
|
|
for _, n := range []string{"A.ps1", "b.PS1", "notes.txt"} {
|
|
if err := os.WriteFile(filepath.Join(dir, n), nil, 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
sh := &Shell{o: &cli.Options{Scripts: dir}}
|
|
got := sh.scriptNames()
|
|
if len(got) != 2 {
|
|
t.Errorf("scriptNames() = %v, want the two .ps1 files", got)
|
|
}
|
|
}
|