# 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()
RDP 服务器在没有适当访问控制的情况下信任所有虚拟通道连接。能够连接到 RDP 会话的攻击者(即使是低权限用户)可以注入恶意虚拟通道并修改共享剪贴板,从而导致数据窃取或凭据截获。
python rdp_server_sim.py
python exploit_rdp_clipboard.py