
# rdp_server_sim.py - Simulated RDP server with trusted virtual channel
from http.server import HTTPServer, BaseHTTPRequestHandler
import json, threading
clipboard = ""
# Simulate an RDP virtual channel that any client can open and write to.
# In real RDP, the CLIPRDR channel is used for clipboard sync.
class RDPHandler(BaseHTTPRequestHandler):
def do_POST(self):
global clipboard
if self.path == '/clipboard':
data = json.loads(self.rfile.read(int(self.headers['Content-Length'])))
# Vulnerability: accepts clipboard updates from any channel without auth
clipboard = data['content']
self.send_response(200)
self.end_headers()
self.wfile.write(b"Clipboard updated")
else:
self.send_response(404)
self.end_headers()
def do_GET(self):
if self.path == '/clipboard':
self.send_response(200)
self.end_headers()
self.wfile.write(clipboard.encode())
else:
self.send_response(404)
self.end_headers()
server = HTTPServer(('0.0.0.0', 3389), RDPHandler) # using HTTP for simulation
print("RDP clipboard simulator on :3389")
server.serve_forever()
An RDP server trusts all virtual channel connections without proper access control. An attacker who can connect to the RDP session (even as a low‑privileged user) can inject a malicious virtual channel and modify the shared clipboard, leading to data theft or credential interception.
python rdp_server_sim.py
python exploit_rdp_clipboard.py