Pre-Requisite
Have an XP qube to begin with; I can write up a “simple” guide on this at some point in the future if anyone is interested. I have this working on Qubes OS 4.3.
Why
A Windows XP HVM can’t use Qubes Windows Tools, which never supported XP. That means there’s no qrexec agent, so qvm-run and the Ansible/Salt qubes connection can’t reach it. I wanted to run commands in XP from my management qube (mgmtvm) without clicking through its desktop, for scripted setup and checks.
Primarily, this was useful for trying things rapidly inside of XP, especially via Claude in a dedicated mgmtvm qube, without having to expose XP to the internet, and then documenting the results to repeat with offline scripts.
XP ships a telnet server, and that turns out to be enough. The trick is that only the XP qube’s netvm has a route to it, so every connection has to start from the netvm. mgmtvm reaches the netvm with qvm-run --pass-io.
mgmtvm xp-netvm (netvm of the XP qube) xp-hvm
<netvm-ip> <xp-ip>
qvm-run --pass-io ─qrexec──► python3 tnlogin.py ───TCP 23──────► tlntsvr
(or socat, interactively) │
▼
cmd.exe
This is a development convenience, not something I’d leave enabled. Telnet is cleartext. The exposure is limited to the single vif between the netvm and XP, because Qubes’ nftables rules drop everything else. Still, a compromised netvm owns XP. (That was already largely true through the vif.) Turn it off when you’re done (see the end of this post).
1. XP side (one-time, from a cmd window on the XP desktop)
sc config tlntsvr start= auto
net start tlntsvr
netsh firewall set portopening protocol=TCP port=23 name=Telnet mode=ENABLE
netsh firewall set icmpsetting 8 enable
tlntadmn config maxconn=10
-
Account: use an admin account with a password. If you insist on a blank password, XP refuses network logons for it (“Logon failure: user account restriction”)
- Unless… in the registry, you set:
HKLM\SYSTEM\CurrentControlSet\Control\Lsa\LimitBlankPasswordUseto 0.
I’d avoid that.
- Unless… in the registry, you set:
-
maxconn: the default is 2. Half-open probes (nc -z, orsocatwith stdin closed) count against it until they time out, and you then get “No more connections are allowed to telnet server.”net stop tlntsvr && net start tlntsvrclears them.
-
Slow greeting (15–20 s of silence after connecting): tlntsvr reverse-resolves the client. If DNS upstream is dead, it waits for the timeout. Add the netvm to
C:\WINDOWS\system32\drivers\etc\hosts:<netvm-ip> xp-netvm -
Static IP: XP’s NIC config must match what Qubes assigned. The address must equal
qvm-prefs xp-hvm ipand the gateway must equalqvm-prefs xp-netvm ip. If they don’t match, the netvm’sproxy_arpanswers XP’s gratuitous ARP, and XP reports “IP address conflict” at boot and disables its IP. Pinning both qubes’ippref to an address outside Qubes’ auto-assigned range keeps this stable. -
On my install the Xen PV NIC was named
"Local Area Connection 2"innetsh, not"Local Area Connection".
2. netvm side
You don’t need any persistent changes. The connection goes from the netvm to XP, so the netvm’s firewall needs no new rule. My netvm had no telnet binary, but it did have socat and python3.
Interactive session (from a terminal in the netvm):
socat -,raw,echo=0 TCP:<xp-ip>:23
3. mgmtvm side
mgmtvm needs to be allowed to qvm-run into the netvm. With the stock mgmtvm policy, that means the netvm carries the created-by-mgmtvm tag. Otherwise, add a qubes.VMShell / qubes.VMExec allow rule for your admin qube.
For scripted use, Claude wrote a small Python telnet client. It declines every telnet option, which makes tlntsvr drop the NTLM attempt and fall back to plain login:/password:. Then it logs in, sends each command, and prints the output up to the next > prompt:
#!/usr/bin/env python3
# tnlogin.py -- minimal scripted telnet client for a Windows XP tlntsvr.
# python3 -I tnlogin.py <host> '<user>' '<password>' --file cmds.txt
# python3 -I tnlogin.py <host> '<user>' '<password>' 'cmd 1' 'cmd 2'
import socket, time, sys
HOST = sys.argv[1]; user = sys.argv[2]; pw = sys.argv[3]; cmds = sys.argv[4:]
if cmds and cmds[0] == "--file": cmds = [l.rstrip("\n") for l in open(cmds[1]) if l.strip()]
s = socket.create_connection((HOST, 23), timeout=10); s.settimeout(1)
IAC, DO, DONT, WILL, WONT, SB, SE = 255, 253, 254, 251, 252, 250, 240
def pump(deadline):
end = time.time() + deadline; got = b""
while time.time() < end:
try: d = s.recv(4096)
except socket.timeout: continue
if not d: print("[server closed]"); return got, True
i = 0
while i < len(d):
if d[i] == IAC and i + 1 < len(d):
c = d[i+1]
if c in (DO, DONT, WILL, WONT) and i + 2 < len(d):
o = d[i+2]
if c == DO: s.send(bytes([IAC, WONT, o]))
elif c == WILL: s.send(bytes([IAC, DONT, o]))
i += 3; continue
if c == SB:
j = d.find(bytes([IAC, SE]), i); i = j + 2 if j >= 0 else len(d); continue
i += 2; continue
got += bytes([d[i]]); i += 1
return got, False
def wait_for(token, t=15):
acc = b""; end = time.time() + t
while time.time() < end:
g, closed = pump(1); acc += g
if token.lower() in acc.lower() or closed: return acc, closed
return acc, False
out, c = wait_for(b"login:"); print(out.decode("cp437","replace"), end="")
s.send(user.encode() + b"\r\n")
out, c = wait_for(b"password:"); print(out.decode("cp437","replace"), end="")
s.send(pw.encode() + b"\r\n")
out, c = wait_for(b">", 20); print(out.decode("cp437","replace"), end="")
if c: sys.exit(1)
for cmd in cmds:
s.send(cmd.encode() + b"\r\n")
out, c = wait_for(b">", 15); print(out.decode("cp437","replace"), end="")
s.send(b"exit\r\n"); pump(2)
I keep the script in mgmtvm and push it to the netvm’s /tmp on every run. Commands go in a file, base64-encoded, because the double shell quoting of qvm-run --pass-io ... "python3 ... '<cmd>'" mangles backslashes and %:
B=$(base64 -w0 ~/tnlogin.py)
cat > /tmp/cmds.txt <<'EOF'
ipconfig /all
net use
EOF
C=$(base64 -w0 /tmp/cmds.txt)
qvm-run --pass-io xp-netvm "echo $B | base64 -d > /tmp/tnlogin.py; \
echo $C | base64 -d > /tmp/cmds.txt; \
python3 -I /tmp/tnlogin.py <xp-ip> 'Administrator' 'yourpassword' --file /tmp/cmds.txt" | tr -d '\r'
(The password ends up in the netvm’s process list and in your mgmtvm shell history. Adjust if that matters to you.)
Gotchas when driving cmd.exe blind
echo select volume 1>filewritesselect volume, because1>is a stream redirect. Put a space before>.- A
)inside anechoinside anif ( ... )block closes the block (“- was unexpected at this time”). Escape it as^). net usemappings are per logon session. A drive you map over telnet won’t appear on the desktop, and the reverse is also true.netsh interface ip set address ... static <ip> <mask> <gw> 1changed the IP but kept the old gateway. Follow it withnetsh interface ip set address name="..." gateway=<gw> gwmetric=1and check the result withipconfig.- XP has no
timeout.exe. Useping -n 6 127.0.0.1 >nulas a 5-second sleep. - XP has no base64 either. To get a file in, I staged it on the netvm and served it with a temporary Samba usershare (
net usershare add ..., deleted afterwards), then rancopy \\xp-netvm\share\filein XP. Convert the file to CRLF first (sed 's/$/\r/').
Turning it off again
net stop tlntsvr
sc config tlntsvr start= disabled
netsh firewall delete portopening protocol=TCP port=23
(If you changed LimitBlankPasswordUse, set it back to 1.)
What I deliberately didn’t do
I didn’t route XP’s address into mgmtvm directly. That would need forwarding rules in the netvm and anything between it and mgmtvm. Hopping through the netvm with qvm-run keeps Qubes’ isolation intact.
Tested on Qubes 4.3 with a Windows XP SP3 standalone HVM. Feedback and better approaches are welcome.