python - 使用 Python 进行 VNC 身份验证中的 DES 算法
问题描述
我正在尝试使用 VNC 身份验证与 VNC 服务器 (Vino) 连接。阅读 RFC 6143 - The Remote Framebuffer Protocol,我们可以看到 VNC 身份验证的工作原理。
它使用质询-响应协议,服务器发送一个 16 字节的质询,客户端用他的密钥加密的质询进行回答。加密使用DES算法。
我使用 TigerVNC 和 Wireshark 嗅探了这个过程,以便用 Python 完成这个过程。
例如
这是我用 Wireshark 在 Vino 和 TigerVNC 之间嗅探到的流量。有用。
Server Client
|------------------ Server protocol version: 003.007 ----------------->|
|<----------------- Client protocol version: 003.007 --------------|
|------------------ Security types: 2 --------------------->|
|<----------------- Security type selected: VNC (2) ------------------|
|------------------- Authentication result: OK --------->|
|----- Authentication challenge: b4a7257a443426527dd9d987fa6b099f ----->|
|<---- Authentication response: 4838c102d8cbb1decd38ecdbec533bc7 ------|
挑战和响应是字节,而不是十六进制字符串。
但是当我用Python加密身份验证挑战时,我得到了不同的结果。我尝试使用不同的分组密码操作模式,但没有成功。
例如
>>> from pydes import des
>>> challenge = "\xb4\xa7\x25\x7a\x44\x34\x26\x52\x7d\xd9\xd9\x87\xfa\x6b\x09\x9f"
>>> key = "testingg"
>>> d = des()
>>> ciphered = d.encrypt(key,challenge,padding=True)
>>> import binascii
>>> ciphered = d.encrypt(key,challenge)
>>> binascii.hexlify(ciphered)
'4f16bc072bf34903e753b3f968b1aa56'
或者使用另一个 Python 模块:
>>> import pyDes
>>> des = pyDes.des("testingg")
>>> challenge = "\xb4\xa7\x25\x7a\x44\x34\x26\x52\x7d\xd9\xd9\x87\xfa\x6b\x09\x9f"
>>> e = des.encrypt(challenge)
>>> binascii.hexlify(e)
'4f16bc072bf34903e753b3f968b1aa56'
>>> binascii.hexlify(des.decrypt(e))
'b4a7257a443426527dd9d987fa6b099f'
我错过了什么吗?RFC 没有显示任何关于加密模式或 IV 向量的信息。
此外,我已经展示了TigerVNC的源代码,它是用Java编写的,并且对于挑战加密没有什么特别之处。
解决方案
推荐阅读
- vim - NeoMutt:如何在 Vim 中编辑收件人/主题/抄送字段?
- java - 创建名为“entityManagerFactoryBean”的bean时出错
- mysql - 签到数据建模/三向关系
- excel - 在 Excel VBA 中,通过单个过程自定义所有用户窗体
- java - 一个 Java Kafka Consumer 需要多少操作系统资源?
- angular - 角度服务数据未更新
- list - 使用迭代递归函数在 Lisp 中构建列表
- javascript - 未捕获的 ReferenceError 类未定义
- python - 从文件中读取搜索字符串并为另一个文件中的字段添加字符串
- vaadin7 - Vaadin 7.7.16 -> java.lang.ClassNotFoundException: com.vaadin.server.VaadinServlet