
# vnc_server_sim.py - VNC server with version negotiation flaw
import socket, struct
def handle(conn):
# Send server version "RFB 003.008\n"
conn.send(b"RFB 003.008\n")
# Receive client version
client_ver = conn.recv(12)
# Vulnerability: if client sends "RFB 003.003", server downgrades and uses no auth
if b"003.003" in client_ver:
conn.send(struct.pack(">I", 1)) # security type 1 = None
else:
conn.send(struct.pack(">I", 2)) # VNC Auth
# ... rest of handshake
print("Downgraded to no authentication!")
s = socket.socket()
s.bind(('0.0.0.0', 5900))
s.listen(1)
while True:
conn, _ = s.accept()
handle(conn)
VNC 服务器根据客户端通告的协议版本协商安全类型。攻击者通过通告较旧版本(RFB 3.3),强制服务器降级到 “None” 认证方式,从而获得未经认证的远程桌面访问权限。
python vnc_server_sim.py
python exploit_vnc_downgrade.py
服务器选择安全类型 1 (None),从而绕过所有认证。